OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel="import" href="/tracing/base/base.html"> | 8 <link rel="import" href="/tracing/base/base.html"> |
9 <link rel="import" href="/tracing/base/event.html"> | 9 <link rel="import" href="/tracing/base/event.html"> |
10 <link rel="import" href="/tracing/base/interval_tree.html"> | 10 <link rel="import" href="/tracing/base/interval_tree.html"> |
(...skipping 13 matching lines...) Expand all Loading... |
24 <link rel="import" href="/tracing/model/kernel.html"> | 24 <link rel="import" href="/tracing/model/kernel.html"> |
25 <link rel="import" href="/tracing/model/model_indices.html"> | 25 <link rel="import" href="/tracing/model/model_indices.html"> |
26 <link rel="import" href="/tracing/model/model_stats.html"> | 26 <link rel="import" href="/tracing/model/model_stats.html"> |
27 <link rel="import" href="/tracing/model/object_snapshot.html"> | 27 <link rel="import" href="/tracing/model/object_snapshot.html"> |
28 <link rel="import" href="/tracing/model/process.html"> | 28 <link rel="import" href="/tracing/model/process.html"> |
29 <link rel="import" href="/tracing/model/process_memory_dump.html"> | 29 <link rel="import" href="/tracing/model/process_memory_dump.html"> |
30 <link rel="import" href="/tracing/model/sample.html"> | 30 <link rel="import" href="/tracing/model/sample.html"> |
31 <link rel="import" href="/tracing/model/stack_frame.html"> | 31 <link rel="import" href="/tracing/model/stack_frame.html"> |
32 <link rel="import" href="/tracing/model/user_model/user_expectation.html"> | 32 <link rel="import" href="/tracing/model/user_model/user_expectation.html"> |
33 <link rel="import" href="/tracing/model/user_model/user_model.html"> | 33 <link rel="import" href="/tracing/model/user_model/user_model.html"> |
| 34 <link rel="import" href="/tracing/ui/base/overlay.html"> |
34 <link rel="import" href="/tracing/value/time_display_mode.html"> | 35 <link rel="import" href="/tracing/value/time_display_mode.html"> |
35 <link rel="import" href="/tracing/value/unit.html"> | 36 <link rel="import" href="/tracing/value/unit.html"> |
36 | 37 |
37 <script> | 38 <script> |
38 'use strict'; | 39 'use strict'; |
39 | 40 |
40 /** | 41 /** |
41 * @fileoverview Model is a parsed representation of the | 42 * @fileoverview Model is a parsed representation of the |
42 * TraceEvents obtained from base/trace_event in which the begin-end | 43 * TraceEvents obtained from base/trace_event in which the begin-end |
43 * tokens are converted into a hierarchy of processes, threads, | 44 * tokens are converted into a hierarchy of processes, threads, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 this.helpersByConstructorGUID_ = {}; | 112 this.helpersByConstructorGUID_ = {}; |
112 this.eventsByStableId_ = undefined; | 113 this.eventsByStableId_ = undefined; |
113 } | 114 } |
114 | 115 |
115 Model.prototype = { | 116 Model.prototype = { |
116 __proto__: tr.model.EventContainer.prototype, | 117 __proto__: tr.model.EventContainer.prototype, |
117 | 118 |
118 getEventByStableId: function(stableId) { | 119 getEventByStableId: function(stableId) { |
119 if (this.eventsByStableId_ === undefined) { | 120 if (this.eventsByStableId_ === undefined) { |
120 this.eventsByStableId_ = {}; | 121 this.eventsByStableId_ = {}; |
121 this.iterateAllEvents(function(event) { | 122 for (var event of this.getDescendantEvents()) { |
122 this.eventsByStableId_[event.stableId] = event; | 123 this.eventsByStableId_[event.stableId] = event; |
123 }, this); | 124 } |
124 } | 125 } |
125 return this.eventsByStableId_[stableId]; | 126 return this.eventsByStableId_[stableId]; |
126 }, | 127 }, |
127 | 128 |
128 getOrCreateHelper: function(constructor) { | 129 getOrCreateHelper: function(constructor) { |
129 if (!constructor.guid) | 130 if (!constructor.guid) |
130 throw new Error('Helper constructors must have GUIDs'); | 131 throw new Error('Helper constructors must have GUIDs'); |
131 | 132 |
132 if (this.helpersByConstructorGUID_[constructor.guid] === undefined) { | 133 if (this.helpersByConstructorGUID_[constructor.guid] === undefined) { |
133 if (this.doesHelperGUIDSupportThisModel_[constructor.guid] === | 134 if (this.doesHelperGUIDSupportThisModel_[constructor.guid] === |
134 undefined) { | 135 undefined) { |
135 this.doesHelperGUIDSupportThisModel_[constructor.guid] = | 136 this.doesHelperGUIDSupportThisModel_[constructor.guid] = |
136 constructor.supportsModel(this); | 137 constructor.supportsModel(this); |
137 } | 138 } |
138 | 139 |
139 if (!this.doesHelperGUIDSupportThisModel_[constructor.guid]) | 140 if (!this.doesHelperGUIDSupportThisModel_[constructor.guid]) |
140 return undefined; | 141 return undefined; |
141 | 142 |
142 this.helpersByConstructorGUID_[constructor.guid] = new constructor( | 143 this.helpersByConstructorGUID_[constructor.guid] = new constructor( |
143 this); | 144 this); |
144 } | 145 } |
145 return this.helpersByConstructorGUID_[constructor.guid]; | 146 return this.helpersByConstructorGUID_[constructor.guid]; |
146 }, | 147 }, |
147 | 148 |
148 findTopmostSlicesInThisContainer: function(eventPredicate, callback, | 149 childEvents: function*() { |
149 opt_this) { | 150 yield * this.globalMemoryDumps; |
150 }, | 151 yield * this.instantEvents; |
151 | 152 yield * this.flowEvents; |
152 childEvents: function*(eventTypePredicate, opt_this) { | 153 yield * this.alerts; |
153 if (eventTypePredicate.call(opt_this, GlobalMemoryDump)) | 154 yield * this.samples; |
154 yield * this.globalMemoryDumps; | |
155 | |
156 if (eventTypePredicate.call(opt_this, GlobalInstantEvent)) | |
157 yield * this.instantEvents; | |
158 | |
159 if (eventTypePredicate.call(opt_this, FlowEvent)) | |
160 yield * this.flowEvents; | |
161 | |
162 if (eventTypePredicate.call(opt_this, Alert)) | |
163 yield * this.alerts; | |
164 | |
165 if (eventTypePredicate.call(opt_this, Sample)) | |
166 yield * this.samples; | |
167 }, | 155 }, |
168 | 156 |
169 childEventContainers: function*() { | 157 childEventContainers: function*() { |
170 yield this.userModel; | 158 yield this.userModel; |
171 yield this.device; | 159 yield this.device; |
172 yield this.kernel; | 160 yield this.kernel; |
173 yield * tr.b.dictionaryValues(this.processes); | 161 yield * tr.b.dictionaryValues(this.processes); |
174 }, | 162 }, |
175 | 163 |
176 /** | 164 /** |
177 * Some objects in the model can persist their state in ModelSettings. | 165 * Some objects in the model can persist their state in ModelSettings. |
178 * | 166 * |
179 * This iterates through them. | 167 * This iterates through them. |
180 */ | 168 */ |
181 iterateAllPersistableObjects: function(callback) { | 169 iterateAllPersistableObjects: function(callback) { |
182 this.kernel.iterateAllPersistableObjects(callback); | 170 this.kernel.iterateAllPersistableObjects(callback); |
183 for (var pid in this.processes) | 171 for (var pid in this.processes) |
184 this.processes[pid].iterateAllPersistableObjects(callback); | 172 this.processes[pid].iterateAllPersistableObjects(callback); |
185 }, | 173 }, |
186 | 174 |
187 updateBounds: function() { | 175 updateBounds: function() { |
188 this.bounds.reset(); | 176 this.bounds.reset(); |
189 var bounds = this.bounds; | 177 var bounds = this.bounds; |
190 | 178 for (var ec of this.childEventContainers()) { |
191 this.iterateAllChildEventContainers(function(ec) { | |
192 ec.updateBounds(); | 179 ec.updateBounds(); |
193 bounds.addRange(ec.bounds); | 180 bounds.addRange(ec.bounds); |
194 }); | 181 } |
195 this.iterateAllEventsInThisContainer( | 182 for (var event of this.childEvents()) |
196 function(eventConstructor) { return true; }, | 183 event.addBoundsToRange(bounds); |
197 function(event) { | |
198 event.addBoundsToRange(bounds); | |
199 }); | |
200 }, | 184 }, |
201 | 185 |
202 shiftWorldToZero: function() { | 186 shiftWorldToZero: function() { |
203 var shiftAmount = -this.bounds.min; | 187 var shiftAmount = -this.bounds.min; |
204 this.timestampShiftToZeroAmount_ = shiftAmount; | 188 this.timestampShiftToZeroAmount_ = shiftAmount; |
205 this.iterateAllChildEventContainers(function(ec) { | 189 for (var ec of this.childEventContainers()) |
206 ec.shiftTimestampsForward(shiftAmount); | 190 ec.shiftTimestampsForward(shiftAmount); |
207 }); | 191 |
208 this.iterateAllEventsInThisContainer( | 192 for (var event of this.childEvents()) |
209 function(eventConstructor) { return true; }, | 193 event.start += shiftAmount; |
210 function(event) { | |
211 event.start += shiftAmount; | |
212 }); | |
213 this.updateBounds(); | 194 this.updateBounds(); |
214 }, | 195 }, |
215 | 196 |
216 convertTimestampToModelTime: function(sourceClockDomainName, ts) { | 197 convertTimestampToModelTime: function(sourceClockDomainName, ts) { |
217 if (sourceClockDomainName !== 'traceEventClock') | 198 if (sourceClockDomainName !== 'traceEventClock') |
218 throw new Error('Only traceEventClock is supported.'); | 199 throw new Error('Only traceEventClock is supported.'); |
219 return tr.v.Unit.timestampFromUs(ts) + | 200 return tr.v.Unit.timestampFromUs(ts) + |
220 this.timestampShiftToZeroAmount_; | 201 this.timestampShiftToZeroAmount_; |
221 }, | 202 }, |
222 | 203 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 iterObjectFieldsRecursively(item.args); | 641 iterObjectFieldsRecursively(item.args); |
661 iterObjectFieldsRecursively(item.contexts); | 642 iterObjectFieldsRecursively(item.contexts); |
662 } | 643 } |
663 }; | 644 }; |
664 | 645 |
665 return { | 646 return { |
666 Model: Model | 647 Model: Model |
667 }; | 648 }; |
668 }); | 649 }); |
669 </script> | 650 </script> |
OLD | NEW |