OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2013 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/extension_registry.html"> | 8 <link rel="import" href="/tracing/base/extension_registry.html"> |
9 <link rel="import" href="/tracing/model/timed_event.html"> | 9 <link rel="import" href="/tracing/model/timed_event.html"> |
10 <link rel="import" href="/tracing/value/unit.html"> | 10 <link rel="import" href="/tracing/value/unit.html"> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 return 'Async slice ' + this.title + ' at ' + | 96 return 'Async slice ' + this.title + ' at ' + |
97 tr.v.Unit.byName.timeStampInMs.format(this.start); | 97 tr.v.Unit.byName.timeStampInMs.format(this.start); |
98 }, | 98 }, |
99 | 99 |
100 get stableId() { | 100 get stableId() { |
101 var parentAsyncSliceGroup = this.parentContainer.asyncSliceGroup; | 101 var parentAsyncSliceGroup = this.parentContainer.asyncSliceGroup; |
102 return parentAsyncSliceGroup.stableId + '.' + | 102 return parentAsyncSliceGroup.stableId + '.' + |
103 parentAsyncSliceGroup.slices.indexOf(this); | 103 parentAsyncSliceGroup.slices.indexOf(this); |
104 }, | 104 }, |
105 | 105 |
106 findTopmostSlicesRelativeToThisSlice: function(eventPredicate, callback, | 106 findTopmostSlicesRelativeToThisSlice: function*(eventPredicate, opt_this) { |
107 opt_this) { | 107 if (eventPredicate(this)) { |
108 if (eventPredicate(this)) | 108 yield this; |
109 callback.call(opt_this, this); | 109 return; |
110 else { | |
111 this.subSlices.forEach(function(s) { | |
112 s.findTopmostSlicesRelativeToThisSlice(eventPredicate, callback, | |
113 opt_this); | |
114 }); | |
115 } | 110 } |
| 111 for (var s of this.subSlices) |
| 112 yield * s.findTopmostSlicesRelativeToThisSlice(eventPredicate); |
116 }, | 113 }, |
117 | 114 |
118 findDescendentSlice: function(targetTitle) { | 115 findDescendentSlice: function(targetTitle) { |
119 if (!this.subSlices) | 116 if (!this.subSlices) |
120 return undefined; | 117 return undefined; |
121 | 118 |
122 for (var i = 0; i < this.subSlices.length; i++) { | 119 for (var i = 0; i < this.subSlices.length; i++) { |
123 if (this.subSlices[i].title == targetTitle) | 120 if (this.subSlices[i].title == targetTitle) |
124 return this.subSlices[i]; | 121 return this.subSlices[i]; |
125 var slice = this.subSlices[i].findDescendentSlice(targetTitle); | 122 var slice = this.subSlices[i].findDescendentSlice(targetTitle); |
126 if (slice) return slice; | 123 if (slice) return slice; |
127 } | 124 } |
128 return undefined; | 125 return undefined; |
129 }, | 126 }, |
130 | 127 |
131 iterateAllDescendents: function(callback, opt_this) { | 128 enumerateAllDescendents: function*() { |
132 this.subSlices.forEach(callback, opt_this); | 129 for (var slice of this.subSlices) |
133 this.subSlices.forEach(function(subSlice) { | 130 yield slice; |
134 subSlice.iterateAllDescendents(callback, opt_this); | 131 for (var slice of this.subSlices) |
135 }, opt_this); | 132 yield * slice.enumerateAllDescendents(); |
136 }, | 133 }, |
137 | 134 |
138 compareTo: function(that) { | 135 compareTo: function(that) { |
139 return this.title.localeCompare(that.title); | 136 return this.title.localeCompare(that.title); |
140 } | 137 } |
141 }; | 138 }; |
142 | 139 |
143 tr.model.EventRegistry.register( | 140 tr.model.EventRegistry.register( |
144 AsyncSlice, | 141 AsyncSlice, |
145 { | 142 { |
146 name: 'asyncSlice', | 143 name: 'asyncSlice', |
147 pluralName: 'asyncSlices', | 144 pluralName: 'asyncSlices', |
148 singleViewElementName: 'tr-ui-a-single-async-slice-sub-view', | 145 singleViewElementName: 'tr-ui-a-single-async-slice-sub-view', |
149 multiViewElementName: 'tr-ui-a-multi-async-slice-sub-view' | 146 multiViewElementName: 'tr-ui-a-multi-async-slice-sub-view' |
150 }); | 147 }); |
151 | 148 |
152 | 149 |
153 var options = new tr.b.ExtensionRegistryOptions( | 150 var options = new tr.b.ExtensionRegistryOptions( |
154 tr.b.TYPE_BASED_REGISTRY_MODE); | 151 tr.b.TYPE_BASED_REGISTRY_MODE); |
155 options.mandatoryBaseClass = AsyncSlice; | 152 options.mandatoryBaseClass = AsyncSlice; |
156 options.defaultConstructor = AsyncSlice; | 153 options.defaultConstructor = AsyncSlice; |
157 tr.b.decorateExtensionRegistry(AsyncSlice, options); | 154 tr.b.decorateExtensionRegistry(AsyncSlice, options); |
158 | 155 |
159 return { | 156 return { |
160 AsyncSlice: AsyncSlice | 157 AsyncSlice: AsyncSlice |
161 }; | 158 }; |
162 }); | 159 }); |
163 </script> | 160 </script> |
OLD | NEW |