Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 The Chromium Authors. All rights reserved. | 2 * Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @constructor | 8 * @constructor |
| 9 * @param {!WebInspector.TracingModel} tracingModel | 9 * @param {!WebInspector.TracingModel} tracingModel |
| 10 */ | 10 */ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 */ | 47 */ |
| 48 zeroTime: function() | 48 zeroTime: function() |
| 49 { | 49 { |
| 50 return this._tracingModel.minimumRecordTime(); | 50 return this._tracingModel.minimumRecordTime(); |
| 51 }, | 51 }, |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * @param {number} timestamp | 54 * @param {number} timestamp |
| 55 * @return {?WebInspector.FilmStripModel.Frame} | 55 * @return {?WebInspector.FilmStripModel.Frame} |
| 56 */ | 56 */ |
| 57 firstFrameAfterCommit: function(timestamp) | 57 frameByTimestamp: function(timestamp) |
| 58 { | 58 { |
| 59 var bestIndex = 0; | 59 /** |
| 60 var bestDelta = Number.MAX_VALUE; | 60 * @param {number} timestamp |
| 61 for (var i = 0; i < this._frames.length; ++i) { | 61 * @param {!WebInspector.FilmStripModel.Frame} frame |
| 62 var delta = this._frames[i].timestamp - timestamp; | 62 * @return {number} |
| 63 if (delta < 0) | 63 */ |
| 64 continue; | 64 function comparator(timestamp, frame) |
| 65 if (delta < bestDelta) { | 65 { |
| 66 bestIndex = i; | 66 return timestamp - frame.timestamp; |
| 67 bestDelta = delta; | |
| 68 } | |
| 69 } | 67 } |
| 70 return bestDelta < 10 ? this._frames[bestIndex] : null; | 68 var index = this._frames.upperBound(timestamp, comparator) - 1; |
|
yurys
2015/06/09 13:22:36
lowerBound?
alph
2015/06/09 13:26:38
Done.
| |
| 69 return index >= 0 ? this._frames[index] : null; | |
| 71 } | 70 } |
| 72 } | 71 } |
| 73 | 72 |
| 74 /** | 73 /** |
| 75 * @constructor | 74 * @constructor |
| 76 * @param {!WebInspector.FilmStripModel} model | 75 * @param {!WebInspector.FilmStripModel} model |
| 77 * @param {string} imageData | 76 * @param {string} imageData |
| 78 * @param {number} timestamp | 77 * @param {number} timestamp |
| 79 * @param {number} index | 78 * @param {number} index |
| 80 */ | 79 */ |
| 81 WebInspector.FilmStripModel.Frame = function(model, imageData, timestamp, index) | 80 WebInspector.FilmStripModel.Frame = function(model, imageData, timestamp, index) |
| 82 { | 81 { |
| 83 this._model = model; | 82 this._model = model; |
| 84 this.imageData = imageData; | 83 this.imageData = imageData; |
| 85 this.timestamp = timestamp; | 84 this.timestamp = timestamp; |
| 86 this.index = index; | 85 this.index = index; |
| 87 } | 86 } |
| 88 | 87 |
| 89 WebInspector.FilmStripModel.Frame.prototype = { | 88 WebInspector.FilmStripModel.Frame.prototype = { |
| 90 /** | 89 /** |
| 91 * @return {!WebInspector.FilmStripModel} | 90 * @return {!WebInspector.FilmStripModel} |
| 92 */ | 91 */ |
| 93 model: function() | 92 model: function() |
| 94 { | 93 { |
| 95 return this._model; | 94 return this._model; |
| 96 } | 95 } |
| 97 } | 96 } |
| OLD | NEW |