OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /** | 7 /** |
8 * @constructor | 8 * @constructor |
9 * @extends {WebInspector.Object} | 9 * @extends {WebInspector.Object} |
10 * @implements {WebInspector.TargetManager.Observer} | 10 * @implements {WebInspector.TargetManager.Observer} |
11 */ | 11 */ |
12 WebInspector.TracingModel = function() | 12 WebInspector.TracingManager = function() |
13 { | 13 { |
14 this.reset(); | 14 WebInspector.Object.call(this); |
15 this._active = false; | 15 this._active = false; |
16 WebInspector.targetManager.observeTargets(this); | 16 WebInspector.targetManager.observeTargets(this); |
17 } | 17 } |
18 | 18 |
19 WebInspector.TracingModel.Events = { | 19 WebInspector.TracingManager.Events = { |
20 "BufferUsage": "BufferUsage", | 20 "BufferUsage": "BufferUsage", |
21 "TracingStarted": "TracingStarted", | 21 "TracingStarted": "TracingStarted", |
22 "EventsCollected": "EventsCollected", | |
22 "TracingStopped": "TracingStopped", | 23 "TracingStopped": "TracingStopped", |
23 "TracingComplete": "TracingComplete" | 24 "TracingComplete": "TracingComplete" |
24 } | 25 } |
25 | 26 |
26 /** @typedef {!{ | 27 /** @typedef {!{ |
27 cat: string, | 28 cat: string, |
28 pid: number, | 29 pid: number, |
29 tid: number, | 30 tid: number, |
30 ts: number, | 31 ts: number, |
31 ph: string, | 32 ph: string, |
32 name: string, | 33 name: string, |
33 args: !Object, | 34 args: !Object, |
34 dur: number, | 35 dur: number, |
35 id: number, | 36 id: number, |
36 s: string | 37 s: string |
37 }} | 38 }} |
38 */ | 39 */ |
39 WebInspector.TracingModel.EventPayload; | 40 WebInspector.TracingManager.EventPayload; |
yurys
2014/09/10 09:57:42
Can we move it somewhere else to avoid dependency
caseq
2014/09/10 11:59:56
I like the idea, but let's do it as a separate cha
| |
41 | |
42 | |
43 WebInspector.TracingManager.prototype = { | |
44 /** | |
45 * @param {!WebInspector.Target} target | |
46 */ | |
47 targetAdded: function(target) | |
48 { | |
49 if (this._target) | |
50 return; | |
51 this._target = target; | |
52 InspectorBackend.registerTracingDispatcher(new WebInspector.TracingDispa tcher(this)); | |
53 }, | |
54 | |
55 /** | |
56 * @param {!WebInspector.Target} target | |
57 */ | |
58 targetRemoved: function(target) | |
59 { | |
60 if (this._target !== target) | |
61 return; | |
62 delete this._target; | |
63 }, | |
64 | |
65 /** | |
66 * @param {number} usage | |
67 */ | |
68 _bufferUsage: function(usage) | |
69 { | |
70 this.dispatchEventToListeners(WebInspector.TracingManager.Events.BufferU sage, usage); | |
71 }, | |
72 | |
73 /** | |
74 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events | |
75 */ | |
76 _eventsCollected: function(events) | |
77 { | |
78 this.dispatchEventToListeners(WebInspector.TracingManager.Events.EventsC ollected, events); | |
79 }, | |
80 | |
81 _tracingComplete: function() | |
82 { | |
83 this.dispatchEventToListeners(WebInspector.TracingManager.Events.Tracing Complete); | |
84 }, | |
85 | |
86 /** | |
87 * @param {string} categoryFilter | |
88 * @param {string} options | |
89 * @param {function(?string)=} callback | |
90 */ | |
91 start: function(categoryFilter, options, callback) | |
92 { | |
93 if (this._active) | |
94 return; | |
95 WebInspector.profilingLock().acquire(); | |
96 this._active = true; | |
97 this._shouldReleaseLock = true; | |
98 var bufferUsageReportingIntervalMs = 500; | |
99 TracingAgent.start(categoryFilter, options, bufferUsageReportingInterval Ms, callback); | |
100 this.dispatchEventToListeners(WebInspector.TracingManager.Events.Tracing Started); | |
101 }, | |
102 | |
103 stop: function() | |
104 { | |
105 if (!this._active) | |
106 return; | |
107 TracingAgent.end(this._onStop.bind(this)); | |
108 if (this._shouldReleaseLock) { | |
109 this._shouldReleaseLock = false; | |
110 WebInspector.profilingLock().release(); | |
111 } | |
112 }, | |
113 | |
114 _onStop: function() | |
115 { | |
116 if (!this._active) | |
117 return; | |
118 this.dispatchEventToListeners(WebInspector.TracingManager.Events.Tracing Stopped); | |
119 this._active = false; | |
120 }, | |
121 | |
122 __proto__: WebInspector.Object.prototype | |
123 } | |
124 | |
125 /** | |
126 * @constructor | |
127 */ | |
128 WebInspector.TracingModel = function() | |
129 { | |
130 this.reset(); | |
131 } | |
40 | 132 |
41 /** | 133 /** |
42 * @enum {string} | 134 * @enum {string} |
43 */ | 135 */ |
44 WebInspector.TracingModel.Phase = { | 136 WebInspector.TracingModel.Phase = { |
45 Begin: "B", | 137 Begin: "B", |
46 End: "E", | 138 End: "E", |
47 Complete: "X", | 139 Complete: "X", |
48 Instant: "I", | 140 Instant: "I", |
49 AsyncBegin: "S", | 141 AsyncBegin: "S", |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 * @return {boolean} | 176 * @return {boolean} |
85 */ | 177 */ |
86 WebInspector.TracingModel.isAsyncPhase = function(phase) | 178 WebInspector.TracingModel.isAsyncPhase = function(phase) |
87 { | 179 { |
88 return phase === WebInspector.TracingModel.Phase.AsyncBegin || phase === Web Inspector.TracingModel.Phase.AsyncEnd || | 180 return phase === WebInspector.TracingModel.Phase.AsyncBegin || phase === Web Inspector.TracingModel.Phase.AsyncEnd || |
89 phase === WebInspector.TracingModel.Phase.AsyncStepInto || phase === Web Inspector.TracingModel.Phase.AsyncStepPast; | 181 phase === WebInspector.TracingModel.Phase.AsyncStepInto || phase === Web Inspector.TracingModel.Phase.AsyncStepPast; |
90 } | 182 } |
91 | 183 |
92 WebInspector.TracingModel.prototype = { | 184 WebInspector.TracingModel.prototype = { |
93 /** | 185 /** |
94 * @param {!WebInspector.Target} target | |
95 */ | |
96 targetAdded: function(target) | |
97 { | |
98 if (this._target) | |
99 return; | |
100 this._target = target; | |
101 InspectorBackend.registerTracingDispatcher(new WebInspector.TracingDispa tcher(this)); | |
102 }, | |
103 | |
104 /** | |
105 * @param {!WebInspector.Target} target | |
106 */ | |
107 targetRemoved: function(target) | |
108 { | |
109 if (this._target !== target) | |
110 return; | |
111 delete this._target; | |
112 }, | |
113 | |
114 /** | |
115 * @return {!Array.<!WebInspector.TracingModel.Event>} | 186 * @return {!Array.<!WebInspector.TracingModel.Event>} |
116 */ | 187 */ |
117 devtoolsPageMetadataEvents: function() | 188 devtoolsPageMetadataEvents: function() |
118 { | 189 { |
119 return this._devtoolsPageMetadataEvents; | 190 return this._devtoolsPageMetadataEvents; |
120 }, | 191 }, |
121 | 192 |
122 /** | 193 /** |
123 * @return {!Array.<!WebInspector.TracingModel.Event>} | 194 * @return {!Array.<!WebInspector.TracingModel.Event>} |
124 */ | 195 */ |
125 devtoolsWorkerMetadataEvents: function() | 196 devtoolsWorkerMetadataEvents: function() |
126 { | 197 { |
127 return this._devtoolsWorkerMetadataEvents; | 198 return this._devtoolsWorkerMetadataEvents; |
128 }, | 199 }, |
129 | 200 |
130 /** | 201 /** |
131 * @param {string} categoryFilter | |
132 * @param {string} options | |
133 * @param {function(?string)=} callback | |
134 */ | |
135 start: function(categoryFilter, options, callback) | |
136 { | |
137 WebInspector.profilingLock().acquire(); | |
138 this._shouldReleaseLock = true; | |
139 this.reset(); | |
140 var bufferUsageReportingIntervalMs = 500; | |
141 TracingAgent.start(categoryFilter, options, bufferUsageReportingInterval Ms, callback); | |
142 this._tracingStarted(); | |
143 }, | |
144 | |
145 stop: function() | |
146 { | |
147 if (!this._active) | |
148 return; | |
149 TracingAgent.end(this._onStop.bind(this)); | |
150 if (this._shouldReleaseLock) { | |
151 this._shouldReleaseLock = false; | |
152 WebInspector.profilingLock().release(); | |
153 } | |
154 }, | |
155 | |
156 /** | |
157 * @return {?string} | 202 * @return {?string} |
158 */ | 203 */ |
159 sessionId: function() | 204 sessionId: function() |
160 { | 205 { |
161 return this._sessionId; | 206 return this._sessionId; |
162 }, | 207 }, |
163 | 208 |
164 /** | 209 /** |
165 * @param {!Array.<!WebInspector.TracingModel.EventPayload>} events | 210 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events |
166 */ | 211 */ |
167 setEventsForTest: function(events) | 212 setEventsForTest: function(events) |
168 { | 213 { |
169 this._tracingStarted(); | 214 this.reset(); |
170 this._eventsCollected(events); | 215 this.addEvents(events); |
171 this._tracingComplete(); | 216 this.tracingComplete(); |
172 }, | 217 }, |
173 | 218 |
174 /** | 219 /** |
175 * @param {number} usage | 220 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events |
176 */ | 221 */ |
177 _bufferUsage: function(usage) | 222 addEvents: function(events) |
178 { | 223 { |
179 this.dispatchEventToListeners(WebInspector.TracingModel.Events.BufferUsa ge, usage); | |
180 }, | |
181 | |
182 /** | |
183 * @param {!Array.<!WebInspector.TracingModel.EventPayload>} events | |
184 */ | |
185 _eventsCollected: function(events) | |
186 { | |
187 this._onStop(); | |
188 for (var i = 0; i < events.length; ++i) { | 224 for (var i = 0; i < events.length; ++i) { |
189 this._addEvent(events[i]); | 225 this._addEvent(events[i]); |
190 this._rawEvents.push(events[i]); | 226 this._rawEvents.push(events[i]); |
191 } | 227 } |
192 }, | 228 }, |
193 | 229 |
194 _tracingComplete: function() | 230 tracingComplete: function() |
195 { | 231 { |
196 this._processMetadataEvents(); | 232 this._processMetadataEvents(); |
197 this._active = false; | |
198 for (var process in this._processById) | 233 for (var process in this._processById) |
199 this._processById[process]._tracingComplete(this._maximumRecordTime) ; | 234 this._processById[process]._tracingComplete(this._maximumRecordTime) ; |
200 this.dispatchEventToListeners(WebInspector.TracingModel.Events.TracingCo mplete); | |
201 }, | |
202 | |
203 _tracingStarted: function() | |
204 { | |
205 if (this._active) | |
206 return; | |
207 this.reset(); | |
208 this._active = true; | |
209 this._sessionId = null; | |
210 this.dispatchEventToListeners(WebInspector.TracingModel.Events.TracingSt arted); | |
211 }, | |
212 | |
213 _onStop: function() | |
214 { | |
215 if (!this._active) | |
216 return; | |
217 this.dispatchEventToListeners(WebInspector.TracingModel.Events.TracingSt opped); | |
218 this._active = false; | |
219 }, | 235 }, |
220 | 236 |
221 reset: function() | 237 reset: function() |
222 { | 238 { |
223 this._processById = {}; | 239 this._processById = {}; |
224 this._minimumRecordTime = 0; | 240 this._minimumRecordTime = 0; |
225 this._maximumRecordTime = 0; | 241 this._maximumRecordTime = 0; |
226 this._sessionId = null; | 242 this._sessionId = null; |
227 this._devtoolsPageMetadataEvents = []; | 243 this._devtoolsPageMetadataEvents = []; |
228 this._devtoolsWorkerMetadataEvents = []; | 244 this._devtoolsWorkerMetadataEvents = []; |
229 this._rawEvents = []; | 245 this._rawEvents = []; |
230 }, | 246 }, |
231 | 247 |
232 /** | 248 /** |
233 * @return {!Array.<!WebInspector.TracingModel.EventPayload>} | 249 * @return {!Array.<!WebInspector.TracingManager.EventPayload>} |
234 */ | 250 */ |
235 rawEvents: function() | 251 rawEvents: function() |
236 { | 252 { |
237 return this._rawEvents; | 253 return this._rawEvents; |
238 }, | 254 }, |
239 | 255 |
240 /** | 256 /** |
241 * @param {!WebInspector.TracingModel.EventPayload} payload | 257 * @param {!WebInspector.TracingManager.EventPayload} payload |
242 */ | 258 */ |
243 _addEvent: function(payload) | 259 _addEvent: function(payload) |
244 { | 260 { |
245 var process = this._processById[payload.pid]; | 261 var process = this._processById[payload.pid]; |
246 if (!process) { | 262 if (!process) { |
247 process = new WebInspector.TracingModel.Process(payload.pid); | 263 process = new WebInspector.TracingModel.Process(payload.pid); |
248 this._processById[payload.pid] = process; | 264 this._processById[payload.pid] = process; |
249 } | 265 } |
250 if (payload.ph !== WebInspector.TracingModel.Phase.Metadata) { | 266 if (payload.ph !== WebInspector.TracingModel.Phase.Metadata) { |
251 var timestamp = payload.ts / 1000; | 267 var timestamp = payload.ts / 1000; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 { | 340 { |
325 return this._maximumRecordTime; | 341 return this._maximumRecordTime; |
326 }, | 342 }, |
327 | 343 |
328 /** | 344 /** |
329 * @return {!Array.<!WebInspector.TracingModel.Process>} | 345 * @return {!Array.<!WebInspector.TracingModel.Process>} |
330 */ | 346 */ |
331 sortedProcesses: function() | 347 sortedProcesses: function() |
332 { | 348 { |
333 return WebInspector.TracingModel.NamedObject._sort(Object.values(this._p rocessById)); | 349 return WebInspector.TracingModel.NamedObject._sort(Object.values(this._p rocessById)); |
334 }, | 350 } |
335 | |
336 __proto__: WebInspector.Object.prototype | |
337 } | 351 } |
338 | 352 |
339 | 353 |
340 /** | 354 /** |
341 * @constructor | 355 * @constructor |
342 * @param {!WebInspector.TracingModel} tracingModel | 356 * @param {!WebInspector.TracingModel} tracingModel |
343 */ | 357 */ |
344 WebInspector.TracingModel.Loader = function(tracingModel) | 358 WebInspector.TracingModel.Loader = function(tracingModel) |
345 { | 359 { |
346 this._tracingModel = tracingModel; | 360 this._tracingModel = tracingModel; |
347 this._firstChunkReceived = false; | 361 this._firstChunkReceived = false; |
348 } | 362 } |
349 | 363 |
350 WebInspector.TracingModel.Loader.prototype = { | 364 WebInspector.TracingModel.Loader.prototype = { |
351 /** | 365 /** |
352 * @param {!Array.<!WebInspector.TracingModel.EventPayload>} events | 366 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events |
353 */ | 367 */ |
354 loadNextChunk: function(events) | 368 loadNextChunk: function(events) |
355 { | 369 { |
356 if (!this._firstChunkReceived) { | 370 if (!this._firstChunkReceived) { |
357 this._tracingModel._tracingStarted(); | 371 this._tracingModel.reset(); |
358 this._firstChunkReceived = true; | 372 this._firstChunkReceived = true; |
359 } | 373 } |
360 this._tracingModel._eventsCollected(events); | 374 this._tracingModel.addEvents(events); |
361 }, | 375 }, |
362 | 376 |
363 finish: function() | 377 finish: function() |
364 { | 378 { |
365 this._tracingModel._tracingComplete(); | 379 this._tracingModel.tracingComplete(); |
366 } | 380 } |
367 } | 381 } |
368 | 382 |
369 | 383 |
370 /** | 384 /** |
371 * @constructor | 385 * @constructor |
372 * @param {string} category | 386 * @param {string} category |
373 * @param {string} name | 387 * @param {string} name |
374 * @param {string} phase | 388 * @param {string} phase |
375 * @param {number} startTime | 389 * @param {number} startTime |
(...skipping 19 matching lines...) Expand all Loading... | |
395 /** @type {?string} */ | 409 /** @type {?string} */ |
396 this.imageURL = null; | 410 this.imageURL = null; |
397 /** @type {number} */ | 411 /** @type {number} */ |
398 this.backendNodeId = 0; | 412 this.backendNodeId = 0; |
399 | 413 |
400 /** @type {number} */ | 414 /** @type {number} */ |
401 this.selfTime = 0; | 415 this.selfTime = 0; |
402 } | 416 } |
403 | 417 |
404 /** | 418 /** |
405 * @param {!WebInspector.TracingModel.EventPayload} payload | 419 * @param {!WebInspector.TracingManager.EventPayload} payload |
406 * @param {?WebInspector.TracingModel.Thread} thread | 420 * @param {?WebInspector.TracingModel.Thread} thread |
407 * @return {!WebInspector.TracingModel.Event} | 421 * @return {!WebInspector.TracingModel.Event} |
408 */ | 422 */ |
409 WebInspector.TracingModel.Event.fromPayload = function(payload, thread) | 423 WebInspector.TracingModel.Event.fromPayload = function(payload, thread) |
410 { | 424 { |
411 var event = new WebInspector.TracingModel.Event(payload.cat, payload.name, p ayload.ph, payload.ts / 1000, thread); | 425 var event = new WebInspector.TracingModel.Event(payload.cat, payload.name, p ayload.ph, payload.ts / 1000, thread); |
412 if (payload.args) | 426 if (payload.args) |
413 event.addArgs(payload.args); | 427 event.addArgs(payload.args); |
414 else | 428 else |
415 console.error("Missing mandatory event argument 'args' at " + payload.ts / 1000); | 429 console.error("Missing mandatory event argument 'args' at " + payload.ts / 1000); |
(...skipping 25 matching lines...) Expand all Loading... | |
441 { | 455 { |
442 // Shallow copy args to avoid modifying original payload which may be sa ved to file. | 456 // Shallow copy args to avoid modifying original payload which may be sa ved to file. |
443 for (var name in args) { | 457 for (var name in args) { |
444 if (name in this.args) | 458 if (name in this.args) |
445 console.error("Same argument name (" + name + ") is used for be gin and end phases of " + this.name); | 459 console.error("Same argument name (" + name + ") is used for be gin and end phases of " + this.name); |
446 this.args[name] = args[name]; | 460 this.args[name] = args[name]; |
447 } | 461 } |
448 }, | 462 }, |
449 | 463 |
450 /** | 464 /** |
451 * @param {!WebInspector.TracingModel.EventPayload} payload | 465 * @param {!WebInspector.TracingManager.EventPayload} payload |
452 */ | 466 */ |
453 _complete: function(payload) | 467 _complete: function(payload) |
454 { | 468 { |
455 if (payload.args) | 469 if (payload.args) |
456 this.addArgs(payload.args); | 470 this.addArgs(payload.args); |
457 else | 471 else |
458 console.error("Missing mandatory event argument 'args' at " + payloa d.ts / 1000); | 472 console.error("Missing mandatory event argument 'args' at " + payloa d.ts / 1000); |
459 this.setEndTime(payload.ts / 1000); | 473 this.setEndTime(payload.ts / 1000); |
460 } | 474 } |
461 } | 475 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
537 * @constructor | 551 * @constructor |
538 * @extends {WebInspector.TracingModel.NamedObject} | 552 * @extends {WebInspector.TracingModel.NamedObject} |
539 * @param {number} id | 553 * @param {number} id |
540 */ | 554 */ |
541 WebInspector.TracingModel.Process = function(id) | 555 WebInspector.TracingModel.Process = function(id) |
542 { | 556 { |
543 WebInspector.TracingModel.NamedObject.call(this); | 557 WebInspector.TracingModel.NamedObject.call(this); |
544 this._setName("Process " + id); | 558 this._setName("Process " + id); |
545 this._threads = {}; | 559 this._threads = {}; |
546 this._objects = {}; | 560 this._objects = {}; |
547 /** @type {!Array.<!WebInspector.TracingModel.EventPayload>} */ | 561 /** @type {!Array.<!WebInspector.TracingManager.EventPayload>} */ |
548 this._asyncEvents = []; | 562 this._asyncEvents = []; |
549 /** @type {!Object.<string, ?Array.<!WebInspector.TracingModel.Event>>} */ | 563 /** @type {!Object.<string, ?Array.<!WebInspector.TracingModel.Event>>} */ |
550 this._openAsyncEvents = []; | 564 this._openAsyncEvents = []; |
551 } | 565 } |
552 | 566 |
553 WebInspector.TracingModel.Process.prototype = { | 567 WebInspector.TracingModel.Process.prototype = { |
554 /** | 568 /** |
555 * @param {number} id | 569 * @param {number} id |
556 * @return {!WebInspector.TracingModel.Thread} | 570 * @return {!WebInspector.TracingModel.Thread} |
557 */ | 571 */ |
558 threadById: function(id) | 572 threadById: function(id) |
559 { | 573 { |
560 var thread = this._threads[id]; | 574 var thread = this._threads[id]; |
561 if (!thread) { | 575 if (!thread) { |
562 thread = new WebInspector.TracingModel.Thread(this, id); | 576 thread = new WebInspector.TracingModel.Thread(this, id); |
563 this._threads[id] = thread; | 577 this._threads[id] = thread; |
564 } | 578 } |
565 return thread; | 579 return thread; |
566 }, | 580 }, |
567 | 581 |
568 /** | 582 /** |
569 * @param {!WebInspector.TracingModel.EventPayload} payload | 583 * @param {!WebInspector.TracingManager.EventPayload} payload |
570 * @return {?WebInspector.TracingModel.Event} event | 584 * @return {?WebInspector.TracingModel.Event} event |
571 */ | 585 */ |
572 _addEvent: function(payload) | 586 _addEvent: function(payload) |
573 { | 587 { |
574 var phase = WebInspector.TracingModel.Phase; | 588 var phase = WebInspector.TracingModel.Phase; |
575 // Build async event when we've got events from all threads, so we can s ort them and process in the chronological order. | 589 // Build async event when we've got events from all threads, so we can s ort them and process in the chronological order. |
576 // However, also add individual async events to the thread flow, so we c an easily display them on the same chart as | 590 // However, also add individual async events to the thread flow, so we c an easily display them on the same chart as |
577 // other events, should we choose so. | 591 // other events, should we choose so. |
578 if (WebInspector.TracingModel.isAsyncPhase(payload.ph)) | 592 if (WebInspector.TracingModel.isAsyncPhase(payload.ph)) |
579 this._asyncEvents.push(payload); | 593 this._asyncEvents.push(payload); |
580 | 594 |
581 var event = this.threadById(payload.tid)._addEvent(payload); | 595 var event = this.threadById(payload.tid)._addEvent(payload); |
582 if (event && payload.ph === phase.SnapshotObject) | 596 if (event && payload.ph === phase.SnapshotObject) |
583 this.objectsByName(event.name).push(event); | 597 this.objectsByName(event.name).push(event); |
584 return event; | 598 return event; |
585 }, | 599 }, |
586 | 600 |
587 /** | 601 /** |
588 * @param {!number} lastEventTime | 602 * @param {!number} lastEventTime |
589 */ | 603 */ |
590 _tracingComplete: function(lastEventTime) | 604 _tracingComplete: function(lastEventTime) |
591 { | 605 { |
592 /** | 606 /** |
593 * @param {!WebInspector.TracingModel.EventPayload} a | 607 * @param {!WebInspector.TracingManager.EventPayload} a |
594 * @param {!WebInspector.TracingModel.EventPayload} b | 608 * @param {!WebInspector.TracingManager.EventPayload} b |
595 */ | 609 */ |
596 function comparePayloadTimestamp(a, b) | 610 function comparePayloadTimestamp(a, b) |
597 { | 611 { |
598 return a.ts - b.ts; | 612 return a.ts - b.ts; |
599 } | 613 } |
600 this._asyncEvents.sort(comparePayloadTimestamp).forEach(this._addAsyncEv ent, this); | 614 this._asyncEvents.sort(comparePayloadTimestamp).forEach(this._addAsyncEv ent, this); |
601 for (var key in this._openAsyncEvents) { | 615 for (var key in this._openAsyncEvents) { |
602 var steps = this._openAsyncEvents[key]; | 616 var steps = this._openAsyncEvents[key]; |
603 if (!steps) | 617 if (!steps) |
604 continue; | 618 continue; |
605 var startEvent = steps[0]; | 619 var startEvent = steps[0]; |
606 var syntheticEndEvent = new WebInspector.TracingModel.Event(startEve nt.category, startEvent.name, WebInspector.TracingModel.Phase.AsyncEnd, lastEven tTime, startEvent.thread); | 620 var syntheticEndEvent = new WebInspector.TracingModel.Event(startEve nt.category, startEvent.name, WebInspector.TracingModel.Phase.AsyncEnd, lastEven tTime, startEvent.thread); |
607 steps.push(syntheticEndEvent); | 621 steps.push(syntheticEndEvent); |
608 } | 622 } |
609 this._asyncEvents = []; | 623 this._asyncEvents = []; |
610 this._openAsyncEvents = []; | 624 this._openAsyncEvents = []; |
611 }, | 625 }, |
612 | 626 |
613 /** | 627 /** |
614 * @param {!WebInspector.TracingModel.EventPayload} payload | 628 * @param {!WebInspector.TracingManager.EventPayload} payload |
615 */ | 629 */ |
616 _addAsyncEvent: function(payload) | 630 _addAsyncEvent: function(payload) |
617 { | 631 { |
618 var phase = WebInspector.TracingModel.Phase; | 632 var phase = WebInspector.TracingModel.Phase; |
619 var timestamp = payload.ts / 1000; | 633 var timestamp = payload.ts / 1000; |
620 var key = payload.name + "." + payload.id; | 634 var key = payload.name + "." + payload.id; |
621 var steps = this._openAsyncEvents[key]; | 635 var steps = this._openAsyncEvents[key]; |
622 | 636 |
623 var thread = this.threadById(payload.tid); | 637 var thread = this.threadById(payload.tid); |
624 if (payload.ph === phase.AsyncBegin) { | 638 if (payload.ph === phase.AsyncBegin) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 /** | 720 /** |
707 * @return {?WebInspector.Target} | 721 * @return {?WebInspector.Target} |
708 */ | 722 */ |
709 target: function() | 723 target: function() |
710 { | 724 { |
711 //FIXME: correctly specify target | 725 //FIXME: correctly specify target |
712 return WebInspector.targetManager.targets()[0]; | 726 return WebInspector.targetManager.targets()[0]; |
713 }, | 727 }, |
714 | 728 |
715 /** | 729 /** |
716 * @param {!WebInspector.TracingModel.EventPayload} payload | 730 * @param {!WebInspector.TracingManager.EventPayload} payload |
717 * @return {?WebInspector.TracingModel.Event} event | 731 * @return {?WebInspector.TracingModel.Event} event |
718 */ | 732 */ |
719 _addEvent: function(payload) | 733 _addEvent: function(payload) |
720 { | 734 { |
721 var timestamp = payload.ts / 1000; | 735 var timestamp = payload.ts / 1000; |
722 if (payload.ph === WebInspector.TracingModel.Phase.End) { | 736 if (payload.ph === WebInspector.TracingModel.Phase.End) { |
723 // Quietly ignore unbalanced close events, they're legit (we could h ave missed start one). | 737 // Quietly ignore unbalanced close events, they're legit (we could h ave missed start one). |
724 if (!this._stack.length) | 738 if (!this._stack.length) |
725 return null; | 739 return null; |
726 var top = this._stack.pop(); | 740 var top = this._stack.pop(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
771 return this._asyncEvents; | 785 return this._asyncEvents; |
772 }, | 786 }, |
773 | 787 |
774 __proto__: WebInspector.TracingModel.NamedObject.prototype | 788 __proto__: WebInspector.TracingModel.NamedObject.prototype |
775 } | 789 } |
776 | 790 |
777 | 791 |
778 /** | 792 /** |
779 * @constructor | 793 * @constructor |
780 * @implements {TracingAgent.Dispatcher} | 794 * @implements {TracingAgent.Dispatcher} |
781 * @param {!WebInspector.TracingModel} tracingModel | 795 * @param {!WebInspector.TracingManager} tracingManager |
782 */ | 796 */ |
783 WebInspector.TracingDispatcher = function(tracingModel) | 797 WebInspector.TracingDispatcher = function(tracingManager) |
784 { | 798 { |
785 this._tracingModel = tracingModel; | 799 this._tracingManager = tracingManager; |
786 } | 800 } |
787 | 801 |
788 WebInspector.TracingDispatcher.prototype = { | 802 WebInspector.TracingDispatcher.prototype = { |
789 /** | 803 /** |
790 * @param {number} usage | 804 * @param {number} usage |
791 */ | 805 */ |
792 bufferUsage: function(usage) | 806 bufferUsage: function(usage) |
793 { | 807 { |
794 this._tracingModel._bufferUsage(usage); | 808 this._tracingManager._bufferUsage(usage); |
795 }, | 809 }, |
796 | 810 |
797 /** | 811 /** |
798 * @param {!Array.<!WebInspector.TracingModel.EventPayload>} data | 812 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} data |
799 */ | 813 */ |
800 dataCollected: function(data) | 814 dataCollected: function(data) |
801 { | 815 { |
802 this._tracingModel._eventsCollected(data); | 816 this._tracingManager._eventsCollected(data); |
803 }, | 817 }, |
804 | 818 |
805 tracingComplete: function() | 819 tracingComplete: function() |
806 { | 820 { |
807 this._tracingModel._tracingComplete(); | 821 this._tracingManager._tracingComplete(); |
808 }, | 822 }, |
809 | 823 |
810 started: function() | 824 started: function() |
811 { | 825 { |
yurys
2014/09/10 09:57:42
How do we handle console.timeline initiated record
caseq
2014/09/10 11:59:56
Reverted this one. Sorry, got a bit carried away w
| |
812 this._tracingModel._tracingStarted(); | |
813 } | 826 } |
814 } | 827 } |
OLD | NEW |