@@ -29,7 +29,7 @@ cls.NetworkLoggerService = function()
2929
3030 this . remove_request_context = function ( type )
3131 {
32- type = ( type || this . CONTEXT_TYPE_MAIN ) ;
32+ type = type || this . CONTEXT_TYPE_MAIN ;
3333 this . _contexts [ type ] = null ;
3434 this . post ( "context-removed" , { "context_type" : type } ) ;
3535 } ;
@@ -45,22 +45,18 @@ cls.NetworkLoggerService = function()
4545 this . _queue_message = function ( listener , msg )
4646 {
4747 var crafter = this . _contexts [ this . CONTEXT_TYPE_CRAFTER ] ;
48- if ( crafter )
48+ if ( crafter && crafter . is_waiting_for_create_request )
4949 {
50- if ( crafter . is_waiting_for_create_request )
51- {
52- // Store in a queue. Before we know what resourceID create_request
53- // will return, messages can't be assorciated with the right context.
54- this . _message_queue . push ( [ listener , msg ] ) ;
55- return true ;
56- }
57- else
58- {
59- // Play back the message queue.
60- while ( this . _message_queue . length )
61- this . _playback_message_bound ( this . _message_queue . shift ( ) ) ;
62-
63- }
50+ // Store in a queue. Before we know what resourceID create_request
51+ // will return, messages can't be associated with the right context.
52+ this . _message_queue . push ( [ listener , msg ] ) ;
53+ return true ;
54+ }
55+ else
56+ {
57+ // Play back the message queue.
58+ while ( this . _message_queue . length )
59+ this . _playback_message_bound ( this . _message_queue . shift ( ) ) ;
6460 }
6561 return false ;
6662 } ;
@@ -69,12 +65,12 @@ cls.NetworkLoggerService = function()
6965 {
7066 var LISTENER = 0 ;
7167 var MSG = 1 ;
72- queued [ LISTENER ] . call ( this , queued [ LISTENER ] , queued [ MSG ] , true ) ;
68+ queued [ LISTENER ] . call ( this , queued [ MSG ] , true ) ;
7369 } . bind ( this ) ;
7470
75- this . _on_abouttoloaddocument = function ( listener , msg , is_playing_back )
71+ this . _on_abouttoloaddocument = function on_abouttoloaddocument ( msg , is_playing_back )
7672 {
77- if ( ! is_playing_back && this . _queue_message ( listener , msg ) )
73+ if ( ! is_playing_back && this . _queue_message ( on_abouttoloaddocument , msg ) )
7874 return ;
7975
8076 var data = new cls . DocumentManager [ "1.0" ] . AboutToLoadDocument ( msg ) ;
@@ -92,11 +88,11 @@ cls.NetworkLoggerService = function()
9288 window_context . saw_main_document = true ;
9389
9490 } ;
95- this . _on_abouttoloaddocument_bound = this . _on_abouttoloaddocument . bind ( this , this . _on_abouttoloaddocument_bound ) ;
91+ this . _on_abouttoloaddocument_bound = this . _on_abouttoloaddocument . bind ( this ) ;
9692
97- this . _on_urlload = function ( listener , msg , is_playing_back )
93+ this . _on_urlload = function on_urlload ( msg , is_playing_back )
9894 {
99- if ( ! is_playing_back && this . _queue_message ( listener , msg ) )
95+ if ( ! is_playing_back && this . _queue_message ( on_urlload , msg ) )
10096 return ;
10197
10298 var data = new cls . ResourceManager [ "1.2" ] . UrlLoad ( msg ) ;
@@ -110,11 +106,11 @@ cls.NetworkLoggerService = function()
110106 }
111107 ctx . update ( "urlload" , data ) ;
112108 } ;
113- this . _on_urlload_bound = this . _on_urlload . bind ( this , this . _on_urlload ) ;
109+ this . _on_urlload_bound = this . _on_urlload . bind ( this ) ;
114110
115- this . _on_urlredirect = function ( listener , msg , is_playing_back )
111+ this . _on_urlredirect = function on_urlredirect ( msg , is_playing_back )
116112 {
117- if ( ! is_playing_back && this . _queue_message ( listener , msg ) )
113+ if ( ! is_playing_back && this . _queue_message ( on_urlredirect , msg ) )
118114 return ;
119115
120116 var data = new cls . ResourceManager [ "1.0" ] . UrlRedirect ( msg ) ;
@@ -132,11 +128,11 @@ cls.NetworkLoggerService = function()
132128
133129 ctx . update ( "urlredirect" , data ) ;
134130 } ;
135- this . _on_urlredirect_bound = this . _on_urlredirect . bind ( this , this . _on_urlredirect ) ;
131+ this . _on_urlredirect_bound = this . _on_urlredirect . bind ( this ) ;
136132
137- this . _on_urlfinished = function ( listener , msg , is_playing_back )
133+ this . _on_urlfinished = function on_urlfinished ( msg , is_playing_back )
138134 {
139- if ( ! is_playing_back && this . _queue_message ( listener , msg ) )
135+ if ( ! is_playing_back && this . _queue_message ( on_urlfinished , msg ) )
140136 return ;
141137
142138 var data = new cls . ResourceManager [ "1.0" ] . UrlFinished ( msg ) ;
@@ -150,11 +146,11 @@ cls.NetworkLoggerService = function()
150146 // don't belong to the crafter.
151147 delete ctx . allocated_res_ids [ data . resourceID ] ;
152148 } ;
153- this . _on_urlfinished_bound = this . _on_urlfinished . bind ( this , this . _on_urlfinished ) ;
149+ this . _on_urlfinished_bound = this . _on_urlfinished . bind ( this ) ;
154150
155- this . _on_response_bound = function ( listener , msg , is_playing_back )
151+ this . _on_response_bound = function on_response_bound ( msg , is_playing_back )
156152 {
157- if ( ! is_playing_back && this . _queue_message ( listener , msg ) )
153+ if ( ! is_playing_back && this . _queue_message ( on_response_bound , msg ) )
158154 return ;
159155
160156 var data = new cls . ResourceManager [ "1.0" ] . Response ( msg ) ;
@@ -164,11 +160,11 @@ cls.NetworkLoggerService = function()
164160
165161 ctx . update ( "response" , data ) ;
166162 }
167- this . _on_response_bound = this . _on_response_bound . bind ( this , this . _on_response_bound ) ;
163+ this . _on_response_bound = this . _on_response_bound . bind ( this ) ;
168164
169- this . _on_request = function ( listener , msg , is_playing_back )
165+ this . _on_request = function on_request ( msg , is_playing_back )
170166 {
171- if ( ! is_playing_back && this . _queue_message ( listener , msg ) )
167+ if ( ! is_playing_back && this . _queue_message ( on_request , msg ) )
172168 return ;
173169
174170 var data = new cls . ResourceManager [ "1.0" ] . Request ( msg ) ;
@@ -178,11 +174,11 @@ cls.NetworkLoggerService = function()
178174
179175 ctx . update ( "request" , data ) ;
180176 } ;
181- this . _on_request_bound = this . _on_request . bind ( this , this . _on_request ) ;
177+ this . _on_request_bound = this . _on_request . bind ( this ) ;
182178
183- this . _on_requestheader = function ( listener , msg , is_playing_back )
179+ this . _on_requestheader = function on_requestheader ( msg , is_playing_back )
184180 {
185- if ( ! is_playing_back && this . _queue_message ( listener , msg ) )
181+ if ( ! is_playing_back && this . _queue_message ( on_requestheader , msg ) )
186182 return ;
187183
188184 var data = new cls . ResourceManager [ "1.0" ] . RequestHeader ( msg ) ;
@@ -192,11 +188,11 @@ cls.NetworkLoggerService = function()
192188
193189 ctx . update ( "requestheader" , data ) ;
194190 } ;
195- this . _on_requestheader_bound = this . _on_requestheader . bind ( this , this . _on_requestheader ) ;
191+ this . _on_requestheader_bound = this . _on_requestheader . bind ( this ) ;
196192
197- this . _on_requestfinished = function ( listener , msg , is_playing_back )
193+ this . _on_requestfinished = function on_requestfinished ( msg , is_playing_back )
198194 {
199- if ( ! is_playing_back && this . _queue_message ( listener , msg ) )
195+ if ( ! is_playing_back && this . _queue_message ( on_requestfinished , msg ) )
200196 return ;
201197
202198 var data = new cls . ResourceManager [ "1.0" ] . RequestFinished ( msg ) ;
@@ -206,11 +202,11 @@ cls.NetworkLoggerService = function()
206202
207203 ctx . update ( "requestfinished" , data ) ;
208204 } ;
209- this . _on_requestfinished_bound = this . _on_requestfinished . bind ( this , this . _on_requestfinished ) ;
205+ this . _on_requestfinished_bound = this . _on_requestfinished . bind ( this ) ;
210206
211- this . _on_requestretry = function ( listener , msg , is_playing_back )
207+ this . _on_requestretry = function on_requestretry ( msg , is_playing_back )
212208 {
213- if ( ! is_playing_back && this . _queue_message ( listener , msg ) )
209+ if ( ! is_playing_back && this . _queue_message ( on_requestretry , msg ) )
214210 return ;
215211
216212 var data = new cls . ResourceManager [ "1.0" ] . RequestRetry ( msg ) ;
@@ -220,11 +216,11 @@ cls.NetworkLoggerService = function()
220216
221217 ctx . update ( "requestretry" , data ) ;
222218 } ;
223- this . _on_requestretry_bound = this . _on_requestretry . bind ( this , this . _on_requestretry ) ;
219+ this . _on_requestretry_bound = this . _on_requestretry . bind ( this ) ;
224220
225- this . _on_responseheader = function ( listener , msg , is_playing_back )
221+ this . _on_responseheader = function on_responseheader ( msg , is_playing_back )
226222 {
227- if ( ! is_playing_back && this . _queue_message ( listener , msg ) )
223+ if ( ! is_playing_back && this . _queue_message ( on_responseheader , msg ) )
228224 return ;
229225
230226 var data = new cls . ResourceManager [ "1.0" ] . ResponseHeader ( msg ) ;
@@ -234,11 +230,11 @@ cls.NetworkLoggerService = function()
234230
235231 ctx . update ( "responseheader" , data ) ;
236232 } ;
237- this . _on_responseheader_bound = this . _on_responseheader . bind ( this , this . _on_responseheader ) ;
233+ this . _on_responseheader_bound = this . _on_responseheader . bind ( this ) ;
238234
239- this . _on_responsefinished = function ( listener , msg , is_playing_back )
235+ this . _on_responsefinished = function on_responsefinished ( msg , is_playing_back )
240236 {
241- if ( ! is_playing_back && this . _queue_message ( listener , msg ) )
237+ if ( ! is_playing_back && this . _queue_message ( on_responsefinished , msg ) )
242238 return ;
243239
244240 var data = new cls . ResourceManager [ "1.0" ] . ResponseFinished ( msg ) ;
@@ -266,11 +262,11 @@ cls.NetworkLoggerService = function()
266262 delete ctx . allocated_res_ids [ data . resourceID ] ;
267263
268264 } ;
269- this . _on_responsefinished_bound = this . _on_responsefinished . bind ( this , this . _on_responsefinished ) ;
265+ this . _on_responsefinished_bound = this . _on_responsefinished . bind ( this ) ;
270266
271- this . _on_urlunload = function ( listener , msg , is_playing_back )
267+ this . _on_urlunload = function on_urlunload ( msg , is_playing_back )
272268 {
273- if ( ! is_playing_back && this . _queue_message ( listener , msg ) )
269+ if ( ! is_playing_back && this . _queue_message ( on_urlunload , msg ) )
274270 return ;
275271
276272 var data = new cls . ResourceManager [ "1.2" ] . UrlUnload ( msg ) ;
@@ -280,7 +276,7 @@ cls.NetworkLoggerService = function()
280276
281277 ctx . update ( "urlunload" , data ) ;
282278 } ;
283- this . _on_urlunload_bound = this . _on_urlunload . bind ( this , this . _on_urlunload ) ;
279+ this . _on_urlunload_bound = this . _on_urlunload . bind ( this ) ;
284280
285281 this . _setup_request_body_behaviour_bound = function ( )
286282 {
@@ -423,7 +419,7 @@ cls.NetworkLoggerService.WindowContextPrototype = function()
423419 {
424420 var filter_bound = this . _filter_entries . bind ( this , resource_ids ) ;
425421 var entries = this . _context . get_entries ( ) . filter ( filter_bound ) ;
426- return entries . map ( function ( entry ) { return new cls . ResourceInfo ( entry ) } ) ;
422+ return entries . map ( function ( entry ) { return new cls . ResourceInfo ( entry ) ; } ) ;
427423 } ;
428424
429425 this . discard_incomplete_warning = function ( )
@@ -438,7 +434,7 @@ cls.RequestContext = function(service, is_main_context)
438434{
439435 this . FILTER_ALLOW_ALL = {
440436 type_list : [ ] ,
441- " is_blacklist" : true
437+ is_blacklist : true
442438 } ;
443439 this . allocated_res_ids = [ ] ;
444440 this . is_paused = false ;
@@ -625,11 +621,16 @@ cls.RequestContextPrototype = function()
625621 this . _logger_entries . push ( logger_entry ) ;
626622 // Store the id in the list of entries in the window_context
627623 var window_context = ( event . windowID && this . get_window_context ( event . windowID , true ) ) ;
628- window_context . entry_ids . push ( id ) ;
624+ if ( window_context )
625+ window_context . entry_ids . push ( id ) ;
629626 }
630627 logger_entry . request_id = event . requestID ;
631628
632629 // Add a mapped crafter_request_id when applicable
630+ var crafter_request_id = this . allocated_res_ids [ res_id ] ;
631+ if ( crafter_request_id && ! logger_entry . crafter_request_id )
632+ logger_entry . crafter_request_id = crafter_request_id ;
633+
633634 if ( res_id in this . allocated_res_ids )
634635 logger_entry . crafter_request_id = this . allocated_res_ids [ res_id ] ;
635636
@@ -646,10 +647,7 @@ cls.RequestContextPrototype = function()
646647 {
647648 // Find out where to post the update message.
648649 // Messages of main_contexts are posted on the service, not the context.
649- var posting_object = this ;
650- if ( this . _is_main_context )
651- posting_object = this . _service ;
652-
650+ var posting_object = this . _is_main_context ? this . _service : this ;
653651 posting_object . post ( name , body ) ;
654652 } ;
655653
@@ -724,11 +722,11 @@ cls.RequestContextPrototype = function()
724722 3 , // header policy. 2 == overwrite, 3 == replace
725723 2 , // reload policy. 2 == no cache, always reload from network
726724 null , // request content mode
727- [ 1 , 1 ] // response content mode 1 == string, 1 == decodee
725+ [ 1 , 1 ] // response content mode 1 == string, 1 == decode
728726 ] ;
729727 this . is_waiting_for_create_request = true ;
730728 var id = this . _get_uid ( ) ;
731- var tag = window . tagManager . set_callback ( null , this . _handle_create_request . bind ( this ) , [ id ] ) ;
729+ var tag = window . tag_manager . set_callback ( null , this . _handle_create_request . bind ( this ) , [ id ] ) ;
732730 window . services [ "resource-manager" ] . requestCreateRequest ( tag , request ) ;
733731 return id ;
734732 } ;
@@ -780,6 +778,7 @@ cls.NetworkLoggerEntry = function(id, resource_id, document_id, context_starttim
780778 this . _current_request = null ;
781779 this . _current_response = null ;
782780 this . _set_is_finished_on_responsefinished = false ;
781+ this . crafter_request_id = null ;
783782} ;
784783
785784cls . NetworkLoggerEntryPrototype = function ( )
0 commit comments