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.TargetAwareObject} | 9 * @extends {WebInspector.TargetAwareObject} |
10 */ | 10 */ |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 WebInspector.TracingModel.FrameLifecycleEventCategory = "cc,devtools"; | 70 WebInspector.TracingModel.FrameLifecycleEventCategory = "cc,devtools"; |
71 | 71 |
72 WebInspector.TracingModel.DevToolsMetadataEvent = { | 72 WebInspector.TracingModel.DevToolsMetadataEvent = { |
73 TracingStartedInPage: "TracingStartedInPage", | 73 TracingStartedInPage: "TracingStartedInPage", |
74 }; | 74 }; |
75 | 75 |
76 WebInspector.TracingModel.prototype = { | 76 WebInspector.TracingModel.prototype = { |
77 /** | 77 /** |
78 * @return {!Array.<!WebInspector.TracingModel.Event>} | 78 * @return {!Array.<!WebInspector.TracingModel.Event>} |
79 */ | 79 */ |
80 inspectedTargetEvents: function() | 80 devtoolsMetadataEvents: function() |
81 { | 81 { |
82 return this._inspectedTargetEvents; | 82 return this._devtoolsMetadataEvents; |
83 }, | 83 }, |
84 | 84 |
85 /** | 85 /** |
86 * @param {string} categoryFilter | 86 * @param {string} categoryFilter |
87 * @param {string} options | 87 * @param {string} options |
88 * @param {function(?string)=} callback | 88 * @param {function(?string)=} callback |
89 */ | 89 */ |
90 start: function(categoryFilter, options, callback) | 90 start: function(categoryFilter, options, callback) |
91 { | 91 { |
92 this.reset(); | 92 this.reset(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 */ | 148 */ |
149 _eventsCollected: function(events) | 149 _eventsCollected: function(events) |
150 { | 150 { |
151 for (var i = 0; i < events.length; ++i) | 151 for (var i = 0; i < events.length; ++i) |
152 this._addEvent(events[i]); | 152 this._addEvent(events[i]); |
153 }, | 153 }, |
154 | 154 |
155 _tracingComplete: function() | 155 _tracingComplete: function() |
156 { | 156 { |
157 this._active = false; | 157 this._active = false; |
158 | |
159 /** | |
160 * @param {!WebInspector.TracingModel.Event} a | |
161 * @param {!WebInspector.TracingModel.Event} b | |
162 */ | |
163 function compareStartTime(a, b) | |
164 { | |
165 return a.startTime - b.startTime; | |
166 } | |
167 | |
168 this._inspectedTargetEvents.sort(compareStartTime); | |
169 if (!this._pendingStopCallback) | 158 if (!this._pendingStopCallback) |
170 return; | 159 return; |
171 this._pendingStopCallback(); | 160 this._pendingStopCallback(); |
172 this._pendingStopCallback = null; | 161 this._pendingStopCallback = null; |
173 }, | 162 }, |
174 | 163 |
175 reset: function() | 164 reset: function() |
176 { | 165 { |
177 this._processById = {}; | 166 this._processById = {}; |
178 this._minimumRecordTime = null; | 167 this._minimumRecordTime = null; |
179 this._maximumRecordTime = null; | 168 this._maximumRecordTime = null; |
180 this._sessionId = null; | 169 this._sessionId = null; |
181 this._inspectedTargetProcessId = null; | 170 this._devtoolsMetadataEvents = []; |
182 this._inspectedTargetEvents = []; | |
183 }, | 171 }, |
184 | 172 |
185 /** | 173 /** |
186 * @param {!WebInspector.TracingModel.EventPayload} payload | 174 * @param {!WebInspector.TracingModel.EventPayload} payload |
187 */ | 175 */ |
188 _addEvent: function(payload) | 176 _addEvent: function(payload) |
189 { | 177 { |
190 var process = this._processById[payload.pid]; | 178 var process = this._processById[payload.pid]; |
191 if (!process) { | 179 if (!process) { |
192 process = new WebInspector.TracingModel.Process(payload.pid); | 180 process = new WebInspector.TracingModel.Process(payload.pid); |
193 this._processById[payload.pid] = process; | 181 this._processById[payload.pid] = process; |
194 } | 182 } |
195 var thread = process.threadById(payload.tid); | 183 var thread = process.threadById(payload.tid); |
196 if (payload.ph === WebInspector.TracingModel.Phase.SnapshotObject) { | 184 if (payload.ph === WebInspector.TracingModel.Phase.SnapshotObject) { |
197 var event = new WebInspector.TracingModel.Event(payload, 0, thread); | 185 var event = thread.addEvent(payload); |
198 process.addObject(event); | 186 process.addObject(event); |
199 if (payload.pid === this._inspectedTargetProcessId) | |
200 this._inspectedTargetEvents.push(event); | |
201 return; | 187 return; |
202 } | 188 } |
203 if (payload.ph !== WebInspector.TracingModel.Phase.Metadata) { | 189 if (payload.ph !== WebInspector.TracingModel.Phase.Metadata) { |
204 var timestamp = payload.ts; | 190 var timestamp = payload.ts; |
205 // We do allow records for unrelated threads to arrive out-of-order, | 191 // We do allow records for unrelated threads to arrive out-of-order, |
206 // so there's a chance we're getting records from the past. | 192 // so there's a chance we're getting records from the past. |
207 if (timestamp && (!this._minimumRecordTime || timestamp < this._mini
mumRecordTime)) | 193 if (timestamp && (!this._minimumRecordTime || timestamp < this._mini
mumRecordTime)) |
208 this._minimumRecordTime = timestamp; | 194 this._minimumRecordTime = timestamp; |
209 if (!this._maximumRecordTime || timestamp > this._maximumRecordTime) | 195 if (!this._maximumRecordTime || timestamp > this._maximumRecordTime) |
210 this._maximumRecordTime = timestamp; | 196 this._maximumRecordTime = timestamp; |
211 if (payload.cat === WebInspector.TracingModel.DevToolsMetadataEventC
ategory) | |
212 this._processDevToolsMetadataEvent(payload); | |
213 var event = thread.addEvent(payload); | 197 var event = thread.addEvent(payload); |
214 if (event && payload.pid === this._inspectedTargetProcessId) | 198 if (event && event.name === WebInspector.TracingModel.DevToolsMetada
taEvent.TracingStartedInPage && |
215 this._inspectedTargetEvents.push(event); | 199 event.category === WebInspector.TracingModel.DevToolsMetadataEve
ntCategory && |
| 200 event.args["sessionId"] === this._sessionId) |
| 201 this._devtoolsMetadataEvents.push(event); |
216 return; | 202 return; |
217 } | 203 } |
218 switch (payload.name) { | 204 switch (payload.name) { |
219 case WebInspector.TracingModel.MetadataEvent.ProcessSortIndex: | 205 case WebInspector.TracingModel.MetadataEvent.ProcessSortIndex: |
220 process._setSortIndex(payload.args["sort_index"]); | 206 process._setSortIndex(payload.args["sort_index"]); |
221 break; | 207 break; |
222 case WebInspector.TracingModel.MetadataEvent.ProcessName: | 208 case WebInspector.TracingModel.MetadataEvent.ProcessName: |
223 process._setName(payload.args["name"]); | 209 process._setName(payload.args["name"]); |
224 break; | 210 break; |
225 case WebInspector.TracingModel.MetadataEvent.ThreadSortIndex: | 211 case WebInspector.TracingModel.MetadataEvent.ThreadSortIndex: |
226 thread._setSortIndex(payload.args["sort_index"]); | 212 thread._setSortIndex(payload.args["sort_index"]); |
227 break; | 213 break; |
228 case WebInspector.TracingModel.MetadataEvent.ThreadName: | 214 case WebInspector.TracingModel.MetadataEvent.ThreadName: |
229 thread._setName(payload.args["name"]); | 215 thread._setName(payload.args["name"]); |
230 break; | 216 break; |
231 } | 217 } |
232 }, | 218 }, |
233 | 219 |
234 /** | |
235 * @param {!WebInspector.TracingModel.EventPayload} payload | |
236 */ | |
237 _processDevToolsMetadataEvent: function(payload) | |
238 { | |
239 if (payload.args["sessionId"] !== this._sessionId || payload.name !== We
bInspector.TracingModel.DevToolsMetadataEvent.TracingStartedInPage) | |
240 return; | |
241 this._inspectedTargetProcessId = payload.pid; | |
242 }, | |
243 | |
244 /** | 220 /** |
245 * @return {?number} | 221 * @return {?number} |
246 */ | 222 */ |
247 minimumRecordTime: function() | 223 minimumRecordTime: function() |
248 { | 224 { |
249 return this._minimumRecordTime; | 225 return this._minimumRecordTime; |
250 }, | 226 }, |
251 | 227 |
252 /** | 228 /** |
253 * @return {?number} | 229 * @return {?number} |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 var duration = payload.ts - this.startTime; | 310 var duration = payload.ts - this.startTime; |
335 if (duration < 0) { | 311 if (duration < 0) { |
336 console.assert(false, "Event out of order: " + this.name); | 312 console.assert(false, "Event out of order: " + this.name); |
337 return; | 313 return; |
338 } | 314 } |
339 this._setDuration(duration); | 315 this._setDuration(duration); |
340 } | 316 } |
341 } | 317 } |
342 | 318 |
343 /** | 319 /** |
| 320 * @param {!WebInspector.TracingModel.Event} a |
| 321 * @param {!WebInspector.TracingModel.Event} b |
| 322 * @return {number} |
| 323 */ |
| 324 WebInspector.TracingModel.Event.compareStartTime = function (a, b) |
| 325 { |
| 326 return a.startTime - b.startTime; |
| 327 } |
| 328 |
| 329 /** |
344 * @constructor | 330 * @constructor |
345 */ | 331 */ |
346 WebInspector.TracingModel.NamedObject = function() | 332 WebInspector.TracingModel.NamedObject = function() |
347 { | 333 { |
348 } | 334 } |
349 | 335 |
350 WebInspector.TracingModel.NamedObject.prototype = | 336 WebInspector.TracingModel.NamedObject.prototype = |
351 { | 337 { |
352 /** | 338 /** |
353 * @param {string} name | 339 * @param {string} name |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 391 |
406 WebInspector.TracingModel.Process.prototype = { | 392 WebInspector.TracingModel.Process.prototype = { |
407 /** | 393 /** |
408 * @param {number} id | 394 * @param {number} id |
409 * @return {!WebInspector.TracingModel.Thread} | 395 * @return {!WebInspector.TracingModel.Thread} |
410 */ | 396 */ |
411 threadById: function(id) | 397 threadById: function(id) |
412 { | 398 { |
413 var thread = this._threads[id]; | 399 var thread = this._threads[id]; |
414 if (!thread) { | 400 if (!thread) { |
415 thread = new WebInspector.TracingModel.Thread(id); | 401 thread = new WebInspector.TracingModel.Thread(this, id); |
416 this._threads[id] = thread; | 402 this._threads[id] = thread; |
417 } | 403 } |
418 return thread; | 404 return thread; |
419 }, | 405 }, |
420 | 406 |
421 /** | 407 /** |
422 * @param {!WebInspector.TracingModel.Event} event | 408 * @param {!WebInspector.TracingModel.Event} event |
423 */ | 409 */ |
424 addObject: function(event) | 410 addObject: function(event) |
425 { | 411 { |
(...skipping 29 matching lines...) Expand all Loading... |
455 { | 441 { |
456 return WebInspector.TracingModel.NamedObject._sort(Object.values(this._t
hreads)); | 442 return WebInspector.TracingModel.NamedObject._sort(Object.values(this._t
hreads)); |
457 }, | 443 }, |
458 | 444 |
459 __proto__: WebInspector.TracingModel.NamedObject.prototype | 445 __proto__: WebInspector.TracingModel.NamedObject.prototype |
460 } | 446 } |
461 | 447 |
462 /** | 448 /** |
463 * @constructor | 449 * @constructor |
464 * @extends {WebInspector.TracingModel.NamedObject} | 450 * @extends {WebInspector.TracingModel.NamedObject} |
| 451 * @param {!WebInspector.TracingModel.Process} process |
465 * @param {number} id | 452 * @param {number} id |
466 */ | 453 */ |
467 WebInspector.TracingModel.Thread = function(id) | 454 WebInspector.TracingModel.Thread = function(process, id) |
468 { | 455 { |
469 WebInspector.TracingModel.NamedObject.call(this); | 456 WebInspector.TracingModel.NamedObject.call(this); |
| 457 this._process = process; |
470 this._setName("Thread " + id); | 458 this._setName("Thread " + id); |
471 this._events = []; | 459 this._events = []; |
472 this._stack = []; | 460 this._stack = []; |
473 this._maxStackDepth = 0; | 461 this._maxStackDepth = 0; |
474 } | 462 } |
475 | 463 |
476 WebInspector.TracingModel.Thread.prototype = { | 464 WebInspector.TracingModel.Thread.prototype = { |
477 /** | 465 /** |
478 * @param {!WebInspector.TracingModel.EventPayload} payload | 466 * @param {!WebInspector.TracingModel.EventPayload} payload |
479 * @return {?WebInspector.TracingModel.Event} event | 467 * @return {?WebInspector.TracingModel.Event} event |
(...skipping 20 matching lines...) Expand all Loading... |
500 if (this._maxStackDepth < this._stack.length) | 488 if (this._maxStackDepth < this._stack.length) |
501 this._maxStackDepth = this._stack.length; | 489 this._maxStackDepth = this._stack.length; |
502 } | 490 } |
503 if (this._events.length && this._events.peekLast().startTime > event.sta
rtTime) | 491 if (this._events.length && this._events.peekLast().startTime > event.sta
rtTime) |
504 console.assert(false, "Event is our of order: " + event.name); | 492 console.assert(false, "Event is our of order: " + event.name); |
505 this._events.push(event); | 493 this._events.push(event); |
506 return event; | 494 return event; |
507 }, | 495 }, |
508 | 496 |
509 /** | 497 /** |
| 498 * @return {!WebInspector.TracingModel.Process} |
| 499 */ |
| 500 process: function() |
| 501 { |
| 502 return this._process; |
| 503 }, |
| 504 |
| 505 /** |
510 * @return {!Array.<!WebInspector.TracingModel.Event>} | 506 * @return {!Array.<!WebInspector.TracingModel.Event>} |
511 */ | 507 */ |
512 events: function() | 508 events: function() |
513 { | 509 { |
514 return this._events; | 510 return this._events; |
515 }, | 511 }, |
516 | 512 |
517 /** | 513 /** |
518 * @return {number} | 514 * @return {number} |
519 */ | 515 */ |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 dataCollected: function(data) | 548 dataCollected: function(data) |
553 { | 549 { |
554 this._tracingModel._eventsCollected(data); | 550 this._tracingModel._eventsCollected(data); |
555 }, | 551 }, |
556 | 552 |
557 tracingComplete: function() | 553 tracingComplete: function() |
558 { | 554 { |
559 this._tracingModel._tracingComplete(); | 555 this._tracingModel._tracingComplete(); |
560 } | 556 } |
561 } | 557 } |
OLD | NEW |