22
33cls . NetworkLoggerService = function ( )
44{
5- this . CONTEXT_TYPE_LOGGER = this . MAIN_CONTEXT_TYPE = "network-logger" ;
5+ this . CONTEXT_TYPE_LOGGER = this . CONTEXT_TYPE_MAIN = "network-logger" ;
66 this . CONTEXT_TYPE_CRAFTER = "request-crafter" ;
77
88 this . _get_matching_context = function ( res_id )
@@ -20,19 +20,18 @@ cls.NetworkLoggerService = function()
2020 var ctx = this . contexts [ type ] ;
2121 if ( ! ctx && force )
2222 {
23- var is_main_context = type === this . MAIN_CONTEXT_TYPE ;
23+ var is_main_context = type === this . CONTEXT_TYPE_MAIN ;
2424 ctx = this . contexts [ type ] = new cls . RequestContext ( this , is_main_context ) ;
25- this . post ( "context-established " , { "context_type" : type } ) ;
25+ this . post ( "context-added " , { "context_type" : type } ) ;
2626 }
2727 return ctx ;
2828 } ;
2929
30- this . clear_request_context = function ( type )
30+ this . remove_request_context = function ( type )
3131 {
32- // Todo: Maybe this should be called with the context gotten from get_request_context instead.
33- var type = this . CONTEXT_TYPE_LOGGER ;
32+ type = ( type || this . CONTEXT_TYPE_MAIN ) ;
3433 this . contexts [ type ] = null ;
35- this . post ( "context-cleared" ) ;
34+ this . post ( "context-removed" , { "context_type" : type } ) ;
3635 } ;
3736
3837 this . _queue_message = function ( listener , msg )
@@ -107,9 +106,9 @@ cls.NetworkLoggerService = function()
107106 if ( ! ctx )
108107 {
109108 var type = this . CONTEXT_TYPE_LOGGER ;
110- var is_main_context = type === this . MAIN_CONTEXT_TYPE ;
109+ var is_main_context = type === this . CONTEXT_TYPE_MAIN ;
111110 ctx = this . contexts [ type ] = new cls . RequestContext ( this , is_main_context ) ;
112- this . post ( "context-established " , { "context_type" : type } ) ;
111+ this . post ( "context-added " , { "context_type" : type } ) ;
113112 }
114113 ctx . update ( "urlload" , data ) ;
115114 } ;
@@ -310,7 +309,7 @@ cls.NetworkLoggerService = function()
310309 this . _doc_service = window . services [ "document-manager" ] ;
311310 this . _doc_service . addListener ( "abouttoloaddocument" , this . _on_abouttoloaddocument_bound ) ;
312311
313- messages . addListener ( "debug-context-selected" , this . clear_request_context . bind ( this , this . CONTEXT_TYPE_LOGGER ) ) ;
312+ messages . addListener ( "debug-context-selected" , this . remove_request_context . bind ( this , null ) ) ;
314313 messages . addListener ( "setting-changed" , this . _on_setting_changed_bound ) ;
315314
316315 this . _message_queue = [ ] ;
@@ -742,9 +741,8 @@ cls.RequestContextPrototype = function()
742741 this . is_waiting_for_create_request = false ;
743742 if ( status == 0 )
744743 {
745- var RESOURCEID = 0 ;
746- // todo: use the message class instead
747- this . allocated_res_ids [ msg [ RESOURCEID ] ] = id ;
744+ var data = new cls . ResourceManager [ "1.3" ] . ResourceID ( msg ) ;
745+ this . allocated_res_ids [ data . resourceID ] = id ;
748746 }
749747 else
750748 {
0 commit comments