11"use strict" ;
22
33cls . NetworkLogger = function ( )
4- {
4+ {
5+ this . _filter_entries_by_list = function ( ids , entry )
6+ {
7+ return ids . contains ( entry . id ) ;
8+ }
9+
10+ this . get_resources = function ( ids )
11+ {
12+ // ids is an optional array of entry ids.
13+ var ctx = this . get_logger_context ( ) ;
14+ var entries = ctx . get_entries ( true ) ;
15+ if ( ids )
16+ {
17+ var filter_bound = this . _filter_entries_by_list . bind ( this , ids ) ;
18+ entries = entries . filter ( filter_bound ) ;
19+ }
20+ return entries . map ( function ( entry ) { return new cls . ResourceInfo ( entry ) ; } ) ;
21+ } ;
22+
523 this . _get_matching_context = function ( res_id )
624 {
725 var crafter_context = this . _contexts [ cls . NetworkLogger . CONTEXT_TYPE_CRAFTER ] ;
@@ -380,34 +398,15 @@ cls.NetworkLogger = function()
380398 this . _res_service . requestSetResponseMode ( cls . TagManager . IGNORE_RESPONSE , resparg ) ;
381399 } . bind ( this ) ;
382400
383- this . get_resource_info = function ( resource_id )
384- {
385- // Returns a ResourceInfo based on the most recent Entry with that resource_id.
386- var entry = this . _current_context &&
387- this . _current_context . get_entries_with_res_id ( resource_id ) . last ;
388- if ( entry && entry . current_response && entry . current_response . responsebody )
389- {
390- return new cls . ResourceInfo ( entry ) ;
391- }
392- return null ;
393- } ;
394-
395- this . get_request_context = function ( )
396- {
397- return this . _current_context ;
398- } ;
399-
400401 this . init ( ) ;
401402} ;
402403cls . NetworkLogger . CONTEXT_TYPE_LOGGER = 1 ;
403404cls . NetworkLogger . CONTEXT_TYPE_CRAFTER = 2 ;
404405cls . NetworkLogger . CONTEXT_TYPE_MAIN = cls . NetworkLogger . CONTEXT_TYPE_LOGGER ;
405406
406407
407- cls . NetworkLogger . WindowContext = function ( window_id , logger , context )
408+ cls . NetworkLogger . WindowContext = function ( window_id )
408409{
409- this . _logger = logger ;
410- this . _context = context ;
411410 this . id = window_id ;
412411 this . saw_main_document = false ;
413412 this . incomplete_warn_discarded = false ;
@@ -416,22 +415,6 @@ cls.NetworkLogger.WindowContext = function(window_id, logger, context)
416415
417416cls . NetworkLogger . WindowContextPrototype = function ( )
418417{
419- this . _filter_entries = function ( resource_ids , entry , index , entries )
420- {
421- // Skip an entry if an entry with the same resource_id is found further down the list.
422- var same_resource_id = window . helpers . eq ( "resource_id" , entry . resource_id ) ;
423- return this . entry_ids . contains ( entry . id ) &&
424- ( ! resource_ids || resource_ids . contains ( entry . resource_id ) ) &&
425- entries . slice ( index + 1 ) . filter ( same_resource_id ) . length == 0 ;
426- }
427-
428- this . get_resources = function ( resource_ids )
429- {
430- var filter_bound = this . _filter_entries . bind ( this , resource_ids ) ;
431- var entries = this . _context . get_entries ( ) . filter ( filter_bound ) ;
432- return entries . map ( function ( entry ) { return new cls . ResourceInfo ( entry ) ; } ) ;
433- } ;
434-
435418 this . discard_incomplete_warning = function ( )
436419 {
437420 this . incomplete_warn_discarded = true ;
@@ -498,10 +481,10 @@ cls.RequestContextPrototype = function()
498481 return this . get_entries ( ) . filter ( this . _filter_function_bound ) ;
499482 } ;
500483
501- this . get_entries = function ( )
484+ this . get_entries = function ( dismiss_paused )
502485 {
503486 var entries = this . _logger_entries ;
504- if ( this . is_paused )
487+ if ( ! dismiss_paused && this . is_paused )
505488 entries = this . _paused_entries ;
506489
507490 return entries ;
@@ -585,7 +568,11 @@ cls.RequestContextPrototype = function()
585568 if ( eventname == "urlload" )
586569 {
587570 var id = this . _get_uid ( ) ;
588- logger_entry = new cls . NetworkLoggerEntry ( id , event . resourceID , event . documentID , this . get_starttime ( ) ) ;
571+ logger_entry = new cls . NetworkLoggerEntry ( id ,
572+ event . resourceID ,
573+ event . documentID ,
574+ event . windowID ,
575+ this . get_starttime ( ) ) ;
589576 this . _logger_entries . push ( logger_entry ) ;
590577 // Store the id in the list of entries in the window_context
591578 var window_context = event . windowID && this . get_window_context ( event . windowID , true ) ;
@@ -619,9 +606,8 @@ cls.RequestContextPrototype = function()
619606 var window_context = this . _window_contexts . filter ( helpers . eq ( "id" , window_id ) ) [ 0 ] ;
620607 if ( ! window_context && force )
621608 {
622- window_context = new cls . NetworkLogger . WindowContext ( window_id , this . _logger , this ) ;
609+ window_context = new cls . NetworkLogger . WindowContext ( window_id ) ;
623610 this . _window_contexts . push ( window_context ) ;
624- this . post_on_context_or_logger ( "window-context-added" , { "window-context" : window_context } ) ;
625611 }
626612 return window_context ;
627613 } ;
@@ -713,11 +699,12 @@ cls.RequestContextPrototype = function()
713699
714700cls . RequestContext . prototype = new cls . RequestContextPrototype ( ) ;
715701
716- cls . NetworkLoggerEntry = function ( id , resource_id , document_id , context_starttime )
702+ cls . NetworkLoggerEntry = function ( id , resource_id , document_id , window_id , context_starttime )
717703{
718704 this . id = id ;
719705 this . resource_id = resource_id ;
720706 this . document_id = document_id ;
707+ this . window_id = window_id ;
721708 this . context_starttime = context_starttime ;
722709 this . url = null ;
723710 this . human_url = "No URL" ;
@@ -1324,7 +1311,9 @@ cls.ResourceInfo = function(entry)
13241311 this . url = entry . url ;
13251312 this . document_id = entry . document_id ;
13261313 this . type = entry . type ;
1314+ this . window_id = entry . window_id ;
13271315 this . is_unloaded = entry . is_unloaded ;
1316+ this . id = entry . id ;
13281317} ;
13291318
13301319cls . ResourceInfo . prototype = new URIPrototype ( "url" ) ;
0 commit comments