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 * @param {!WebInspector.TracingModel} tracingModel |
6 * @constructor | 7 * @constructor |
7 */ | 8 */ |
8 WebInspector.TimelineTraceEventBindings = function() | 9 WebInspector.TracingTimelineModel = function(tracingModel) |
9 { | 10 { |
10 this._reset(); | 11 this._tracingModel = tracingModel; |
| 12 this._mainThreadEvents = []; |
11 } | 13 } |
12 | 14 |
13 WebInspector.TimelineTraceEventBindings.RecordType = { | 15 WebInspector.TracingTimelineModel.RecordType = { |
14 Program: "Program", | 16 Program: "Program", |
15 EventDispatch: "EventDispatch", | 17 EventDispatch: "EventDispatch", |
16 | 18 |
17 GPUTask: "GPUTask", | 19 GPUTask: "GPUTask", |
18 | 20 |
19 RequestMainThreadFrame: "RequestMainThreadFrame", | 21 RequestMainThreadFrame: "RequestMainThreadFrame", |
20 BeginFrame: "BeginFrame", | 22 BeginFrame: "BeginFrame", |
21 BeginMainThreadFrame: "BeginMainThreadFrame", | 23 BeginMainThreadFrame: "BeginMainThreadFrame", |
22 ActivateLayerTree: "ActivateLayerTree", | 24 ActivateLayerTree: "ActivateLayerTree", |
23 DrawFrame: "DrawFrame", | 25 DrawFrame: "DrawFrame", |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 DecodeImage: "Decode Image", | 82 DecodeImage: "Decode Image", |
81 ResizeImage: "Resize Image", | 83 ResizeImage: "Resize Image", |
82 DrawLazyPixelRef: "Draw LazyPixelRef", | 84 DrawLazyPixelRef: "Draw LazyPixelRef", |
83 DecodeLazyPixelRef: "Decode LazyPixelRef", | 85 DecodeLazyPixelRef: "Decode LazyPixelRef", |
84 | 86 |
85 LazyPixelRef: "LazyPixelRef", | 87 LazyPixelRef: "LazyPixelRef", |
86 LayerTreeHostImplSnapshot: "cc::LayerTreeHostImpl" | 88 LayerTreeHostImplSnapshot: "cc::LayerTreeHostImpl" |
87 }; | 89 }; |
88 | 90 |
89 | 91 |
90 WebInspector.TimelineTraceEventBindings.prototype = { | 92 WebInspector.TracingTimelineModel.prototype = { |
| 93 willStartRecordingTraceEvents: function() |
| 94 { |
| 95 this._mainThreadEvents = []; |
| 96 }, |
| 97 |
| 98 didStopRecordingTraceEvents: function() |
| 99 { |
| 100 var events = this._tracingModel.inspectedTargetEvents(); |
| 101 this._resetProcessingState(); |
| 102 for (var i = 0, length = events.length; i < length; i++) |
| 103 this._processEvent(events[i]); |
| 104 this._resetProcessingState(); |
| 105 }, |
| 106 |
| 107 /** |
| 108 * @return {?number} |
| 109 */ |
| 110 minimumRecordTime: function() |
| 111 { |
| 112 return this._tracingModel.minimumRecordTime(); |
| 113 }, |
| 114 |
| 115 /** |
| 116 * @return {?number} |
| 117 */ |
| 118 maximumRecordTime: function() |
| 119 { |
| 120 return this._tracingModel.maximumRecordTime(); |
| 121 }, |
| 122 |
| 123 /** |
| 124 * @return {!Array.<!WebInspector.TracingModel.Event>} |
| 125 */ |
| 126 inspectedTargetEvents: function() |
| 127 { |
| 128 return this._tracingModel.inspectedTargetEvents(); |
| 129 }, |
| 130 |
91 /** | 131 /** |
92 * @return {!Array.<!WebInspector.TracingModel.Event>} | 132 * @return {!Array.<!WebInspector.TracingModel.Event>} |
93 */ | 133 */ |
94 mainThreadEvents: function() | 134 mainThreadEvents: function() |
95 { | 135 { |
96 return this._mainThreadEvents; | 136 return this._mainThreadEvents; |
97 }, | 137 }, |
98 | 138 |
99 _reset: function() | |
100 { | |
101 this._resetProcessingState(); | |
102 this._mainThreadEvents = []; | |
103 }, | |
104 | |
105 _resetProcessingState: function() | 139 _resetProcessingState: function() |
106 { | 140 { |
107 this._sendRequestEvents = {}; | 141 this._sendRequestEvents = {}; |
108 this._timerEvents = {}; | 142 this._timerEvents = {}; |
109 this._requestAnimationFrameEvents = {}; | 143 this._requestAnimationFrameEvents = {}; |
110 this._layoutInvalidate = {}; | 144 this._layoutInvalidate = {}; |
111 this._lastScheduleStyleRecalculation = {}; | 145 this._lastScheduleStyleRecalculation = {}; |
112 this._webSocketCreateEvents = {}; | 146 this._webSocketCreateEvents = {}; |
113 this._paintImageEventByPixelRefId = {}; | 147 this._paintImageEventByPixelRefId = {}; |
114 | 148 |
115 this._lastRecalculateStylesEvent = null; | 149 this._lastRecalculateStylesEvent = null; |
116 this._currentScriptEvent = null; | 150 this._currentScriptEvent = null; |
117 this._eventStack = []; | 151 this._eventStack = []; |
118 }, | 152 }, |
119 | 153 |
120 /** | 154 /** |
121 * @param {!Array.<!WebInspector.TracingModel.Event>} events | |
122 */ | |
123 setEvents: function(events) | |
124 { | |
125 this._resetProcessingState(); | |
126 for (var i = 0, length = events.length; i < length; i++) | |
127 this._processEvent(events[i]); | |
128 this._resetProcessingState(); | |
129 }, | |
130 | |
131 /** | |
132 * @param {!WebInspector.TracingModel.Event} event | 155 * @param {!WebInspector.TracingModel.Event} event |
133 */ | 156 */ |
134 _processEvent: function(event) | 157 _processEvent: function(event) |
135 { | 158 { |
136 var recordTypes = WebInspector.TimelineTraceEventBindings.RecordType; | 159 var recordTypes = WebInspector.TracingTimelineModel.RecordType; |
137 | 160 |
138 var eventStack = this._eventStack; | 161 var eventStack = this._eventStack; |
139 while (eventStack.length && eventStack.peekLast().endTime < event.startT
ime) | 162 while (eventStack.length && eventStack.peekLast().endTime < event.startT
ime) |
140 eventStack.pop(); | 163 eventStack.pop(); |
141 var duration = event.duration; | 164 var duration = event.duration; |
142 if (duration) { | 165 if (duration) { |
143 if (eventStack.length) { | 166 if (eventStack.length) { |
144 var parent = eventStack.peekLast(); | 167 var parent = eventStack.peekLast(); |
145 parent.selfTime -= duration; | 168 parent.selfTime -= duration; |
146 } | 169 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 { | 306 { |
284 for (var i = this._eventStack.length - 1; i >= 0; --i) { | 307 for (var i = this._eventStack.length - 1; i >= 0; --i) { |
285 var event = this._eventStack[i]; | 308 var event = this._eventStack[i]; |
286 if (event.name === name) | 309 if (event.name === name) |
287 return event; | 310 return event; |
288 } | 311 } |
289 return null; | 312 return null; |
290 } | 313 } |
291 } | 314 } |
292 | 315 |
OLD | NEW |