OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @extends {WebInspector.TimelineModel} | 7 * @extends {WebInspector.TimelineModel} |
8 * @param {!WebInspector.TimelineManager} timelineManager | 8 * @param {!WebInspector.TimelineManager} timelineManager |
9 */ | 9 */ |
10 WebInspector.TimelineModelImpl = function(timelineManager) | 10 WebInspector.TimelineModelImpl = function(timelineManager) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 { | 42 { |
43 console.assert(!capturePictures, "Legacy timeline does not support captu ring pictures"); | 43 console.assert(!capturePictures, "Legacy timeline does not support captu ring pictures"); |
44 this._clientInitiatedRecording = true; | 44 this._clientInitiatedRecording = true; |
45 this.reset(); | 45 this.reset(); |
46 var maxStackFrames = captureStacks ? 30 : 0; | 46 var maxStackFrames = captureStacks ? 30 : 0; |
47 var includeGPUEvents = WebInspector.experimentsSettings.gpuTimeline.isEn abled(); | 47 var includeGPUEvents = WebInspector.experimentsSettings.gpuTimeline.isEn abled(); |
48 var liveEvents = [ WebInspector.TimelineModel.RecordType.BeginFrame, | 48 var liveEvents = [ WebInspector.TimelineModel.RecordType.BeginFrame, |
49 WebInspector.TimelineModel.RecordType.DrawFrame, | 49 WebInspector.TimelineModel.RecordType.DrawFrame, |
50 WebInspector.TimelineModel.RecordType.RequestMainThre adFrame, | 50 WebInspector.TimelineModel.RecordType.RequestMainThre adFrame, |
51 WebInspector.TimelineModel.RecordType.ActivateLayerTr ee ]; | 51 WebInspector.TimelineModel.RecordType.ActivateLayerTr ee ]; |
52 this._timelineManager.start(maxStackFrames, WebInspector.experimentsSett ings.timelineNoLiveUpdate.isEnabled(), liveEvents.join(","), captureMemory, incl udeGPUEvents, this._fireRecordingStarted.bind(this)); | 52 this._timelineManager.start(maxStackFrames, liveEvents.join(","), captur eMemory, includeGPUEvents, this._fireRecordingStarted.bind(this)); |
53 }, | 53 }, |
54 | 54 |
55 stopRecording: function() | 55 stopRecording: function() |
56 { | 56 { |
57 if (!this._clientInitiatedRecording) { | 57 if (!this._clientInitiatedRecording) { |
58 this._timelineManager.start(undefined, undefined, undefined, undefin ed, undefined, stopTimeline.bind(this)); | 58 this._timelineManager.start(undefined, undefined, undefined, undefin ed, stopTimeline.bind(this)); |
59 return; | 59 return; |
60 } | 60 } |
61 | 61 |
62 /** | 62 /** |
63 * Console started this one and we are just sniffing it. Initiate record ing so that we | 63 * Console started this one and we are just sniffing it. Initiate record ing so that we |
64 * could stop it. | 64 * could stop it. |
65 * @this {WebInspector.TimelineModelImpl} | 65 * @this {WebInspector.TimelineModelImpl} |
66 */ | 66 */ |
67 function stopTimeline() | 67 function stopTimeline() |
68 { | 68 { |
(...skipping 10 matching lines...) Expand all Loading... | |
79 records: function() | 79 records: function() |
80 { | 80 { |
81 return this._records; | 81 return this._records; |
82 }, | 82 }, |
83 | 83 |
84 /** | 84 /** |
85 * @param {!WebInspector.Event} event | 85 * @param {!WebInspector.Event} event |
86 */ | 86 */ |
87 _onRecordAdded: function(event) | 87 _onRecordAdded: function(event) |
88 { | 88 { |
89 if (this._collectionEnabled) | 89 this._addRecord(/** @type {!TimelineAgent.TimelineEvent} */(event.data)) ; |
yurys
2014/07/17 10:42:24
Without this check we will display events if timel
| |
90 this._addRecord(/** @type {!TimelineAgent.TimelineEvent} */(event.da ta)); | |
91 }, | 90 }, |
92 | 91 |
93 /** | 92 /** |
94 * @param {!WebInspector.Event} event | 93 * @param {!WebInspector.Event} event |
95 */ | 94 */ |
96 _onStarted: function(event) | 95 _onStarted: function(event) |
97 { | 96 { |
98 if (event.data) { | 97 if (event.data) { |
99 // Started from console. | 98 // Started from console. |
100 this._fireRecordingStarted(); | 99 this._fireRecordingStarted(); |
101 } | 100 } |
102 }, | 101 }, |
103 | 102 |
104 /** | 103 /** |
105 * @param {!WebInspector.Event} event | 104 * @param {!WebInspector.Event} event |
106 */ | 105 */ |
107 _onStopped: function(event) | 106 _onStopped: function(event) |
108 { | 107 { |
109 // If we were buffering events, discard those that got through, the real ones are coming! | 108 // We were buffering events, discard those that got through, the real on es are coming! |
110 if (WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled()) | 109 this.reset(); |
111 this.reset(); | |
112 if (event.data) { | 110 if (event.data) { |
113 // Stopped from console. | 111 // Stopped from console. |
114 this._fireRecordingStopped(null, null); | 112 this._fireRecordingStopped(null, null); |
115 } | 113 } |
116 }, | 114 }, |
117 | 115 |
118 /** | 116 /** |
119 * @param {!WebInspector.Event} event | 117 * @param {!WebInspector.Event} event |
120 */ | 118 */ |
121 _onProgress: function(event) | 119 _onProgress: function(event) |
122 { | 120 { |
123 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gProgress, event.data); | 121 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gProgress, event.data); |
124 }, | 122 }, |
125 | 123 |
126 _fireRecordingStarted: function() | 124 _fireRecordingStarted: function() |
127 { | 125 { |
128 this._collectionEnabled = true; | |
129 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStarted); | 126 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStarted); |
130 }, | 127 }, |
131 | 128 |
132 /** | 129 /** |
133 * @param {?Protocol.Error} error | 130 * @param {?Protocol.Error} error |
134 * @param {?ProfilerAgent.CPUProfile} cpuProfile | 131 * @param {?ProfilerAgent.CPUProfile} cpuProfile |
135 */ | 132 */ |
136 _fireRecordingStopped: function(error, cpuProfile) | 133 _fireRecordingStopped: function(error, cpuProfile) |
137 { | 134 { |
138 this._collectionEnabled = false; | |
139 if (cpuProfile) | 135 if (cpuProfile) |
140 WebInspector.TimelineJSProfileProcessor.mergeJSProfileIntoTimeline(t his, cpuProfile); | 136 WebInspector.TimelineJSProfileProcessor.mergeJSProfileIntoTimeline(t his, cpuProfile); |
141 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStopped); | 137 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStopped); |
142 }, | 138 }, |
143 | 139 |
144 /** | 140 /** |
145 * @param {!TimelineAgent.TimelineEvent} payload | 141 * @param {!TimelineAgent.TimelineEvent} payload |
146 */ | 142 */ |
147 _addRecord: function(payload) | 143 _addRecord: function(payload) |
148 { | 144 { |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
701 break; | 697 break; |
702 length += itemLength; | 698 length += itemLength; |
703 data.push(item); | 699 data.push(item); |
704 ++this._recordIndex; | 700 ++this._recordIndex; |
705 } | 701 } |
706 if (this._recordIndex === this._payloads.length) | 702 if (this._recordIndex === this._payloads.length) |
707 data.push(data.pop() + "]"); | 703 data.push(data.pop() + "]"); |
708 stream.write(data.join(separator), this._writeNextChunk.bind(this)); | 704 stream.write(data.join(separator), this._writeNextChunk.bind(this)); |
709 } | 705 } |
710 } | 706 } |
OLD | NEW |