| 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; |
| 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 _tracingStarted: function() |
| 87 { |
| 88 if (this._active) |
| 89 return; |
| 90 this._active = true; |
| 91 this.dispatchEventToListeners(WebInspector.TracingManager.Events.Tracing
Started); |
| 92 }, |
| 93 |
| 94 /** |
| 95 * @param {string} categoryFilter |
| 96 * @param {string} options |
| 97 * @param {function(?string)=} callback |
| 98 */ |
| 99 start: function(categoryFilter, options, callback) |
| 100 { |
| 101 if (this._active) |
| 102 return; |
| 103 WebInspector.profilingLock().acquire(); |
| 104 this._shouldReleaseLock = true; |
| 105 var bufferUsageReportingIntervalMs = 500; |
| 106 TracingAgent.start(categoryFilter, options, bufferUsageReportingInterval
Ms, callback); |
| 107 this._tracingStarted(); |
| 108 this._active = true; |
| 109 }, |
| 110 |
| 111 stop: function() |
| 112 { |
| 113 if (!this._active) |
| 114 return; |
| 115 TracingAgent.end(this._onStop.bind(this)); |
| 116 if (this._shouldReleaseLock) { |
| 117 this._shouldReleaseLock = false; |
| 118 WebInspector.profilingLock().release(); |
| 119 } |
| 120 }, |
| 121 |
| 122 _onStop: function() |
| 123 { |
| 124 if (!this._active) |
| 125 return; |
| 126 this.dispatchEventToListeners(WebInspector.TracingManager.Events.Tracing
Stopped); |
| 127 this._active = false; |
| 128 }, |
| 129 |
| 130 __proto__: WebInspector.Object.prototype |
| 131 } |
| 132 |
| 133 /** |
| 134 * @constructor |
| 135 */ |
| 136 WebInspector.TracingModel = function() |
| 137 { |
| 138 this.reset(); |
| 139 } |
| 40 | 140 |
| 41 /** | 141 /** |
| 42 * @enum {string} | 142 * @enum {string} |
| 43 */ | 143 */ |
| 44 WebInspector.TracingModel.Phase = { | 144 WebInspector.TracingModel.Phase = { |
| 45 Begin: "B", | 145 Begin: "B", |
| 46 End: "E", | 146 End: "E", |
| 47 Complete: "X", | 147 Complete: "X", |
| 48 Instant: "I", | 148 Instant: "I", |
| 49 AsyncBegin: "S", | 149 AsyncBegin: "S", |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 * @return {boolean} | 184 * @return {boolean} |
| 85 */ | 185 */ |
| 86 WebInspector.TracingModel.isAsyncPhase = function(phase) | 186 WebInspector.TracingModel.isAsyncPhase = function(phase) |
| 87 { | 187 { |
| 88 return phase === WebInspector.TracingModel.Phase.AsyncBegin || phase === Web
Inspector.TracingModel.Phase.AsyncEnd || | 188 return phase === WebInspector.TracingModel.Phase.AsyncBegin || phase === Web
Inspector.TracingModel.Phase.AsyncEnd || |
| 89 phase === WebInspector.TracingModel.Phase.AsyncStepInto || phase === Web
Inspector.TracingModel.Phase.AsyncStepPast; | 189 phase === WebInspector.TracingModel.Phase.AsyncStepInto || phase === Web
Inspector.TracingModel.Phase.AsyncStepPast; |
| 90 } | 190 } |
| 91 | 191 |
| 92 WebInspector.TracingModel.prototype = { | 192 WebInspector.TracingModel.prototype = { |
| 93 /** | 193 /** |
| 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>} | 194 * @return {!Array.<!WebInspector.TracingModel.Event>} |
| 116 */ | 195 */ |
| 117 devtoolsPageMetadataEvents: function() | 196 devtoolsPageMetadataEvents: function() |
| 118 { | 197 { |
| 119 return this._devtoolsPageMetadataEvents; | 198 return this._devtoolsPageMetadataEvents; |
| 120 }, | 199 }, |
| 121 | 200 |
| 122 /** | 201 /** |
| 123 * @return {!Array.<!WebInspector.TracingModel.Event>} | 202 * @return {!Array.<!WebInspector.TracingModel.Event>} |
| 124 */ | 203 */ |
| 125 devtoolsWorkerMetadataEvents: function() | 204 devtoolsWorkerMetadataEvents: function() |
| 126 { | 205 { |
| 127 return this._devtoolsWorkerMetadataEvents; | 206 return this._devtoolsWorkerMetadataEvents; |
| 128 }, | 207 }, |
| 129 | 208 |
| 130 /** | 209 /** |
| 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} | 210 * @return {?string} |
| 158 */ | 211 */ |
| 159 sessionId: function() | 212 sessionId: function() |
| 160 { | 213 { |
| 161 return this._sessionId; | 214 return this._sessionId; |
| 162 }, | 215 }, |
| 163 | 216 |
| 164 /** | 217 /** |
| 165 * @param {!Array.<!WebInspector.TracingModel.EventPayload>} events | 218 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events |
| 166 */ | 219 */ |
| 167 setEventsForTest: function(events) | 220 setEventsForTest: function(events) |
| 168 { | 221 { |
| 169 this._tracingStarted(); | 222 this.reset(); |
| 170 this._eventsCollected(events); | 223 this.addEvents(events); |
| 171 this._tracingComplete(); | 224 this.tracingComplete(); |
| 172 }, | 225 }, |
| 173 | 226 |
| 174 /** | 227 /** |
| 175 * @param {number} usage | 228 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events |
| 176 */ | 229 */ |
| 177 _bufferUsage: function(usage) | 230 addEvents: function(events) |
| 178 { | 231 { |
| 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) { | 232 for (var i = 0; i < events.length; ++i) { |
| 189 this._addEvent(events[i]); | 233 this._addEvent(events[i]); |
| 190 this._rawEvents.push(events[i]); | 234 this._rawEvents.push(events[i]); |
| 191 } | 235 } |
| 192 }, | 236 }, |
| 193 | 237 |
| 194 _tracingComplete: function() | 238 tracingComplete: function() |
| 195 { | 239 { |
| 196 this._processMetadataEvents(); | 240 this._processMetadataEvents(); |
| 197 this._active = false; | |
| 198 for (var process in this._processById) | 241 for (var process in this._processById) |
| 199 this._processById[process]._tracingComplete(this._maximumRecordTime)
; | 242 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 }, | 243 }, |
| 220 | 244 |
| 221 reset: function() | 245 reset: function() |
| 222 { | 246 { |
| 223 this._processById = {}; | 247 this._processById = {}; |
| 224 this._minimumRecordTime = 0; | 248 this._minimumRecordTime = 0; |
| 225 this._maximumRecordTime = 0; | 249 this._maximumRecordTime = 0; |
| 226 this._sessionId = null; | 250 this._sessionId = null; |
| 227 this._devtoolsPageMetadataEvents = []; | 251 this._devtoolsPageMetadataEvents = []; |
| 228 this._devtoolsWorkerMetadataEvents = []; | 252 this._devtoolsWorkerMetadataEvents = []; |
| 229 this._rawEvents = []; | 253 this._rawEvents = []; |
| 230 }, | 254 }, |
| 231 | 255 |
| 232 /** | 256 /** |
| 233 * @return {!Array.<!WebInspector.TracingModel.EventPayload>} | 257 * @return {!Array.<!WebInspector.TracingManager.EventPayload>} |
| 234 */ | 258 */ |
| 235 rawEvents: function() | 259 rawEvents: function() |
| 236 { | 260 { |
| 237 return this._rawEvents; | 261 return this._rawEvents; |
| 238 }, | 262 }, |
| 239 | 263 |
| 240 /** | 264 /** |
| 241 * @param {!WebInspector.TracingModel.EventPayload} payload | 265 * @param {!WebInspector.TracingManager.EventPayload} payload |
| 242 */ | 266 */ |
| 243 _addEvent: function(payload) | 267 _addEvent: function(payload) |
| 244 { | 268 { |
| 245 var process = this._processById[payload.pid]; | 269 var process = this._processById[payload.pid]; |
| 246 if (!process) { | 270 if (!process) { |
| 247 process = new WebInspector.TracingModel.Process(payload.pid); | 271 process = new WebInspector.TracingModel.Process(payload.pid); |
| 248 this._processById[payload.pid] = process; | 272 this._processById[payload.pid] = process; |
| 249 } | 273 } |
| 250 if (payload.ph !== WebInspector.TracingModel.Phase.Metadata) { | 274 if (payload.ph !== WebInspector.TracingModel.Phase.Metadata) { |
| 251 var timestamp = payload.ts / 1000; | 275 var timestamp = payload.ts / 1000; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 { | 348 { |
| 325 return this._maximumRecordTime; | 349 return this._maximumRecordTime; |
| 326 }, | 350 }, |
| 327 | 351 |
| 328 /** | 352 /** |
| 329 * @return {!Array.<!WebInspector.TracingModel.Process>} | 353 * @return {!Array.<!WebInspector.TracingModel.Process>} |
| 330 */ | 354 */ |
| 331 sortedProcesses: function() | 355 sortedProcesses: function() |
| 332 { | 356 { |
| 333 return WebInspector.TracingModel.NamedObject._sort(Object.values(this._p
rocessById)); | 357 return WebInspector.TracingModel.NamedObject._sort(Object.values(this._p
rocessById)); |
| 334 }, | 358 } |
| 335 | |
| 336 __proto__: WebInspector.Object.prototype | |
| 337 } | 359 } |
| 338 | 360 |
| 339 | 361 |
| 340 /** | 362 /** |
| 341 * @constructor | 363 * @constructor |
| 342 * @param {!WebInspector.TracingModel} tracingModel | 364 * @param {!WebInspector.TracingModel} tracingModel |
| 343 */ | 365 */ |
| 344 WebInspector.TracingModel.Loader = function(tracingModel) | 366 WebInspector.TracingModel.Loader = function(tracingModel) |
| 345 { | 367 { |
| 346 this._tracingModel = tracingModel; | 368 this._tracingModel = tracingModel; |
| 347 this._firstChunkReceived = false; | 369 this._firstChunkReceived = false; |
| 348 } | 370 } |
| 349 | 371 |
| 350 WebInspector.TracingModel.Loader.prototype = { | 372 WebInspector.TracingModel.Loader.prototype = { |
| 351 /** | 373 /** |
| 352 * @param {!Array.<!WebInspector.TracingModel.EventPayload>} events | 374 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events |
| 353 */ | 375 */ |
| 354 loadNextChunk: function(events) | 376 loadNextChunk: function(events) |
| 355 { | 377 { |
| 356 if (!this._firstChunkReceived) { | 378 if (!this._firstChunkReceived) { |
| 357 this._tracingModel._tracingStarted(); | 379 this._tracingModel.reset(); |
| 358 this._firstChunkReceived = true; | 380 this._firstChunkReceived = true; |
| 359 } | 381 } |
| 360 this._tracingModel._eventsCollected(events); | 382 this._tracingModel.addEvents(events); |
| 361 }, | 383 }, |
| 362 | 384 |
| 363 finish: function() | 385 finish: function() |
| 364 { | 386 { |
| 365 this._tracingModel._tracingComplete(); | 387 this._tracingModel.tracingComplete(); |
| 366 } | 388 } |
| 367 } | 389 } |
| 368 | 390 |
| 369 | 391 |
| 370 /** | 392 /** |
| 371 * @constructor | 393 * @constructor |
| 372 * @param {string} category | 394 * @param {string} category |
| 373 * @param {string} name | 395 * @param {string} name |
| 374 * @param {string} phase | 396 * @param {string} phase |
| 375 * @param {number} startTime | 397 * @param {number} startTime |
| (...skipping 19 matching lines...) Expand all Loading... |
| 395 /** @type {?string} */ | 417 /** @type {?string} */ |
| 396 this.imageURL = null; | 418 this.imageURL = null; |
| 397 /** @type {number} */ | 419 /** @type {number} */ |
| 398 this.backendNodeId = 0; | 420 this.backendNodeId = 0; |
| 399 | 421 |
| 400 /** @type {number} */ | 422 /** @type {number} */ |
| 401 this.selfTime = 0; | 423 this.selfTime = 0; |
| 402 } | 424 } |
| 403 | 425 |
| 404 /** | 426 /** |
| 405 * @param {!WebInspector.TracingModel.EventPayload} payload | 427 * @param {!WebInspector.TracingManager.EventPayload} payload |
| 406 * @param {?WebInspector.TracingModel.Thread} thread | 428 * @param {?WebInspector.TracingModel.Thread} thread |
| 407 * @return {!WebInspector.TracingModel.Event} | 429 * @return {!WebInspector.TracingModel.Event} |
| 408 */ | 430 */ |
| 409 WebInspector.TracingModel.Event.fromPayload = function(payload, thread) | 431 WebInspector.TracingModel.Event.fromPayload = function(payload, thread) |
| 410 { | 432 { |
| 411 var event = new WebInspector.TracingModel.Event(payload.cat, payload.name, p
ayload.ph, payload.ts / 1000, thread); | 433 var event = new WebInspector.TracingModel.Event(payload.cat, payload.name, p
ayload.ph, payload.ts / 1000, thread); |
| 412 if (payload.args) | 434 if (payload.args) |
| 413 event.addArgs(payload.args); | 435 event.addArgs(payload.args); |
| 414 else | 436 else |
| 415 console.error("Missing mandatory event argument 'args' at " + payload.ts
/ 1000); | 437 console.error("Missing mandatory event argument 'args' at " + payload.ts
/ 1000); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 441 { | 463 { |
| 442 // Shallow copy args to avoid modifying original payload which may be sa
ved to file. | 464 // Shallow copy args to avoid modifying original payload which may be sa
ved to file. |
| 443 for (var name in args) { | 465 for (var name in args) { |
| 444 if (name in this.args) | 466 if (name in this.args) |
| 445 console.error("Same argument name (" + name + ") is used for be
gin and end phases of " + this.name); | 467 console.error("Same argument name (" + name + ") is used for be
gin and end phases of " + this.name); |
| 446 this.args[name] = args[name]; | 468 this.args[name] = args[name]; |
| 447 } | 469 } |
| 448 }, | 470 }, |
| 449 | 471 |
| 450 /** | 472 /** |
| 451 * @param {!WebInspector.TracingModel.EventPayload} payload | 473 * @param {!WebInspector.TracingManager.EventPayload} payload |
| 452 */ | 474 */ |
| 453 _complete: function(payload) | 475 _complete: function(payload) |
| 454 { | 476 { |
| 455 if (payload.args) | 477 if (payload.args) |
| 456 this.addArgs(payload.args); | 478 this.addArgs(payload.args); |
| 457 else | 479 else |
| 458 console.error("Missing mandatory event argument 'args' at " + payloa
d.ts / 1000); | 480 console.error("Missing mandatory event argument 'args' at " + payloa
d.ts / 1000); |
| 459 this.setEndTime(payload.ts / 1000); | 481 this.setEndTime(payload.ts / 1000); |
| 460 } | 482 } |
| 461 } | 483 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 * @constructor | 559 * @constructor |
| 538 * @extends {WebInspector.TracingModel.NamedObject} | 560 * @extends {WebInspector.TracingModel.NamedObject} |
| 539 * @param {number} id | 561 * @param {number} id |
| 540 */ | 562 */ |
| 541 WebInspector.TracingModel.Process = function(id) | 563 WebInspector.TracingModel.Process = function(id) |
| 542 { | 564 { |
| 543 WebInspector.TracingModel.NamedObject.call(this); | 565 WebInspector.TracingModel.NamedObject.call(this); |
| 544 this._setName("Process " + id); | 566 this._setName("Process " + id); |
| 545 this._threads = {}; | 567 this._threads = {}; |
| 546 this._objects = {}; | 568 this._objects = {}; |
| 547 /** @type {!Array.<!WebInspector.TracingModel.EventPayload>} */ | 569 /** @type {!Array.<!WebInspector.TracingManager.EventPayload>} */ |
| 548 this._asyncEvents = []; | 570 this._asyncEvents = []; |
| 549 /** @type {!Object.<string, ?Array.<!WebInspector.TracingModel.Event>>} */ | 571 /** @type {!Object.<string, ?Array.<!WebInspector.TracingModel.Event>>} */ |
| 550 this._openAsyncEvents = []; | 572 this._openAsyncEvents = []; |
| 551 } | 573 } |
| 552 | 574 |
| 553 WebInspector.TracingModel.Process.prototype = { | 575 WebInspector.TracingModel.Process.prototype = { |
| 554 /** | 576 /** |
| 555 * @param {number} id | 577 * @param {number} id |
| 556 * @return {!WebInspector.TracingModel.Thread} | 578 * @return {!WebInspector.TracingModel.Thread} |
| 557 */ | 579 */ |
| 558 threadById: function(id) | 580 threadById: function(id) |
| 559 { | 581 { |
| 560 var thread = this._threads[id]; | 582 var thread = this._threads[id]; |
| 561 if (!thread) { | 583 if (!thread) { |
| 562 thread = new WebInspector.TracingModel.Thread(this, id); | 584 thread = new WebInspector.TracingModel.Thread(this, id); |
| 563 this._threads[id] = thread; | 585 this._threads[id] = thread; |
| 564 } | 586 } |
| 565 return thread; | 587 return thread; |
| 566 }, | 588 }, |
| 567 | 589 |
| 568 /** | 590 /** |
| 569 * @param {!WebInspector.TracingModel.EventPayload} payload | 591 * @param {!WebInspector.TracingManager.EventPayload} payload |
| 570 * @return {?WebInspector.TracingModel.Event} event | 592 * @return {?WebInspector.TracingModel.Event} event |
| 571 */ | 593 */ |
| 572 _addEvent: function(payload) | 594 _addEvent: function(payload) |
| 573 { | 595 { |
| 574 var phase = WebInspector.TracingModel.Phase; | 596 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. | 597 // 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 | 598 // 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. | 599 // other events, should we choose so. |
| 578 if (WebInspector.TracingModel.isAsyncPhase(payload.ph)) | 600 if (WebInspector.TracingModel.isAsyncPhase(payload.ph)) |
| 579 this._asyncEvents.push(payload); | 601 this._asyncEvents.push(payload); |
| 580 | 602 |
| 581 var event = this.threadById(payload.tid)._addEvent(payload); | 603 var event = this.threadById(payload.tid)._addEvent(payload); |
| 582 if (event && payload.ph === phase.SnapshotObject) | 604 if (event && payload.ph === phase.SnapshotObject) |
| 583 this.objectsByName(event.name).push(event); | 605 this.objectsByName(event.name).push(event); |
| 584 return event; | 606 return event; |
| 585 }, | 607 }, |
| 586 | 608 |
| 587 /** | 609 /** |
| 588 * @param {!number} lastEventTime | 610 * @param {!number} lastEventTime |
| 589 */ | 611 */ |
| 590 _tracingComplete: function(lastEventTime) | 612 _tracingComplete: function(lastEventTime) |
| 591 { | 613 { |
| 592 /** | 614 /** |
| 593 * @param {!WebInspector.TracingModel.EventPayload} a | 615 * @param {!WebInspector.TracingManager.EventPayload} a |
| 594 * @param {!WebInspector.TracingModel.EventPayload} b | 616 * @param {!WebInspector.TracingManager.EventPayload} b |
| 595 */ | 617 */ |
| 596 function comparePayloadTimestamp(a, b) | 618 function comparePayloadTimestamp(a, b) |
| 597 { | 619 { |
| 598 return a.ts - b.ts; | 620 return a.ts - b.ts; |
| 599 } | 621 } |
| 600 this._asyncEvents.sort(comparePayloadTimestamp).forEach(this._addAsyncEv
ent, this); | 622 this._asyncEvents.sort(comparePayloadTimestamp).forEach(this._addAsyncEv
ent, this); |
| 601 for (var key in this._openAsyncEvents) { | 623 for (var key in this._openAsyncEvents) { |
| 602 var steps = this._openAsyncEvents[key]; | 624 var steps = this._openAsyncEvents[key]; |
| 603 if (!steps) | 625 if (!steps) |
| 604 continue; | 626 continue; |
| 605 var startEvent = steps[0]; | 627 var startEvent = steps[0]; |
| 606 var syntheticEndEvent = new WebInspector.TracingModel.Event(startEve
nt.category, startEvent.name, WebInspector.TracingModel.Phase.AsyncEnd, lastEven
tTime, startEvent.thread); | 628 var syntheticEndEvent = new WebInspector.TracingModel.Event(startEve
nt.category, startEvent.name, WebInspector.TracingModel.Phase.AsyncEnd, lastEven
tTime, startEvent.thread); |
| 607 steps.push(syntheticEndEvent); | 629 steps.push(syntheticEndEvent); |
| 608 } | 630 } |
| 609 this._asyncEvents = []; | 631 this._asyncEvents = []; |
| 610 this._openAsyncEvents = []; | 632 this._openAsyncEvents = []; |
| 611 }, | 633 }, |
| 612 | 634 |
| 613 /** | 635 /** |
| 614 * @param {!WebInspector.TracingModel.EventPayload} payload | 636 * @param {!WebInspector.TracingManager.EventPayload} payload |
| 615 */ | 637 */ |
| 616 _addAsyncEvent: function(payload) | 638 _addAsyncEvent: function(payload) |
| 617 { | 639 { |
| 618 var phase = WebInspector.TracingModel.Phase; | 640 var phase = WebInspector.TracingModel.Phase; |
| 619 var timestamp = payload.ts / 1000; | 641 var timestamp = payload.ts / 1000; |
| 620 var key = payload.name + "." + payload.id; | 642 var key = payload.name + "." + payload.id; |
| 621 var steps = this._openAsyncEvents[key]; | 643 var steps = this._openAsyncEvents[key]; |
| 622 | 644 |
| 623 var thread = this.threadById(payload.tid); | 645 var thread = this.threadById(payload.tid); |
| 624 if (payload.ph === phase.AsyncBegin) { | 646 if (payload.ph === phase.AsyncBegin) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 /** | 728 /** |
| 707 * @return {?WebInspector.Target} | 729 * @return {?WebInspector.Target} |
| 708 */ | 730 */ |
| 709 target: function() | 731 target: function() |
| 710 { | 732 { |
| 711 //FIXME: correctly specify target | 733 //FIXME: correctly specify target |
| 712 return WebInspector.targetManager.targets()[0]; | 734 return WebInspector.targetManager.targets()[0]; |
| 713 }, | 735 }, |
| 714 | 736 |
| 715 /** | 737 /** |
| 716 * @param {!WebInspector.TracingModel.EventPayload} payload | 738 * @param {!WebInspector.TracingManager.EventPayload} payload |
| 717 * @return {?WebInspector.TracingModel.Event} event | 739 * @return {?WebInspector.TracingModel.Event} event |
| 718 */ | 740 */ |
| 719 _addEvent: function(payload) | 741 _addEvent: function(payload) |
| 720 { | 742 { |
| 721 var timestamp = payload.ts / 1000; | 743 var timestamp = payload.ts / 1000; |
| 722 if (payload.ph === WebInspector.TracingModel.Phase.End) { | 744 if (payload.ph === WebInspector.TracingModel.Phase.End) { |
| 723 // Quietly ignore unbalanced close events, they're legit (we could h
ave missed start one). | 745 // Quietly ignore unbalanced close events, they're legit (we could h
ave missed start one). |
| 724 if (!this._stack.length) | 746 if (!this._stack.length) |
| 725 return null; | 747 return null; |
| 726 var top = this._stack.pop(); | 748 var top = this._stack.pop(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 return this._asyncEvents; | 793 return this._asyncEvents; |
| 772 }, | 794 }, |
| 773 | 795 |
| 774 __proto__: WebInspector.TracingModel.NamedObject.prototype | 796 __proto__: WebInspector.TracingModel.NamedObject.prototype |
| 775 } | 797 } |
| 776 | 798 |
| 777 | 799 |
| 778 /** | 800 /** |
| 779 * @constructor | 801 * @constructor |
| 780 * @implements {TracingAgent.Dispatcher} | 802 * @implements {TracingAgent.Dispatcher} |
| 781 * @param {!WebInspector.TracingModel} tracingModel | 803 * @param {!WebInspector.TracingManager} tracingManager |
| 782 */ | 804 */ |
| 783 WebInspector.TracingDispatcher = function(tracingModel) | 805 WebInspector.TracingDispatcher = function(tracingManager) |
| 784 { | 806 { |
| 785 this._tracingModel = tracingModel; | 807 this._tracingManager = tracingManager; |
| 786 } | 808 } |
| 787 | 809 |
| 788 WebInspector.TracingDispatcher.prototype = { | 810 WebInspector.TracingDispatcher.prototype = { |
| 789 /** | 811 /** |
| 790 * @param {number} usage | 812 * @param {number} usage |
| 791 */ | 813 */ |
| 792 bufferUsage: function(usage) | 814 bufferUsage: function(usage) |
| 793 { | 815 { |
| 794 this._tracingModel._bufferUsage(usage); | 816 this._tracingManager._bufferUsage(usage); |
| 795 }, | 817 }, |
| 796 | 818 |
| 797 /** | 819 /** |
| 798 * @param {!Array.<!WebInspector.TracingModel.EventPayload>} data | 820 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} data |
| 799 */ | 821 */ |
| 800 dataCollected: function(data) | 822 dataCollected: function(data) |
| 801 { | 823 { |
| 802 this._tracingModel._eventsCollected(data); | 824 this._tracingManager._eventsCollected(data); |
| 803 }, | 825 }, |
| 804 | 826 |
| 805 tracingComplete: function() | 827 tracingComplete: function() |
| 806 { | 828 { |
| 807 this._tracingModel._tracingComplete(); | 829 this._tracingManager._tracingComplete(); |
| 808 }, | 830 }, |
| 809 | 831 |
| 810 started: function() | 832 started: function() |
| 811 { | 833 { |
| 812 this._tracingModel._tracingStarted(); | 834 this._tracingManager._tracingStarted(); |
| 813 } | 835 } |
| 814 } | 836 } |
| OLD | NEW |