1212
1313namespace PuppeteerSharp
1414{
15+ /// <summary>
16+ /// Launcher controls the creation of Chromium processes or the connection remote ones.
17+ /// </summary>
1518 public class Launcher
1619 {
1720 #region Constants
@@ -29,37 +32,44 @@ public class Launcher
2932 "--metrics-recording-only" ,
3033 "--no-first-run" ,
3134 "--remote-debugging-port=0" ,
32- "--safebrowsing-disable-auto-update" ,
35+ "--safebrowsing-disable-auto-update"
3336 } ;
34-
3537 internal static readonly string [ ] AutomationArgs = {
3638 "--enable-automation" ,
3739 "--password-store=basic" ,
3840 "--use-mock-keychain"
3941 } ;
40-
42+ private const string UserDataDirArgument = "--user-data-dir" ;
4143 #endregion
4244
43- #region Private members
45+ #region Private members
46+ private static int _processCount ;
4447 private readonly ILoggerFactory _loggerFactory ;
4548 private readonly ILogger _logger ;
4649 private Process _chromeProcess ;
47- private string _temporaryUserDataDir = null ;
48- private Connection _connection = null ;
49- private Timer _timer = null ;
50+ private string _temporaryUserDataDir ;
51+ private Connection _connection ;
52+ private Timer _timer ;
5053 private LaunchOptions _options ;
5154 private TaskCompletionSource < bool > _waitForChromeToClose ;
52- private static int _processCount = 0 ;
5355 private bool _processLoaded ;
54- private const string UserDataDirArgument = "--user-data-dir" ;
55- private bool _chromiumLaunched = false ;
56+ private bool _chromiumLaunched ;
5657 #endregion
5758
5859 #region Properties
60+ /// <summary>
61+ /// Gets or sets a value indicating whether the process created by the instance is closed.
62+ /// </summary>
63+ /// <value><c>true</c> if is the process is closed; otherwise, <c>false</c>.</value>
5964 public bool IsChromeClosed { get ; internal set ; }
6065 #endregion
6166
67+ /// <summary>
68+ /// Initializes a new instance of the <see cref="PuppeteerSharp.Launcher"/> class.
69+ /// </summary>
70+ /// <param name="loggerFactory">Logger factory.</param>
6271 public Launcher ( ILoggerFactory loggerFactory = null )
72+
6373 {
6474 _loggerFactory = loggerFactory ?? new LoggerFactory ( ) ;
6575 _logger = _loggerFactory . CreateLogger < Launcher > ( ) ;
@@ -156,6 +166,12 @@ public async Task<Browser> ConnectAsync(ConnectOptions options)
156166 }
157167 }
158168
169+ /// <summary>
170+ /// Tries the delete user data dir.
171+ /// </summary>
172+ /// <returns>The task.</returns>
173+ /// <param name="times">How many times it should try to delete the folder</param>
174+ /// <param name="delay">Time to wait between tries.</param>
159175 public async Task TryDeleteUserDataDir ( int times = 10 , TimeSpan ? delay = null )
160176 {
161177 if ( ! IsChromeClosed )
@@ -195,13 +211,21 @@ public async Task TryDeleteUserDataDir(int times = 10, TimeSpan? delay = null)
195211 }
196212 }
197213
214+ /// <summary>
215+ /// Gets the executable path.
216+ /// </summary>
217+ /// <returns>The executable path.</returns>
198218 public static string GetExecutablePath ( )
199219 {
200220 var downloader = Downloader . CreateDefault ( ) ;
201221 var revisionInfo = downloader . RevisionInfo ( Downloader . CurrentPlatform , Downloader . DefaultRevision ) ;
202222 return revisionInfo . ExecutablePath ;
203223 }
204224
225+ /// <summary>
226+ /// Gets a temporary directory using <see cref="Path.GetTempPath"/> and <see cref="Path.GetRandomFileName"/>.
227+ /// </summary>
228+ /// <returns>A temporary directory.</returns>
205229 public static string GetTemporaryDirectory ( )
206230 {
207231 string tempDirectory = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
@@ -300,7 +324,7 @@ private Task<string> WaitForEndpoint(Process chromeProcess, int timeout, bool du
300324 chromeProcess . StartInfo . RedirectStandardOutput = true ;
301325 chromeProcess . StartInfo . RedirectStandardError = true ;
302326
303- EventHandler exitedEvent = ( sender , e ) =>
327+ void exitedEvent ( object sender , EventArgs e )
304328 {
305329 if ( _options . LogProcess && ! _processLoaded )
306330 {
@@ -310,7 +334,7 @@ private Task<string> WaitForEndpoint(Process chromeProcess, int timeout, bool du
310334 CleanUp ( ) ;
311335
312336 taskWrapper . SetException ( new ChromeProcessException ( $ "Failed to launch chrome! { output } ") ) ;
313- } ;
337+ }
314338
315339 chromeProcess . ErrorDataReceived += ( sender , e ) =>
316340 {
0 commit comments