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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 /** | 36 /** |
37 * @param {boolean} captureStacks | 37 * @param {boolean} captureStacks |
38 * @param {boolean} captureMemory | 38 * @param {boolean} captureMemory |
39 */ | 39 */ |
40 startRecording: function(captureStacks, captureMemory) | 40 startRecording: function(captureStacks, captureMemory) |
41 { | 41 { |
42 this._clientInitiatedRecording = true; | 42 this._clientInitiatedRecording = true; |
43 this.reset(); | 43 this.reset(); |
44 var maxStackFrames = captureStacks ? 30 : 0; | 44 var maxStackFrames = captureStacks ? 30 : 0; |
45 this._bufferEvents = WebInspector.experimentsSettings.timelineNoLiveUpda
te.isEnabled(); | |
46 var includeGPUEvents = WebInspector.experimentsSettings.gpuTimeline.isEn
abled(); | 45 var includeGPUEvents = WebInspector.experimentsSettings.gpuTimeline.isEn
abled(); |
47 var liveEvents = [ WebInspector.TimelineModel.RecordType.BeginFrame, | 46 var liveEvents = [ WebInspector.TimelineModel.RecordType.BeginFrame, |
48 WebInspector.TimelineModel.RecordType.DrawFrame, | 47 WebInspector.TimelineModel.RecordType.DrawFrame, |
49 WebInspector.TimelineModel.RecordType.RequestMainThre
adFrame, | 48 WebInspector.TimelineModel.RecordType.RequestMainThre
adFrame, |
50 WebInspector.TimelineModel.RecordType.ActivateLayerTr
ee ]; | 49 WebInspector.TimelineModel.RecordType.ActivateLayerTr
ee ]; |
51 this._timelineManager.start(maxStackFrames, this._bufferEvents, liveEven
ts.join(","), captureMemory, includeGPUEvents, this._fireRecordingStarted.bind(t
his)); | 50 this._timelineManager.start(maxStackFrames, WebInspector.experimentsSett
ings.timelineNoLiveUpdate.isEnabled(), liveEvents.join(","), captureMemory, incl
udeGPUEvents, this._fireRecordingStarted.bind(this)); |
52 }, | 51 }, |
53 | 52 |
54 stopRecording: function() | 53 stopRecording: function() |
55 { | 54 { |
56 if (!this._clientInitiatedRecording) { | 55 if (!this._clientInitiatedRecording) { |
57 this._timelineManager.start(undefined, undefined, undefined, undefin
ed, undefined, stopTimeline.bind(this)); | 56 this._timelineManager.start(undefined, undefined, undefined, undefin
ed, undefined, stopTimeline.bind(this)); |
58 return; | 57 return; |
59 } | 58 } |
60 | 59 |
61 /** | 60 /** |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Started from console. | 97 // Started from console. |
99 this._fireRecordingStarted(); | 98 this._fireRecordingStarted(); |
100 } | 99 } |
101 }, | 100 }, |
102 | 101 |
103 /** | 102 /** |
104 * @param {!WebInspector.Event} event | 103 * @param {!WebInspector.Event} event |
105 */ | 104 */ |
106 _onStopped: function(event) | 105 _onStopped: function(event) |
107 { | 106 { |
| 107 // If we were buffering events, discard those that got through, the real
ones are coming! |
| 108 if (WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled()) |
| 109 this.reset(); |
108 if (event.data) { | 110 if (event.data) { |
109 // Stopped from console. | 111 // Stopped from console. |
110 this._fireRecordingStopped(null, null); | 112 this._fireRecordingStopped(null, null); |
111 } | 113 } |
112 }, | 114 }, |
113 | 115 |
114 /** | 116 /** |
115 * @param {!WebInspector.Event} event | 117 * @param {!WebInspector.Event} event |
116 */ | 118 */ |
117 _onProgress: function(event) | 119 _onProgress: function(event) |
118 { | 120 { |
119 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin
gProgress, event.data); | 121 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin
gProgress, event.data); |
120 }, | 122 }, |
121 | 123 |
122 _fireRecordingStarted: function() | 124 _fireRecordingStarted: function() |
123 { | 125 { |
124 this._collectionEnabled = true; | 126 this._collectionEnabled = true; |
125 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin
gStarted); | 127 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin
gStarted); |
126 }, | 128 }, |
127 | 129 |
128 /** | 130 /** |
129 * @param {?Protocol.Error} error | 131 * @param {?Protocol.Error} error |
130 * @param {?ProfilerAgent.CPUProfile} cpuProfile | 132 * @param {?ProfilerAgent.CPUProfile} cpuProfile |
131 */ | 133 */ |
132 _fireRecordingStopped: function(error, cpuProfile) | 134 _fireRecordingStopped: function(error, cpuProfile) |
133 { | 135 { |
134 this._bufferEvents = false; | |
135 this._collectionEnabled = false; | 136 this._collectionEnabled = false; |
136 if (cpuProfile) | 137 if (cpuProfile) |
137 WebInspector.TimelineJSProfileProcessor.mergeJSProfileIntoTimeline(t
his, cpuProfile); | 138 WebInspector.TimelineJSProfileProcessor.mergeJSProfileIntoTimeline(t
his, cpuProfile); |
138 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin
gStopped); | 139 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin
gStopped); |
139 }, | 140 }, |
140 | 141 |
141 /** | 142 /** |
142 * @return {boolean} | |
143 */ | |
144 bufferEvents: function() | |
145 { | |
146 return this._bufferEvents; | |
147 }, | |
148 | |
149 /** | |
150 * @param {!TimelineAgent.TimelineEvent} payload | 143 * @param {!TimelineAgent.TimelineEvent} payload |
151 */ | 144 */ |
152 _addRecord: function(payload) | 145 _addRecord: function(payload) |
153 { | 146 { |
154 this._internStrings(payload); | 147 this._internStrings(payload); |
155 this._payloads.push(payload); | 148 this._payloads.push(payload); |
156 | 149 |
157 var record = this._innerAddRecord(payload, null); | 150 var record = this._innerAddRecord(payload, null); |
158 this._updateBoundaries(record); | 151 this._updateBoundaries(record); |
159 this._records.push(record); | 152 this._records.push(record); |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 break; | 749 break; |
757 length += itemLength; | 750 length += itemLength; |
758 data.push(item); | 751 data.push(item); |
759 ++this._recordIndex; | 752 ++this._recordIndex; |
760 } | 753 } |
761 if (this._recordIndex === this._payloads.length) | 754 if (this._recordIndex === this._payloads.length) |
762 data.push(data.pop() + "]"); | 755 data.push(data.pop() + "]"); |
763 stream.write(data.join(separator), this._writeNextChunk.bind(this)); | 756 stream.write(data.join(separator), this._writeNextChunk.bind(this)); |
764 } | 757 } |
765 } | 758 } |
OLD | NEW |