| 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 * @param {!WebInspector.BackingStorage} backingStorage | 9 * @param {!WebInspector.BackingStorage} backingStorage |
| 10 */ | 10 */ |
| 11 WebInspector.TracingModel = function(backingStorage) | 11 WebInspector.TracingModel = function(backingStorage) |
| 12 { | 12 { |
| 13 this._backingStorage = backingStorage; | 13 this._backingStorage = backingStorage; |
| 14 // Avoid extra reset of the storage as it's expensive. | 14 // Avoid extra reset of the storage as it's expensive. |
| 15 this._firstWritePending = true; | 15 this._firstWritePending = true; |
| 16 this.reset(); | 16 this.reset(); |
| 17 } | 17 }; |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * @enum {string} | 20 * @enum {string} |
| 21 */ | 21 */ |
| 22 WebInspector.TracingModel.Phase = { | 22 WebInspector.TracingModel.Phase = { |
| 23 Begin: "B", | 23 Begin: "B", |
| 24 End: "E", | 24 End: "E", |
| 25 Complete: "X", | 25 Complete: "X", |
| 26 Instant: "I", | 26 Instant: "I", |
| 27 AsyncBegin: "S", | 27 AsyncBegin: "S", |
| (...skipping 12 matching lines...) Expand all Loading... |
| 40 CreateObject: "N", | 40 CreateObject: "N", |
| 41 SnapshotObject: "O", | 41 SnapshotObject: "O", |
| 42 DeleteObject: "D" | 42 DeleteObject: "D" |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 WebInspector.TracingModel.MetadataEvent = { | 45 WebInspector.TracingModel.MetadataEvent = { |
| 46 ProcessSortIndex: "process_sort_index", | 46 ProcessSortIndex: "process_sort_index", |
| 47 ProcessName: "process_name", | 47 ProcessName: "process_name", |
| 48 ThreadSortIndex: "thread_sort_index", | 48 ThreadSortIndex: "thread_sort_index", |
| 49 ThreadName: "thread_name" | 49 ThreadName: "thread_name" |
| 50 } | 50 }; |
| 51 | 51 |
| 52 WebInspector.TracingModel.TopLevelEventCategory = "toplevel"; | 52 WebInspector.TracingModel.TopLevelEventCategory = "toplevel"; |
| 53 WebInspector.TracingModel.DevToolsMetadataEventCategory = "disabled-by-default-d
evtools.timeline"; | 53 WebInspector.TracingModel.DevToolsMetadataEventCategory = "disabled-by-default-d
evtools.timeline"; |
| 54 WebInspector.TracingModel.DevToolsTimelineEventCategory = "disabled-by-default-d
evtools.timeline"; | 54 WebInspector.TracingModel.DevToolsTimelineEventCategory = "disabled-by-default-d
evtools.timeline"; |
| 55 | 55 |
| 56 WebInspector.TracingModel.FrameLifecycleEventCategory = "cc,devtools"; | 56 WebInspector.TracingModel.FrameLifecycleEventCategory = "cc,devtools"; |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * @param {string} phase | 59 * @param {string} phase |
| 60 * @return {boolean} | 60 * @return {boolean} |
| 61 */ | 61 */ |
| 62 WebInspector.TracingModel.isNestableAsyncPhase = function(phase) | 62 WebInspector.TracingModel.isNestableAsyncPhase = function(phase) |
| 63 { | 63 { |
| 64 return phase === "b" || phase === "e" || phase === "n"; | 64 return phase === "b" || phase === "e" || phase === "n"; |
| 65 } | 65 }; |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * @param {string} phase | 68 * @param {string} phase |
| 69 * @return {boolean} | 69 * @return {boolean} |
| 70 */ | 70 */ |
| 71 WebInspector.TracingModel.isAsyncBeginPhase = function(phase) | 71 WebInspector.TracingModel.isAsyncBeginPhase = function(phase) |
| 72 { | 72 { |
| 73 return phase === "S" || phase === "b"; | 73 return phase === "S" || phase === "b"; |
| 74 } | 74 }; |
| 75 | 75 |
| 76 /** | 76 /** |
| 77 * @param {string} phase | 77 * @param {string} phase |
| 78 * @return {boolean} | 78 * @return {boolean} |
| 79 */ | 79 */ |
| 80 WebInspector.TracingModel.isAsyncPhase = function(phase) | 80 WebInspector.TracingModel.isAsyncPhase = function(phase) |
| 81 { | 81 { |
| 82 return WebInspector.TracingModel.isNestableAsyncPhase(phase) || phase === "S
" || phase === "T" || phase === "F" || phase === "p"; | 82 return WebInspector.TracingModel.isNestableAsyncPhase(phase) || phase === "S
" || phase === "T" || phase === "F" || phase === "p"; |
| 83 } | 83 }; |
| 84 | 84 |
| 85 /** | 85 /** |
| 86 * @param {string} phase | 86 * @param {string} phase |
| 87 * @return {boolean} | 87 * @return {boolean} |
| 88 */ | 88 */ |
| 89 WebInspector.TracingModel.isFlowPhase = function(phase) | 89 WebInspector.TracingModel.isFlowPhase = function(phase) |
| 90 { | 90 { |
| 91 return phase === "s" || phase === "t" || phase === "f"; | 91 return phase === "s" || phase === "t" || phase === "f"; |
| 92 } | 92 }; |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * @param {!WebInspector.TracingModel.Event} event | 95 * @param {!WebInspector.TracingModel.Event} event |
| 96 * @return {boolean} | 96 * @return {boolean} |
| 97 */ | 97 */ |
| 98 WebInspector.TracingModel.isTopLevelEvent = function(event) | 98 WebInspector.TracingModel.isTopLevelEvent = function(event) |
| 99 { | 99 { |
| 100 return event.hasCategory(WebInspector.TracingModel.TopLevelEventCategory) || | 100 return event.hasCategory(WebInspector.TracingModel.TopLevelEventCategory) || |
| 101 event.hasCategory(WebInspector.TracingModel.DevToolsMetadataEventCategor
y) && event.name === "Program"; // Older timelines may have this instead of topl
evel. | 101 event.hasCategory(WebInspector.TracingModel.DevToolsMetadataEventCategor
y) && event.name === "Program"; // Older timelines may have this instead of topl
evel. |
| 102 } | 102 }; |
| 103 | 103 |
| 104 /** | 104 /** |
| 105 * @param {!WebInspector.TracingManager.EventPayload} payload | 105 * @param {!WebInspector.TracingManager.EventPayload} payload |
| 106 * @return {string|undefined} | 106 * @return {string|undefined} |
| 107 */ | 107 */ |
| 108 WebInspector.TracingModel._extractId = function(payload) | 108 WebInspector.TracingModel._extractId = function(payload) |
| 109 { | 109 { |
| 110 var scope = payload.scope || ""; | 110 var scope = payload.scope || ""; |
| 111 if (typeof payload.id2 === "undefined") | 111 if (typeof payload.id2 === "undefined") |
| 112 return scope && payload.id ? `${scope}@${payload.id}` : payload.id; | 112 return scope && payload.id ? `${scope}@${payload.id}` : payload.id; |
| 113 var id2 = payload.id2; | 113 var id2 = payload.id2; |
| 114 if (typeof id2 === "object" && ("global" in id2) !== ("local" in id2)) | 114 if (typeof id2 === "object" && ("global" in id2) !== ("local" in id2)) |
| 115 return typeof id2["global"] !== "undefined" ? `:${scope}:${id2["global"]
}` : `:${scope}:${payload.pid}:${id2["local"]}`; | 115 return typeof id2["global"] !== "undefined" ? `:${scope}:${id2["global"]
}` : `:${scope}:${payload.pid}:${id2["local"]}`; |
| 116 console.error(`Unexpected id2 field at ${payload.ts / 1000}, one and only on
e of 'local' and 'global' should be present.`); | 116 console.error(`Unexpected id2 field at ${payload.ts / 1000}, one and only on
e of 'local' and 'global' should be present.`); |
| 117 } | 117 }; |
| 118 | 118 |
| 119 /** | 119 /** |
| 120 * @param {!WebInspector.TracingModel} tracingModel | 120 * @param {!WebInspector.TracingModel} tracingModel |
| 121 * @return {?WebInspector.TracingModel.Thread} | 121 * @return {?WebInspector.TracingModel.Thread} |
| 122 * | 122 * |
| 123 * TODO: Move this to a better place. This is here just for convenience o | 123 * TODO: Move this to a better place. This is here just for convenience o |
| 124 * re-use between modules. This really belongs to a higher level, since it | 124 * re-use between modules. This really belongs to a higher level, since it |
| 125 * is specific to chrome's usage of tracing. | 125 * is specific to chrome's usage of tracing. |
| 126 */ | 126 */ |
| 127 WebInspector.TracingModel.browserMainThread = function(tracingModel) | 127 WebInspector.TracingModel.browserMainThread = function(tracingModel) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 139 } | 139 } |
| 140 if (crRendererMainThreads.length === 1) | 140 if (crRendererMainThreads.length === 1) |
| 141 return crRendererMainThreads[0]; | 141 return crRendererMainThreads[0]; |
| 142 if (browserProcesses.length === 1) | 142 if (browserProcesses.length === 1) |
| 143 return browserProcesses[0].threadByName("CrBrowserMain"); | 143 return browserProcesses[0].threadByName("CrBrowserMain"); |
| 144 var tracingStartedInBrowser = tracingModel.devToolsMetadataEvents().filter(e
=> e.name === "TracingStartedInBrowser"); | 144 var tracingStartedInBrowser = tracingModel.devToolsMetadataEvents().filter(e
=> e.name === "TracingStartedInBrowser"); |
| 145 if (tracingStartedInBrowser.length === 1) | 145 if (tracingStartedInBrowser.length === 1) |
| 146 return tracingStartedInBrowser[0].thread; | 146 return tracingStartedInBrowser[0].thread; |
| 147 WebInspector.console.error("Failed to find browser main thread in trace, som
e timeline features may be unavailable"); | 147 WebInspector.console.error("Failed to find browser main thread in trace, som
e timeline features may be unavailable"); |
| 148 return null; | 148 return null; |
| 149 } | 149 }; |
| 150 | 150 |
| 151 /** | 151 /** |
| 152 * @interface | 152 * @interface |
| 153 */ | 153 */ |
| 154 WebInspector.BackingStorage = function() | 154 WebInspector.BackingStorage = function() |
| 155 { | 155 { |
| 156 } | 156 }; |
| 157 | 157 |
| 158 WebInspector.BackingStorage.prototype = { | 158 WebInspector.BackingStorage.prototype = { |
| 159 /** | 159 /** |
| 160 * @param {string} string | 160 * @param {string} string |
| 161 */ | 161 */ |
| 162 appendString: function(string) { }, | 162 appendString: function(string) { }, |
| 163 | 163 |
| 164 /** | 164 /** |
| 165 * @param {string} string | 165 * @param {string} string |
| 166 * @return {function():!Promise.<?string>} | 166 * @return {function():!Promise.<?string>} |
| 167 */ | 167 */ |
| 168 appendAccessibleString: function(string) { }, | 168 appendAccessibleString: function(string) { }, |
| 169 | 169 |
| 170 finishWriting: function() { }, | 170 finishWriting: function() { }, |
| 171 | 171 |
| 172 reset: function() { }, | 172 reset: function() { }, |
| 173 } | 173 }; |
| 174 | 174 |
| 175 | 175 |
| 176 WebInspector.TracingModel.prototype = { | 176 WebInspector.TracingModel.prototype = { |
| 177 /** | 177 /** |
| 178 * @return {!Array.<!WebInspector.TracingModel.Event>} | 178 * @return {!Array.<!WebInspector.TracingModel.Event>} |
| 179 */ | 179 */ |
| 180 devToolsMetadataEvents: function() | 180 devToolsMetadataEvents: function() |
| 181 { | 181 { |
| 182 return this._devToolsMetadataEvents; | 182 return this._devToolsMetadataEvents; |
| 183 }, | 183 }, |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 */ | 483 */ |
| 484 _parsedCategoriesForString: function(str) | 484 _parsedCategoriesForString: function(str) |
| 485 { | 485 { |
| 486 var parsedCategories = this._parsedCategories.get(str); | 486 var parsedCategories = this._parsedCategories.get(str); |
| 487 if (!parsedCategories) { | 487 if (!parsedCategories) { |
| 488 parsedCategories = new Set(str.split(",")); | 488 parsedCategories = new Set(str.split(",")); |
| 489 this._parsedCategories.set(str, parsedCategories); | 489 this._parsedCategories.set(str, parsedCategories); |
| 490 } | 490 } |
| 491 return parsedCategories; | 491 return parsedCategories; |
| 492 } | 492 } |
| 493 } | 493 }; |
| 494 | 494 |
| 495 /** | 495 /** |
| 496 * @constructor | 496 * @constructor |
| 497 * @param {string} categories | 497 * @param {string} categories |
| 498 * @param {string} name | 498 * @param {string} name |
| 499 * @param {!WebInspector.TracingModel.Phase} phase | 499 * @param {!WebInspector.TracingModel.Phase} phase |
| 500 * @param {number} startTime | 500 * @param {number} startTime |
| 501 * @param {!WebInspector.TracingModel.Thread} thread | 501 * @param {!WebInspector.TracingModel.Thread} thread |
| 502 */ | 502 */ |
| 503 WebInspector.TracingModel.Event = function(categories, name, phase, startTime, t
hread) | 503 WebInspector.TracingModel.Event = function(categories, name, phase, startTime, t
hread) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 525 this.stackTrace = null; | 525 this.stackTrace = null; |
| 526 /** @type {?Element} */ | 526 /** @type {?Element} */ |
| 527 this.previewElement = null; | 527 this.previewElement = null; |
| 528 /** @type {?string} */ | 528 /** @type {?string} */ |
| 529 this.url = null; | 529 this.url = null; |
| 530 /** @type {number} */ | 530 /** @type {number} */ |
| 531 this.backendNodeId = 0; | 531 this.backendNodeId = 0; |
| 532 | 532 |
| 533 /** @type {number} */ | 533 /** @type {number} */ |
| 534 this.selfTime = 0; | 534 this.selfTime = 0; |
| 535 } | 535 }; |
| 536 | 536 |
| 537 /** | 537 /** |
| 538 * @param {!WebInspector.TracingManager.EventPayload} payload | 538 * @param {!WebInspector.TracingManager.EventPayload} payload |
| 539 * @param {!WebInspector.TracingModel.Thread} thread | 539 * @param {!WebInspector.TracingModel.Thread} thread |
| 540 * @return {!WebInspector.TracingModel.Event} | 540 * @return {!WebInspector.TracingModel.Event} |
| 541 */ | 541 */ |
| 542 WebInspector.TracingModel.Event.fromPayload = function(payload, thread) | 542 WebInspector.TracingModel.Event.fromPayload = function(payload, thread) |
| 543 { | 543 { |
| 544 var event = new WebInspector.TracingModel.Event(payload.cat, payload.name, /
** @type {!WebInspector.TracingModel.Phase} */ (payload.ph), payload.ts / 1000,
thread); | 544 var event = new WebInspector.TracingModel.Event(payload.cat, payload.name, /
** @type {!WebInspector.TracingModel.Phase} */ (payload.ph), payload.ts / 1000,
thread); |
| 545 if (payload.args) | 545 if (payload.args) |
| 546 event.addArgs(payload.args); | 546 event.addArgs(payload.args); |
| 547 else | 547 else |
| 548 console.error("Missing mandatory event argument 'args' at " + payload.ts
/ 1000); | 548 console.error("Missing mandatory event argument 'args' at " + payload.ts
/ 1000); |
| 549 if (typeof payload.dur === "number") | 549 if (typeof payload.dur === "number") |
| 550 event.setEndTime((payload.ts + payload.dur) / 1000); | 550 event.setEndTime((payload.ts + payload.dur) / 1000); |
| 551 var id = WebInspector.TracingModel._extractId(payload); | 551 var id = WebInspector.TracingModel._extractId(payload); |
| 552 if (typeof id !== "undefined") | 552 if (typeof id !== "undefined") |
| 553 event.id = id; | 553 event.id = id; |
| 554 if (payload.bind_id) | 554 if (payload.bind_id) |
| 555 event.bind_id = payload.bind_id; | 555 event.bind_id = payload.bind_id; |
| 556 | 556 |
| 557 return event; | 557 return event; |
| 558 } | 558 }; |
| 559 | 559 |
| 560 WebInspector.TracingModel.Event.prototype = { | 560 WebInspector.TracingModel.Event.prototype = { |
| 561 /** | 561 /** |
| 562 * @param {string} categoryName | 562 * @param {string} categoryName |
| 563 * @return {boolean} | 563 * @return {boolean} |
| 564 */ | 564 */ |
| 565 hasCategory: function(categoryName) | 565 hasCategory: function(categoryName) |
| 566 { | 566 { |
| 567 return this._parsedCategories.has(categoryName); | 567 return this._parsedCategories.has(categoryName); |
| 568 }, | 568 }, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 console.error("Missing mandatory event argument 'args' at " + endEve
nt.startTime); | 604 console.error("Missing mandatory event argument 'args' at " + endEve
nt.startTime); |
| 605 this.setEndTime(endEvent.startTime); | 605 this.setEndTime(endEvent.startTime); |
| 606 }, | 606 }, |
| 607 | 607 |
| 608 /** | 608 /** |
| 609 * @param {?function():!Promise.<?string>} backingStorage | 609 * @param {?function():!Promise.<?string>} backingStorage |
| 610 */ | 610 */ |
| 611 _setBackingStorage: function(backingStorage) | 611 _setBackingStorage: function(backingStorage) |
| 612 { | 612 { |
| 613 } | 613 } |
| 614 } | 614 }; |
| 615 | 615 |
| 616 /** | 616 /** |
| 617 * @param {!WebInspector.TracingModel.Event} a | 617 * @param {!WebInspector.TracingModel.Event} a |
| 618 * @param {!WebInspector.TracingModel.Event} b | 618 * @param {!WebInspector.TracingModel.Event} b |
| 619 * @return {number} | 619 * @return {number} |
| 620 */ | 620 */ |
| 621 WebInspector.TracingModel.Event.compareStartTime = function(a, b) | 621 WebInspector.TracingModel.Event.compareStartTime = function(a, b) |
| 622 { | 622 { |
| 623 return a.startTime - b.startTime; | 623 return a.startTime - b.startTime; |
| 624 } | 624 }; |
| 625 | 625 |
| 626 /** | 626 /** |
| 627 * @param {!WebInspector.TracingModel.Event} a | 627 * @param {!WebInspector.TracingModel.Event} a |
| 628 * @param {!WebInspector.TracingModel.Event} b | 628 * @param {!WebInspector.TracingModel.Event} b |
| 629 * @return {number} | 629 * @return {number} |
| 630 */ | 630 */ |
| 631 WebInspector.TracingModel.Event.compareStartAndEndTime = function(a, b) | 631 WebInspector.TracingModel.Event.compareStartAndEndTime = function(a, b) |
| 632 { | 632 { |
| 633 return a.startTime - b.startTime || (b.endTime !== undefined && a.endTime !=
= undefined && b.endTime - a.endTime) || 0; | 633 return a.startTime - b.startTime || (b.endTime !== undefined && a.endTime !=
= undefined && b.endTime - a.endTime) || 0; |
| 634 } | 634 }; |
| 635 | 635 |
| 636 /** | 636 /** |
| 637 * @param {!WebInspector.TracingModel.Event} a | 637 * @param {!WebInspector.TracingModel.Event} a |
| 638 * @param {!WebInspector.TracingModel.Event} b | 638 * @param {!WebInspector.TracingModel.Event} b |
| 639 * @return {number} | 639 * @return {number} |
| 640 */ | 640 */ |
| 641 WebInspector.TracingModel.Event.orderedCompareStartTime = function(a, b) | 641 WebInspector.TracingModel.Event.orderedCompareStartTime = function(a, b) |
| 642 { | 642 { |
| 643 // Array.mergeOrdered coalesces objects if comparator returns 0. | 643 // Array.mergeOrdered coalesces objects if comparator returns 0. |
| 644 // To change this behavior this comparator return -1 in the case events | 644 // To change this behavior this comparator return -1 in the case events |
| 645 // startTime's are equal, so both events got placed into the result array. | 645 // startTime's are equal, so both events got placed into the result array. |
| 646 return a.startTime - b.startTime || a.ordinal - b.ordinal || -1; | 646 return a.startTime - b.startTime || a.ordinal - b.ordinal || -1; |
| 647 } | 647 }; |
| 648 | 648 |
| 649 /** | 649 /** |
| 650 * @constructor | 650 * @constructor |
| 651 * @extends {WebInspector.TracingModel.Event} | 651 * @extends {WebInspector.TracingModel.Event} |
| 652 * @param {string} category | 652 * @param {string} category |
| 653 * @param {string} name | 653 * @param {string} name |
| 654 * @param {number} startTime | 654 * @param {number} startTime |
| 655 * @param {!WebInspector.TracingModel.Thread} thread | 655 * @param {!WebInspector.TracingModel.Thread} thread |
| 656 */ | 656 */ |
| 657 WebInspector.TracingModel.ObjectSnapshot = function(category, name, startTime, t
hread) | 657 WebInspector.TracingModel.ObjectSnapshot = function(category, name, startTime, t
hread) |
| 658 { | 658 { |
| 659 WebInspector.TracingModel.Event.call(this, category, name, WebInspector.Trac
ingModel.Phase.SnapshotObject, startTime, thread); | 659 WebInspector.TracingModel.Event.call(this, category, name, WebInspector.Trac
ingModel.Phase.SnapshotObject, startTime, thread); |
| 660 } | 660 }; |
| 661 | 661 |
| 662 /** | 662 /** |
| 663 * @param {!WebInspector.TracingManager.EventPayload} payload | 663 * @param {!WebInspector.TracingManager.EventPayload} payload |
| 664 * @param {!WebInspector.TracingModel.Thread} thread | 664 * @param {!WebInspector.TracingModel.Thread} thread |
| 665 * @return {!WebInspector.TracingModel.ObjectSnapshot} | 665 * @return {!WebInspector.TracingModel.ObjectSnapshot} |
| 666 */ | 666 */ |
| 667 WebInspector.TracingModel.ObjectSnapshot.fromPayload = function(payload, thread) | 667 WebInspector.TracingModel.ObjectSnapshot.fromPayload = function(payload, thread) |
| 668 { | 668 { |
| 669 var snapshot = new WebInspector.TracingModel.ObjectSnapshot(payload.cat, pay
load.name, payload.ts / 1000, thread); | 669 var snapshot = new WebInspector.TracingModel.ObjectSnapshot(payload.cat, pay
load.name, payload.ts / 1000, thread); |
| 670 var id = WebInspector.TracingModel._extractId(payload); | 670 var id = WebInspector.TracingModel._extractId(payload); |
| 671 if (typeof id !== "undefined") | 671 if (typeof id !== "undefined") |
| 672 snapshot.id = id; | 672 snapshot.id = id; |
| 673 if (!payload.args || !payload.args["snapshot"]) { | 673 if (!payload.args || !payload.args["snapshot"]) { |
| 674 console.error("Missing mandatory 'snapshot' argument at " + payload.ts /
1000); | 674 console.error("Missing mandatory 'snapshot' argument at " + payload.ts /
1000); |
| 675 return snapshot; | 675 return snapshot; |
| 676 } | 676 } |
| 677 if (payload.args) | 677 if (payload.args) |
| 678 snapshot.addArgs(payload.args); | 678 snapshot.addArgs(payload.args); |
| 679 return snapshot; | 679 return snapshot; |
| 680 } | 680 }; |
| 681 | 681 |
| 682 WebInspector.TracingModel.ObjectSnapshot.prototype = { | 682 WebInspector.TracingModel.ObjectSnapshot.prototype = { |
| 683 /** | 683 /** |
| 684 * @param {function(?)} callback | 684 * @param {function(?)} callback |
| 685 */ | 685 */ |
| 686 requestObject: function(callback) | 686 requestObject: function(callback) |
| 687 { | 687 { |
| 688 var snapshot = this.args["snapshot"]; | 688 var snapshot = this.args["snapshot"]; |
| 689 if (snapshot) { | 689 if (snapshot) { |
| 690 callback(snapshot); | 690 callback(snapshot); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 */ | 726 */ |
| 727 _setBackingStorage: function(backingStorage) | 727 _setBackingStorage: function(backingStorage) |
| 728 { | 728 { |
| 729 if (!backingStorage) | 729 if (!backingStorage) |
| 730 return; | 730 return; |
| 731 this._backingStorage = backingStorage; | 731 this._backingStorage = backingStorage; |
| 732 this.args = {}; | 732 this.args = {}; |
| 733 }, | 733 }, |
| 734 | 734 |
| 735 __proto__: WebInspector.TracingModel.Event.prototype | 735 __proto__: WebInspector.TracingModel.Event.prototype |
| 736 } | 736 }; |
| 737 | 737 |
| 738 /** | 738 /** |
| 739 * @constructor | 739 * @constructor |
| 740 * @param {!WebInspector.TracingModel.Event} startEvent | 740 * @param {!WebInspector.TracingModel.Event} startEvent |
| 741 * @extends {WebInspector.TracingModel.Event} | 741 * @extends {WebInspector.TracingModel.Event} |
| 742 */ | 742 */ |
| 743 WebInspector.TracingModel.AsyncEvent = function(startEvent) | 743 WebInspector.TracingModel.AsyncEvent = function(startEvent) |
| 744 { | 744 { |
| 745 WebInspector.TracingModel.Event.call(this, startEvent.categoriesString, star
tEvent.name, startEvent.phase, startEvent.startTime, startEvent.thread) | 745 WebInspector.TracingModel.Event.call(this, startEvent.categoriesString, star
tEvent.name, startEvent.phase, startEvent.startTime, startEvent.thread); |
| 746 this.addArgs(startEvent.args); | 746 this.addArgs(startEvent.args); |
| 747 this.steps = [startEvent]; | 747 this.steps = [startEvent]; |
| 748 } | 748 }; |
| 749 | 749 |
| 750 WebInspector.TracingModel.AsyncEvent.prototype = { | 750 WebInspector.TracingModel.AsyncEvent.prototype = { |
| 751 /** | 751 /** |
| 752 * @param {!WebInspector.TracingModel.Event} event | 752 * @param {!WebInspector.TracingModel.Event} event |
| 753 */ | 753 */ |
| 754 _addStep: function(event) | 754 _addStep: function(event) |
| 755 { | 755 { |
| 756 this.steps.push(event); | 756 this.steps.push(event); |
| 757 if (event.phase === WebInspector.TracingModel.Phase.AsyncEnd || event.ph
ase === WebInspector.TracingModel.Phase.NestableAsyncEnd) { | 757 if (event.phase === WebInspector.TracingModel.Phase.AsyncEnd || event.ph
ase === WebInspector.TracingModel.Phase.NestableAsyncEnd) { |
| 758 this.setEndTime(event.startTime); | 758 this.setEndTime(event.startTime); |
| 759 // FIXME: ideally, we shouldn't do this, but this makes the logic of
converting | 759 // FIXME: ideally, we shouldn't do this, but this makes the logic of
converting |
| 760 // async console events to sync ones much simpler. | 760 // async console events to sync ones much simpler. |
| 761 this.steps[0].setEndTime(event.startTime); | 761 this.steps[0].setEndTime(event.startTime); |
| 762 } | 762 } |
| 763 }, | 763 }, |
| 764 | 764 |
| 765 __proto__: WebInspector.TracingModel.Event.prototype | 765 __proto__: WebInspector.TracingModel.Event.prototype |
| 766 } | 766 }; |
| 767 | 767 |
| 768 /** | 768 /** |
| 769 * @constructor | 769 * @constructor |
| 770 * @param {!WebInspector.TracingModel.Event} event | 770 * @param {!WebInspector.TracingModel.Event} event |
| 771 */ | 771 */ |
| 772 WebInspector.TracingModel.ProfileEventsGroup = function(event) | 772 WebInspector.TracingModel.ProfileEventsGroup = function(event) |
| 773 { | 773 { |
| 774 /** @type {!Array<!WebInspector.TracingModel.Event>} */ | 774 /** @type {!Array<!WebInspector.TracingModel.Event>} */ |
| 775 this.children = [event]; | 775 this.children = [event]; |
| 776 } | 776 }; |
| 777 | 777 |
| 778 WebInspector.TracingModel.ProfileEventsGroup.prototype = { | 778 WebInspector.TracingModel.ProfileEventsGroup.prototype = { |
| 779 /** | 779 /** |
| 780 * @param {!WebInspector.TracingModel.Event} event | 780 * @param {!WebInspector.TracingModel.Event} event |
| 781 */ | 781 */ |
| 782 _addChild: function(event) | 782 _addChild: function(event) |
| 783 { | 783 { |
| 784 this.children.push(event); | 784 this.children.push(event); |
| 785 } | 785 } |
| 786 } | 786 }; |
| 787 | 787 |
| 788 /** | 788 /** |
| 789 * @constructor | 789 * @constructor |
| 790 */ | 790 */ |
| 791 WebInspector.TracingModel.NamedObject = function() | 791 WebInspector.TracingModel.NamedObject = function() |
| 792 { | 792 { |
| 793 } | 793 }; |
| 794 | 794 |
| 795 WebInspector.TracingModel.NamedObject.prototype = | 795 WebInspector.TracingModel.NamedObject.prototype = |
| 796 { | 796 { |
| 797 /** | 797 /** |
| 798 * @param {string} name | 798 * @param {string} name |
| 799 */ | 799 */ |
| 800 _setName: function(name) | 800 _setName: function(name) |
| 801 { | 801 { |
| 802 this._name = name; | 802 this._name = name; |
| 803 }, | 803 }, |
| 804 | 804 |
| 805 /** | 805 /** |
| 806 * @return {string} | 806 * @return {string} |
| 807 */ | 807 */ |
| 808 name: function() | 808 name: function() |
| 809 { | 809 { |
| 810 return this._name; | 810 return this._name; |
| 811 }, | 811 }, |
| 812 | 812 |
| 813 /** | 813 /** |
| 814 * @param {number} sortIndex | 814 * @param {number} sortIndex |
| 815 */ | 815 */ |
| 816 _setSortIndex: function(sortIndex) | 816 _setSortIndex: function(sortIndex) |
| 817 { | 817 { |
| 818 this._sortIndex = sortIndex; | 818 this._sortIndex = sortIndex; |
| 819 }, | 819 }, |
| 820 } | 820 }; |
| 821 | 821 |
| 822 /** | 822 /** |
| 823 * @param {!Array.<!WebInspector.TracingModel.NamedObject>} array | 823 * @param {!Array.<!WebInspector.TracingModel.NamedObject>} array |
| 824 */ | 824 */ |
| 825 WebInspector.TracingModel.NamedObject._sort = function(array) | 825 WebInspector.TracingModel.NamedObject._sort = function(array) |
| 826 { | 826 { |
| 827 /** | 827 /** |
| 828 * @param {!WebInspector.TracingModel.NamedObject} a | 828 * @param {!WebInspector.TracingModel.NamedObject} a |
| 829 * @param {!WebInspector.TracingModel.NamedObject} b | 829 * @param {!WebInspector.TracingModel.NamedObject} b |
| 830 */ | 830 */ |
| 831 function comparator(a, b) | 831 function comparator(a, b) |
| 832 { | 832 { |
| 833 return a._sortIndex !== b._sortIndex ? a._sortIndex - b._sortIndex : a.n
ame().localeCompare(b.name()); | 833 return a._sortIndex !== b._sortIndex ? a._sortIndex - b._sortIndex : a.n
ame().localeCompare(b.name()); |
| 834 } | 834 } |
| 835 return array.sort(comparator); | 835 return array.sort(comparator); |
| 836 } | 836 }; |
| 837 | 837 |
| 838 /** | 838 /** |
| 839 * @constructor | 839 * @constructor |
| 840 * @extends {WebInspector.TracingModel.NamedObject} | 840 * @extends {WebInspector.TracingModel.NamedObject} |
| 841 * @param {!WebInspector.TracingModel} model | 841 * @param {!WebInspector.TracingModel} model |
| 842 * @param {number} id | 842 * @param {number} id |
| 843 */ | 843 */ |
| 844 WebInspector.TracingModel.Process = function(model, id) | 844 WebInspector.TracingModel.Process = function(model, id) |
| 845 { | 845 { |
| 846 WebInspector.TracingModel.NamedObject.call(this); | 846 WebInspector.TracingModel.NamedObject.call(this); |
| 847 this._setName("Process " + id); | 847 this._setName("Process " + id); |
| 848 this._id = id; | 848 this._id = id; |
| 849 /** @type {!Map<number, !WebInspector.TracingModel.Thread>} */ | 849 /** @type {!Map<number, !WebInspector.TracingModel.Thread>} */ |
| 850 this._threads = new Map(); | 850 this._threads = new Map(); |
| 851 this._threadByName = new Map(); | 851 this._threadByName = new Map(); |
| 852 this._model = model; | 852 this._model = model; |
| 853 } | 853 }; |
| 854 | 854 |
| 855 WebInspector.TracingModel.Process.prototype = { | 855 WebInspector.TracingModel.Process.prototype = { |
| 856 /** | 856 /** |
| 857 * @return {number} | 857 * @return {number} |
| 858 */ | 858 */ |
| 859 id: function() | 859 id: function() |
| 860 { | 860 { |
| 861 return this._id; | 861 return this._id; |
| 862 }, | 862 }, |
| 863 | 863 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 | 904 |
| 905 /** | 905 /** |
| 906 * @return {!Array.<!WebInspector.TracingModel.Thread>} | 906 * @return {!Array.<!WebInspector.TracingModel.Thread>} |
| 907 */ | 907 */ |
| 908 sortedThreads: function() | 908 sortedThreads: function() |
| 909 { | 909 { |
| 910 return WebInspector.TracingModel.NamedObject._sort(this._threads.valuesA
rray()); | 910 return WebInspector.TracingModel.NamedObject._sort(this._threads.valuesA
rray()); |
| 911 }, | 911 }, |
| 912 | 912 |
| 913 __proto__: WebInspector.TracingModel.NamedObject.prototype | 913 __proto__: WebInspector.TracingModel.NamedObject.prototype |
| 914 } | 914 }; |
| 915 | 915 |
| 916 /** | 916 /** |
| 917 * @constructor | 917 * @constructor |
| 918 * @extends {WebInspector.TracingModel.NamedObject} | 918 * @extends {WebInspector.TracingModel.NamedObject} |
| 919 * @param {!WebInspector.TracingModel.Process} process | 919 * @param {!WebInspector.TracingModel.Process} process |
| 920 * @param {number} id | 920 * @param {number} id |
| 921 */ | 921 */ |
| 922 WebInspector.TracingModel.Thread = function(process, id) | 922 WebInspector.TracingModel.Thread = function(process, id) |
| 923 { | 923 { |
| 924 WebInspector.TracingModel.NamedObject.call(this); | 924 WebInspector.TracingModel.NamedObject.call(this); |
| 925 this._process = process; | 925 this._process = process; |
| 926 this._setName("Thread " + id); | 926 this._setName("Thread " + id); |
| 927 this._events = []; | 927 this._events = []; |
| 928 this._asyncEvents = []; | 928 this._asyncEvents = []; |
| 929 this._id = id; | 929 this._id = id; |
| 930 this._model = process._model; | 930 this._model = process._model; |
| 931 } | 931 }; |
| 932 | 932 |
| 933 WebInspector.TracingModel.Thread.prototype = { | 933 WebInspector.TracingModel.Thread.prototype = { |
| 934 tracingComplete: function() | 934 tracingComplete: function() |
| 935 { | 935 { |
| 936 this._asyncEvents.stableSort(WebInspector.TracingModel.Event.compareStar
tAndEndTime); | 936 this._asyncEvents.stableSort(WebInspector.TracingModel.Event.compareStar
tAndEndTime); |
| 937 this._events.stableSort(WebInspector.TracingModel.Event.compareStartTime
); | 937 this._events.stableSort(WebInspector.TracingModel.Event.compareStartTime
); |
| 938 var phases = WebInspector.TracingModel.Phase; | 938 var phases = WebInspector.TracingModel.Phase; |
| 939 var stack = []; | 939 var stack = []; |
| 940 for (var i = 0; i < this._events.length; ++i) { | 940 for (var i = 0; i < this._events.length; ++i) { |
| 941 var e = this._events[i]; | 941 var e = this._events[i]; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 | 1025 |
| 1026 /** | 1026 /** |
| 1027 * @return {!Array.<!WebInspector.TracingModel.AsyncEvent>} | 1027 * @return {!Array.<!WebInspector.TracingModel.AsyncEvent>} |
| 1028 */ | 1028 */ |
| 1029 asyncEvents: function() | 1029 asyncEvents: function() |
| 1030 { | 1030 { |
| 1031 return this._asyncEvents; | 1031 return this._asyncEvents; |
| 1032 }, | 1032 }, |
| 1033 | 1033 |
| 1034 __proto__: WebInspector.TracingModel.NamedObject.prototype | 1034 __proto__: WebInspector.TracingModel.NamedObject.prototype |
| 1035 } | 1035 }; |
| OLD | NEW |