11"use strict" ;
22
3- cls . NetworkLoggerService = function ( )
3+ cls . NetworkLogger = function ( )
44{
5- this . CONTEXT_TYPE_LOGGER = this . CONTEXT_TYPE_MAIN = 1 ;
6- this . CONTEXT_TYPE_CRAFTER = 2 ;
7-
85 this . _get_matching_context = function ( res_id )
96 {
10- var crafter_context = this . _contexts [ this . CONTEXT_TYPE_CRAFTER ] ;
7+ var crafter_context = this . _contexts [ cls . NetworkLogger . CONTEXT_TYPE_CRAFTER ] ;
118 if ( crafter_context && res_id in crafter_context . allocated_res_ids )
129 return crafter_context ;
1310
14- var logger_context = this . _contexts [ this . CONTEXT_TYPE_LOGGER ] ;
11+ var logger_context = this . _contexts [ cls . NetworkLogger . CONTEXT_TYPE_LOGGER ] ;
1512 return logger_context ;
1613 } ;
1714
@@ -20,7 +17,7 @@ cls.NetworkLoggerService = function()
2017 var ctx = this . _contexts [ type ] ;
2118 if ( ! ctx && force )
2219 {
23- var is_main_context = type === this . CONTEXT_TYPE_MAIN ;
20+ var is_main_context = type === cls . NetworkLogger . CONTEXT_TYPE_MAIN ;
2421 ctx = this . _contexts [ type ] = new cls . RequestContext ( this , is_main_context ) ;
2522 this . post ( "context-added" , { "context_type" : type , "context" : ctx } ) ;
2623 }
@@ -29,42 +26,42 @@ cls.NetworkLoggerService = function()
2926
3027 this . get_logger_context = function ( )
3128 {
32- return this . _get_request_context ( this . CONTEXT_TYPE_LOGGER ) ;
29+ return this . _get_request_context ( cls . NetworkLogger . CONTEXT_TYPE_LOGGER ) ;
3330 } ;
3431
35- this . get_logger_context = function ( force )
32+ this . get_crafter_context = function ( force )
3633 {
37- return this . _get_request_context ( this . CONTEXT_TYPE_CRAFTER , force ) ;
34+ return this . _get_request_context ( cls . NetworkLogger . CONTEXT_TYPE_CRAFTER , force ) ;
3835 } ;
3936
4037 this . _remove_request_context = function ( type )
4138 {
42- type = type || this . CONTEXT_TYPE_MAIN ;
39+ type = type || cls . NetworkLogger . CONTEXT_TYPE_MAIN ;
4340 this . _contexts [ type ] = null ;
4441 this . post ( "context-removed" , { "context_type" : type } ) ;
4542 } ;
4643
4744 this . remove_logger_request_context = function ( )
4845 {
49- return this . _remove_request_context ( this . CONTEXT_TYPE_LOGGER ) ;
46+ return this . _remove_request_context ( cls . NetworkLogger . CONTEXT_TYPE_LOGGER ) ;
5047 } ;
5148
5249 this . remove_crafter_request_context = function ( )
5350 {
54- return this . _remove_request_context ( this . CONTEXT_TYPE_CRAFTER ) ;
51+ return this . _remove_request_context ( cls . NetworkLogger . CONTEXT_TYPE_CRAFTER ) ;
5552 } ;
5653
57- // get_window_contexts means "of the main context" here (on the service ). That's in line
54+ // get_window_contexts means "of the main context" here (on the logger ). That's in line
5855 // with messages of the main context firing here instead of on the context.
5956 this . get_window_contexts = function ( type )
6057 {
61- var ctx = this . _get_request_context ( this . CONTEXT_TYPE_MAIN ) ;
58+ var ctx = this . _get_request_context ( cls . NetworkLogger . CONTEXT_TYPE_MAIN ) ;
6259 return ctx && ctx . get_window_contexts ( ) ;
6360 } ;
6461
6562 this . _queue_message = function ( listener , msg )
6663 {
67- var crafter = this . _contexts [ this . CONTEXT_TYPE_CRAFTER ] ;
64+ var crafter = this . _contexts [ cls . NetworkLogger . CONTEXT_TYPE_CRAFTER ] ;
6865 if ( crafter && crafter . is_waiting_for_create_request )
6966 {
7067 // Store in a queue. Before we know what resourceID create_request
@@ -97,7 +94,7 @@ cls.NetworkLoggerService = function()
9794
9895 // For this event, the context is always of type CONTEXT_TYPE_LOGGER.
9996 // That needs to be static here, because a new context will be created if it doesn't exist.
100- var ctx = this . _get_request_context ( this . CONTEXT_TYPE_LOGGER , true ) ;
97+ var ctx = this . _get_request_context ( cls . NetworkLogger . CONTEXT_TYPE_LOGGER , true ) ;
10198
10299 // Without a parentDocumentID, this event means "unload" for the old content of this windowID.
103100 if ( ! data . parentDocumentID )
@@ -119,8 +116,8 @@ cls.NetworkLoggerService = function()
119116 var ctx = this . _get_matching_context ( data . resourceID ) ;
120117 if ( ! ctx )
121118 {
122- var type = this . CONTEXT_TYPE_LOGGER ;
123- var is_main_context = type === this . CONTEXT_TYPE_MAIN ;
119+ var type = cls . NetworkLogger . CONTEXT_TYPE_LOGGER ;
120+ var is_main_context = type === cls . NetworkLogger . CONTEXT_TYPE_MAIN ;
124121 ctx = this . _contexts [ type ] = new cls . RequestContext ( this , is_main_context ) ;
125122 this . post ( "context-added" , { "context_type" : type , "context" : ctx } ) ;
126123 }
@@ -394,7 +391,7 @@ cls.NetworkLoggerService = function()
394391
395392 this . _handle_get_resource = function ( status , data , resource_id )
396393 {
397- var ctx = this . _get_request_context ( this . CONTEXT_TYPE_LOGGER ) ;
394+ var ctx = this . _get_request_context ( cls . NetworkLogger . CONTEXT_TYPE_LOGGER ) ;
398395 if ( status )
399396 {
400397 // the object passed to _current_context represents empty event_data. will set no_used_mimetype.
@@ -407,24 +404,27 @@ cls.NetworkLoggerService = function()
407404 }
408405 // Post update message from here. This is only needed when the generic updating per event is paused.
409406 if ( this . is_paused )
410- ctx . post_on_context_or_service ( "resource-update" , { id : event . resourceID } ) ;
407+ ctx . post_on_context_or_logger ( "resource-update" , { id : event . resourceID } ) ;
411408
412409 } ;
413410
414411 this . init ( ) ;
415412} ;
413+ cls . NetworkLogger . CONTEXT_TYPE_LOGGER = 1 ;
414+ cls . NetworkLogger . CONTEXT_TYPE_CRAFTER = 2 ;
415+ cls . NetworkLogger . CONTEXT_TYPE_MAIN = cls . NetworkLogger . CONTEXT_TYPE_LOGGER ;
416416
417- cls . NetworkLoggerService . WindowContext = function ( window_id , service , context )
417+ cls . NetworkLogger . WindowContext = function ( window_id , logger , context )
418418{
419- this . _service = service ;
419+ this . _logger = logger ;
420420 this . _context = context ;
421421 this . id = window_id ;
422422 this . saw_main_document = false ;
423423 this . incomplete_warn_discarded = false ;
424424 this . entry_ids = [ ] ;
425425} ;
426426
427- cls . NetworkLoggerService . WindowContextPrototype = function ( )
427+ cls . NetworkLogger . WindowContextPrototype = function ( )
428428{
429429 this . _filter_entries = function ( resource_ids , entry , index , entries )
430430 {
@@ -448,9 +448,9 @@ cls.NetworkLoggerService.WindowContextPrototype = function()
448448 } ;
449449} ;
450450
451- cls . NetworkLoggerService . WindowContext . prototype = new cls . NetworkLoggerService . WindowContextPrototype ( ) ;
451+ cls . NetworkLogger . WindowContext . prototype = new cls . NetworkLogger . WindowContextPrototype ( ) ;
452452
453- cls . RequestContext = function ( service , is_main_context )
453+ cls . RequestContext = function ( logger , is_main_context )
454454{
455455 this . FILTER_ALLOW_ALL = {
456456 type_list : [ ] ,
@@ -462,7 +462,7 @@ cls.RequestContext = function(service, is_main_context)
462462 this . _logger_entries = [ ] ;
463463 this . _filters = [ this . FILTER_ALLOW_ALL ] ;
464464 this . _is_main_context = is_main_context ;
465- this . _service = service ;
465+ this . _logger = logger ;
466466 this . _window_contexts = [ ] ;
467467 this . _init ( ) ;
468468} ;
@@ -659,15 +659,15 @@ cls.RequestContextPrototype = function()
659659
660660 if ( ! this . is_paused )
661661 {
662- this . post_on_context_or_service ( "resource-update" , { id : event . resourceID } ) ;
662+ this . post_on_context_or_logger ( "resource-update" , { id : event . resourceID } ) ;
663663 }
664664 } ;
665665
666- this . post_on_context_or_service = function ( name , body )
666+ this . post_on_context_or_logger = function ( name , body )
667667 {
668668 // Find out where to post the update message.
669- // Messages of main_contexts are posted on the service , not the context.
670- var posting_object = this . _is_main_context ? this . _service : this ;
669+ // Messages of main_contexts are posted on the logger , not the context.
670+ var posting_object = this . _is_main_context ? this . _logger : this ;
671671 posting_object . post ( name , body ) ;
672672 } ;
673673
@@ -682,9 +682,9 @@ cls.RequestContextPrototype = function()
682682 var window_context = this . _window_contexts . filter ( helpers . eq ( "id" , window_id ) ) [ 0 ] ;
683683 if ( ! window_context && force )
684684 {
685- window_context = new cls . NetworkLoggerService . WindowContext ( window_id , this . _service , this ) ;
685+ window_context = new cls . NetworkLogger . WindowContext ( window_id , this . _logger , this ) ;
686686 this . _window_contexts . push ( window_context ) ;
687- this . post_on_context_or_service ( "window-context-added" , { "window-context" : window_context } ) ;
687+ this . post_on_context_or_logger ( "window-context-added" , { "window-context" : window_context } ) ;
688688 }
689689 return window_context ;
690690 } ;
@@ -708,7 +708,7 @@ cls.RequestContextPrototype = function()
708708 return window_id != context . id ;
709709 }
710710 ) ;
711- this . post_on_context_or_service ( "window-context-removed" , { "window-id" : window_id } ) ;
711+ this . post_on_context_or_logger ( "window-context-removed" , { "window-id" : window_id } ) ;
712712 } ;
713713
714714 this . get_entry_from_filtered = function ( id )
@@ -733,16 +733,22 @@ cls.RequestContextPrototype = function()
733733 this . send_request = function ( url , requestdata )
734734 {
735735 var windowid = window . window_manager_data . get_debug_context ( ) ;
736+ var PAYLOAD = null ;
737+ var HEADER_POLICY_OVERWRITE = 2 ;
738+ var HEADER_POLICY_REPLACE = 3 ;
739+ var RELOAD_POLICY_NO_CACHE = 2 ;
740+ var REQUEST_CONTENT_MODE = null ;
741+ var RESPONSE_CONTENT_MODE_STRING_DECODE = [ 1 , 1 ] ;
736742 var request = [
737743 windowid ,
738744 url ,
739745 requestdata . method ,
740746 requestdata . headers ,
741- null , // payload
742- 3 , // header policy. 2 == overwrite, 3 == replace
743- 2 , // reload policy. 2 == no cache, always reload from network
744- null , // request content mode
745- [ 1 , 1 ] // response content mode 1 == string, 1 == decode
747+ PAYLOAD ,
748+ HEADER_POLICY_REPLACE ,
749+ RELOAD_POLICY_NO_CACHE ,
750+ REQUEST_CONTENT_MODE ,
751+ RESPONSE_CONTENT_MODE_STRING_DECODE
746752 ] ;
747753 this . is_waiting_for_create_request = true ;
748754 var id = this . _get_uid ( ) ;
@@ -1181,7 +1187,7 @@ cls.NetworkLoggerEntryPrototype = function()
11811187 this . events . push ( evt ) ;
11821188 } ;
11831189
1184- this . check_to_request_body = function ( service )
1190+ this . check_to_request_body = function ( logger )
11851191 {
11861192 // Decide if body should be fetched, for when content-tracking is off or it's a cached request.
11871193 if (
@@ -1193,7 +1199,7 @@ cls.NetworkLoggerEntryPrototype = function()
11931199 ( ! this . _current_response || this . _current_response . saw_responsefinished )
11941200 )
11951201 {
1196- service . get_body ( this ) ;
1202+ logger . get_body ( this ) ;
11971203 }
11981204 } ;
11991205
@@ -1221,7 +1227,7 @@ cls.NetworkLoggerEntryPrototype = function()
12211227 this . __defineGetter__ ( "current_response" , function ( )
12221228 {
12231229 // In 99% of the cases, _current_response is used. It's only
1224- // exposed for getting the ResourceInfo from the service directly.
1230+ // exposed for getting the ResourceInfo from the logger directly.
12251231 return this . _current_response ;
12261232 } ) ;
12271233 this . __defineSetter__ ( "current_response" , function ( ) { } ) ;
0 commit comments