@@ -275,15 +275,6 @@ public CDPSession newCDPSession(Frame frame) {
275275
276276 @ Override
277277 public void close (CloseOptions options ) {
278- withLogging ("BrowserContext.close" , () -> closeImpl (options ));
279- }
280-
281- @ Override
282- public List <Cookie > cookies (String url ) {
283- return cookies (url == null ? new ArrayList <>() : Collections .singletonList (url ));
284- }
285-
286- private void closeImpl (CloseOptions options ) {
287278 if (!closingOrClosed ) {
288279 closingOrClosed = true ;
289280 if (options == null ) {
@@ -318,54 +309,48 @@ private void closeImpl(CloseOptions options) {
318309 runUntil (() -> {}, closePromise );
319310 }
320311
312+ @ Override
313+ public List <Cookie > cookies (String url ) {
314+ return cookies (url == null ? new ArrayList <>() : Collections .singletonList (url ));
315+ }
316+
317+
321318 @ Override
322319 public void addCookies (List <Cookie > cookies ) {
323- withLogging ("BrowserContext.addCookies" , () -> {
324- JsonObject params = new JsonObject ();
325- params .add ("cookies" , gson ().toJsonTree (cookies ));
326- sendMessage ("addCookies" , params );
327- });
320+ JsonObject params = new JsonObject ();
321+ params .add ("cookies" , gson ().toJsonTree (cookies ));
322+ sendMessage ("addCookies" , params );
328323 }
329324
330325 @ Override
331326 public void addInitScript (String script ) {
332- withLogging ("BrowserContext.addInitScript" , () -> addInitScriptImpl (script ));
327+ JsonObject params = new JsonObject ();
328+ params .addProperty ("source" , script );
329+ sendMessage ("addInitScript" , params );
333330 }
334331
335332 @ Override
336333 public void addInitScript (Path path ) {
337- withLogging ("BrowserContext.addInitScript" , () -> {
338- try {
339- byte [] bytes = readAllBytes (path );
340- addInitScriptImpl (new String (bytes , UTF_8 ));
341- } catch (IOException e ) {
342- throw new PlaywrightException ("Failed to read script from file" , e );
343- }
344- });
334+ try {
335+ byte [] bytes = readAllBytes (path );
336+ addInitScript (new String (bytes , UTF_8 ));
337+ } catch (IOException e ) {
338+ throw new PlaywrightException ("Failed to read script from file" , e );
339+ }
345340 }
346341
347342 @ Override
348343 public List <Page > backgroundPages () {
349344 return new ArrayList <>(backgroundPages );
350345 }
351346
352- private void addInitScriptImpl (String script ) {
353- JsonObject params = new JsonObject ();
354- params .addProperty ("source" , script );
355- sendMessage ("addInitScript" , params );
356- }
357-
358347 @ Override
359348 public BrowserImpl browser () {
360349 return browser ;
361350 }
362351
363352 @ Override
364353 public void clearCookies (ClearCookiesOptions options ) {
365- withLogging ("BrowserContext.clearCookies" , () -> clearCookiesImpl (options ));
366- }
367-
368- private void clearCookiesImpl (ClearCookiesOptions options ) {
369354 if (options == null ) {
370355 options = new ClearCookiesOptions ();
371356 }
@@ -388,15 +373,11 @@ private static void setStringOrRegex(JsonObject params, String name, Object valu
388373
389374 @ Override
390375 public void clearPermissions () {
391- withLogging ( "BrowserContext.clearPermissions" , () -> sendMessage ("clearPermissions" ) );
376+ sendMessage ("clearPermissions" );
392377 }
393378
394379 @ Override
395380 public List <Cookie > cookies (List <String > urls ) {
396- return withLogging ("BrowserContext.cookies" , () -> cookiesImpl (urls ));
397- }
398-
399- private List <Cookie > cookiesImpl (List <String > urls ) {
400381 JsonObject params = new JsonObject ();
401382 if (urls == null ) {
402383 urls = new ArrayList <>();
@@ -409,7 +390,7 @@ private List<Cookie> cookiesImpl(List<String> urls) {
409390
410391 @ Override
411392 public void exposeBinding (String name , BindingCallback playwrightBinding , ExposeBindingOptions options ) {
412- withLogging ( "BrowserContext.exposeBinding" , () -> exposeBindingImpl (name , playwrightBinding , options ) );
393+ exposeBindingImpl (name , playwrightBinding , options );
413394 }
414395
415396 private void exposeBindingImpl (String name , BindingCallback playwrightBinding , ExposeBindingOptions options ) {
@@ -433,16 +414,11 @@ private void exposeBindingImpl(String name, BindingCallback playwrightBinding, E
433414
434415 @ Override
435416 public void exposeFunction (String name , FunctionCallback playwrightFunction ) {
436- withLogging ("BrowserContext.exposeFunction" ,
437- () -> exposeBindingImpl (name , (BindingCallback .Source source , Object ... args ) -> playwrightFunction .call (args ), null ));
417+ exposeBindingImpl (name , (BindingCallback .Source source , Object ... args ) -> playwrightFunction .call (args ), null );
438418 }
439419
440420 @ Override
441421 public void grantPermissions (List <String > permissions , GrantPermissionsOptions options ) {
442- withLogging ("BrowserContext.grantPermissions" , () -> grantPermissionsImpl (permissions , options ));
443- }
444-
445- private void grantPermissionsImpl (List <String > permissions , GrantPermissionsOptions options ) {
446422 if (options == null ) {
447423 options = new GrantPermissionsOptions ();
448424 }
@@ -456,10 +432,6 @@ private void grantPermissionsImpl(List<String> permissions, GrantPermissionsOpti
456432
457433 @ Override
458434 public PageImpl newPage () {
459- return withLogging ("BrowserContext.newPage" , () -> newPageImpl ());
460- }
461-
462- private PageImpl newPageImpl () {
463435 if (ownerPage != null ) {
464436 throw new PlaywrightException ("Please use browser.newContext()" );
465437 }
@@ -508,10 +480,8 @@ public void routeFromHAR(Path har, RouteFromHAROptions options) {
508480 }
509481
510482 private void route (UrlMatcher matcher , Consumer <Route > handler , RouteOptions options ) {
511- withLogging ("BrowserContext.route" , () -> {
512- routes .add (matcher , handler , options == null ? null : options .times );
513- updateInterceptionPatterns ();
514- });
483+ routes .add (matcher , handler , options == null ? null : options .times );
484+ updateInterceptionPatterns ();
515485 }
516486
517487 @ Override
@@ -530,10 +500,8 @@ public void routeWebSocket(Predicate<String> predicate, Consumer<WebSocketRoute>
530500 }
531501
532502 private void routeWebSocketImpl (UrlMatcher matcher , Consumer <WebSocketRoute > handler ) {
533- withLogging ("BrowserContext.routeWebSocket" , () -> {
534- webSocketRoutes .add (matcher , handler );
535- updateWebSocketInterceptionPatterns ();
536- });
503+ webSocketRoutes .add (matcher , handler );
504+ updateWebSocketInterceptionPatterns ();
537505 }
538506
539507 void recordIntoHar (PageImpl page , Path har , RouteFromHAROptions options , HarContentPolicy contentPolicy ) {
@@ -572,46 +540,36 @@ public void setDefaultTimeout(double timeout) {
572540
573541 @ Override
574542 public void setExtraHTTPHeaders (Map <String , String > headers ) {
575- withLogging ("BrowserContext.setExtraHTTPHeaders" , () -> {
576- JsonObject params = new JsonObject ();
577- JsonArray jsonHeaders = new JsonArray ();
578- for (Map .Entry <String , String > e : headers .entrySet ()) {
579- JsonObject header = new JsonObject ();
580- header .addProperty ("name" , e .getKey ());
581- header .addProperty ("value" , e .getValue ());
582- jsonHeaders .add (header );
583- }
584- params .add ("headers" , jsonHeaders );
585- sendMessage ("setExtraHTTPHeaders" , params );
586- });
543+ JsonObject params = new JsonObject ();
544+ JsonArray jsonHeaders = new JsonArray ();
545+ for (Map .Entry <String , String > e : headers .entrySet ()) {
546+ JsonObject header = new JsonObject ();
547+ header .addProperty ("name" , e .getKey ());
548+ header .addProperty ("value" , e .getValue ());
549+ jsonHeaders .add (header );
550+ }
551+ params .add ("headers" , jsonHeaders );
552+ sendMessage ("setExtraHTTPHeaders" , params );
587553 }
588554
589555 @ Override
590556 public void setGeolocation (Geolocation geolocation ) {
591- withLogging ("BrowserContext.setGeolocation" , () -> {
592- JsonObject params = new JsonObject ();
593- if (geolocation != null ) {
594- params .add ("geolocation" , gson ().toJsonTree (geolocation ));
595- }
596- sendMessage ("setGeolocation" , params );
597- });
557+ JsonObject params = new JsonObject ();
558+ if (geolocation != null ) {
559+ params .add ("geolocation" , gson ().toJsonTree (geolocation ));
560+ }
561+ sendMessage ("setGeolocation" , params );
598562 }
599563
600564 @ Override
601565 public void setOffline (boolean offline ) {
602- withLogging ("BrowserContext.setOffline" , () -> {
603- JsonObject params = new JsonObject ();
604- params .addProperty ("offline" , offline );
605- sendMessage ("setOffline" , params );
606- });
566+ JsonObject params = new JsonObject ();
567+ params .addProperty ("offline" , offline );
568+ sendMessage ("setOffline" , params );
607569 }
608570
609571 @ Override
610572 public String storageState (StorageStateOptions options ) {
611- return withLogging ("BrowserContext.storageState" , () -> storageStateImpl (options ));
612- }
613-
614- private String storageStateImpl (StorageStateOptions options ) {
615573 if (options == null ) {
616574 options = new StorageStateOptions ();
617575 }
@@ -633,10 +591,8 @@ public TracingImpl tracing() {
633591
634592 @ Override
635593 public void unrouteAll () {
636- withLogging ("BrowserContext.unrouteAll" , () -> {
637- routes .removeAll ();
638- updateInterceptionPatterns ();
639- });
594+ routes .removeAll ();
595+ updateInterceptionPatterns ();
640596 }
641597
642598 @ Override
@@ -687,10 +643,8 @@ public R get() {
687643 }
688644
689645 private void unroute (UrlMatcher matcher , Consumer <Route > handler ) {
690- withLogging ("BrowserContext.unroute" , () -> {
691- routes .remove (matcher , handler );
692- updateInterceptionPatterns ();
693- });
646+ routes .remove (matcher , handler );
647+ updateInterceptionPatterns ();
694648 }
695649
696650 private void updateInterceptionPatterns () {
0 commit comments