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 <link rel="import" href="/tracing/base/range.html"> | 7 <link rel="import" href="/tracing/base/math/range.html"> |
8 <link rel="import" href="/tracing/base/sorted_array_utils.html"> | 8 <link rel="import" href="/tracing/base/math/sorted_array_utils.html"> |
9 | 9 |
10 <script> | 10 <script> |
11 'use strict'; | 11 'use strict'; |
12 | 12 |
13 /** | 13 /** |
14 * @fileoverview Provides the TimeToObjectInstanceMap class. | 14 * @fileoverview Provides the TimeToObjectInstanceMap class. |
15 */ | 15 */ |
16 tr.exportTo('tr.model', function() { | 16 tr.exportTo('tr.model', function() { |
17 /** | 17 /** |
18 * Tracks all the instances associated with a given ID over its lifetime. | 18 * Tracks all the instances associated with a given ID over its lifetime. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 this.instances.push(lastInstance); | 52 this.instances.push(lastInstance); |
53 return lastInstance; | 53 return lastInstance; |
54 }, | 54 }, |
55 | 55 |
56 addSnapshot: function(category, name, ts, args, opt_baseTypeName) { | 56 addSnapshot: function(category, name, ts, args, opt_baseTypeName) { |
57 if (this.instances.length === 0) { | 57 if (this.instances.length === 0) { |
58 this.instances.push(this.createObjectInstanceFunction_( | 58 this.instances.push(this.createObjectInstanceFunction_( |
59 this.parent, this.scopedId, category, name, ts, opt_baseTypeName)); | 59 this.parent, this.scopedId, category, name, ts, opt_baseTypeName)); |
60 } | 60 } |
61 | 61 |
62 var i = tr.b.findIndexInSortedIntervals( | 62 var i = tr.b.math.findIndexInSortedIntervals( |
63 this.instances, | 63 this.instances, |
64 function(inst) { return inst.creationTs; }, | 64 function(inst) { return inst.creationTs; }, |
65 function(inst) { return inst.deletionTs - inst.creationTs; }, | 65 function(inst) { return inst.deletionTs - inst.creationTs; }, |
66 ts); | 66 ts); |
67 | 67 |
68 var instance; | 68 var instance; |
69 if (i < 0) { | 69 if (i < 0) { |
70 instance = this.instances[0]; | 70 instance = this.instances[0]; |
71 if (ts > instance.deletionTs || | 71 if (ts > instance.deletionTs || |
72 instance.creationTsWasExplicit) { | 72 instance.creationTsWasExplicit) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // A new instance was deleted with no snapshots in-between. | 147 // A new instance was deleted with no snapshots in-between. |
148 // Create an instance then kill it. | 148 // Create an instance then kill it. |
149 lastInstance = this.createObjectInstanceFunction_( | 149 lastInstance = this.createObjectInstanceFunction_( |
150 this.parent, this.scopedId, category, name, ts); | 150 this.parent, this.scopedId, category, name, ts); |
151 this.instances.push(lastInstance); | 151 this.instances.push(lastInstance); |
152 lastInstance.wasDeleted(ts); | 152 lastInstance.wasDeleted(ts); |
153 return lastInstance; | 153 return lastInstance; |
154 }, | 154 }, |
155 | 155 |
156 getInstanceAt: function(ts) { | 156 getInstanceAt: function(ts) { |
157 var i = tr.b.findIndexInSortedIntervals( | 157 var i = tr.b.math.findIndexInSortedIntervals( |
158 this.instances, | 158 this.instances, |
159 function(inst) { return inst.creationTs; }, | 159 function(inst) { return inst.creationTs; }, |
160 function(inst) { return inst.deletionTs - inst.creationTs; }, | 160 function(inst) { return inst.deletionTs - inst.creationTs; }, |
161 ts); | 161 ts); |
162 if (i < 0) { | 162 if (i < 0) { |
163 if (this.instances[0].creationTsWasExplicit) | 163 if (this.instances[0].creationTsWasExplicit) |
164 return undefined; | 164 return undefined; |
165 return this.instances[0]; | 165 return this.instances[0]; |
166 } else if (i >= this.instances.length) { | 166 } else if (i >= this.instances.length) { |
167 return undefined; | 167 return undefined; |
168 } | 168 } |
169 return this.instances[i]; | 169 return this.instances[i]; |
170 } | 170 } |
171 }; | 171 }; |
172 | 172 |
173 return { | 173 return { |
174 TimeToObjectInstanceMap, | 174 TimeToObjectInstanceMap, |
175 }; | 175 }; |
176 }); | 176 }); |
177 </script> | 177 </script> |
OLD | NEW |