Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @param {!WebInspector.Target} target | |
| 33 * @param {string} snapshotId | 34 * @param {string} snapshotId |
| 35 * @extends {WebInspector.SDKObject} | |
| 34 */ | 36 */ |
| 35 WebInspector.PaintProfilerSnapshot = function(snapshotId) | 37 WebInspector.PaintProfilerSnapshot = function(target, snapshotId) |
|
sergeyv
2014/07/11 11:29:00
As we spoke offline, this snapshot can live longer
| |
| 36 { | 38 { |
| 39 WebInspector.SDKObject.call(this, target); | |
| 37 this._id = snapshotId; | 40 this._id = snapshotId; |
| 38 } | 41 } |
| 39 | 42 |
| 40 /** | 43 /** |
| 44 * @param {!WebInspector.Target} target | |
| 41 * @param {string} encodedPicture | 45 * @param {string} encodedPicture |
| 42 * @param {function(?WebInspector.PaintProfilerSnapshot)} callback | 46 * @param {function(?WebInspector.PaintProfilerSnapshot)} callback |
| 43 */ | 47 */ |
| 44 WebInspector.PaintProfilerSnapshot.load = function(encodedPicture, callback) | 48 WebInspector.PaintProfilerSnapshot.load = function(target, encodedPicture, callb ack) |
| 45 { | 49 { |
| 46 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTr eeAgent.loadSnapshot(): ", WebInspector.PaintProfilerSnapshot); | 50 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTr eeAgent.loadSnapshot(): ", WebInspector.PaintProfilerSnapshot.bind(null, target) ); |
| 47 LayerTreeAgent.loadSnapshot(encodedPicture, wrappedCallback); | 51 target.layerTreeAgent().loadSnapshot(encodedPicture, wrappedCallback); |
| 48 } | 52 } |
| 49 | 53 |
| 50 /** | 54 /** |
| 51 * @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log | 55 * @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log |
| 52 * @return {!Array.<!WebInspector.PaintProfilerLogItem>} | 56 * @return {!Array.<!WebInspector.PaintProfilerLogItem>} |
| 53 */ | 57 */ |
| 54 WebInspector.PaintProfilerSnapshot._processAnnotations = function(log) | 58 WebInspector.PaintProfilerSnapshot._processAnnotations = function(log) |
| 55 { | 59 { |
| 56 var result = []; | 60 var result = []; |
| 57 /** @type {!Array.<!Object.<string, string>>} */ | 61 /** @type {!Array.<!Object.<string, string>>} */ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 default: | 94 default: |
| 91 result.push(new WebInspector.PaintProfilerLogItem(log[i], i, comment GroupStack.peekLast())); | 95 result.push(new WebInspector.PaintProfilerLogItem(log[i], i, comment GroupStack.peekLast())); |
| 92 } | 96 } |
| 93 } | 97 } |
| 94 return result; | 98 return result; |
| 95 } | 99 } |
| 96 | 100 |
| 97 WebInspector.PaintProfilerSnapshot.prototype = { | 101 WebInspector.PaintProfilerSnapshot.prototype = { |
| 98 dispose: function() | 102 dispose: function() |
| 99 { | 103 { |
| 100 LayerTreeAgent.releaseSnapshot(this._id); | 104 this.target().layerTreeAgent().releaseSnapshot(this._id); |
| 101 }, | 105 }, |
| 102 | 106 |
| 103 /** | 107 /** |
| 104 * @param {?number} firstStep | 108 * @param {?number} firstStep |
| 105 * @param {?number} lastStep | 109 * @param {?number} lastStep |
| 106 * @param {?number} scale | 110 * @param {?number} scale |
| 107 * @param {function(string=)} callback | 111 * @param {function(string=)} callback |
| 108 */ | 112 */ |
| 109 requestImage: function(firstStep, lastStep, scale, callback) | 113 requestImage: function(firstStep, lastStep, scale, callback) |
| 110 { | 114 { |
| 111 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay erTreeAgent.replaySnapshot(): "); | 115 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay erTreeAgent.replaySnapshot(): "); |
| 112 LayerTreeAgent.replaySnapshot(this._id, firstStep || undefined, lastStep || undefined, scale || 1.0, wrappedCallback); | 116 this.target().layerTreeAgent().replaySnapshot(this._id, firstStep || und efined, lastStep || undefined, scale || 1.0, wrappedCallback); |
| 113 }, | 117 }, |
| 114 | 118 |
| 115 /** | 119 /** |
| 116 * @param {function(!Array.<!LayerTreeAgent.PaintProfile>=)} callback | 120 * @param {function(!Array.<!LayerTreeAgent.PaintProfile>=)} callback |
| 117 */ | 121 */ |
| 118 profile: function(callback) | 122 profile: function(callback) |
| 119 { | 123 { |
| 120 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay erTreeAgent.profileSnapshot(): "); | 124 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay erTreeAgent.profileSnapshot(): "); |
| 121 LayerTreeAgent.profileSnapshot(this._id, 5, 1, wrappedCallback); | 125 this.target().layerTreeAgent().profileSnapshot(this._id, 5, 1, wrappedCa llback); |
| 122 }, | 126 }, |
| 123 | 127 |
| 124 /** | 128 /** |
| 125 * @param {function(!Array.<!WebInspector.PaintProfilerLogItem>=)} callback | 129 * @param {function(!Array.<!WebInspector.PaintProfilerLogItem>=)} callback |
| 126 */ | 130 */ |
| 127 commandLog: function(callback) | 131 commandLog: function(callback) |
| 128 { | 132 { |
| 129 /** | 133 /** |
| 130 * @param {?string} error | 134 * @param {?string} error |
| 131 * @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log | 135 * @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log |
| 132 */ | 136 */ |
| 133 function callbackWrapper(error, log) | 137 function callbackWrapper(error, log) |
| 134 { | 138 { |
| 135 if (error) { | 139 if (error) { |
| 136 console.error("LayerTreeAgent.snapshotCommandLog(): " + error); | 140 console.error("LayerTreeAgent.snapshotCommandLog(): " + error); |
| 137 callback(); | 141 callback(); |
| 138 return; | 142 return; |
| 139 } | 143 } |
| 140 callback(WebInspector.PaintProfilerSnapshot._processAnnotations(log) ); | 144 callback(WebInspector.PaintProfilerSnapshot._processAnnotations(log) ); |
| 141 } | 145 } |
| 142 LayerTreeAgent.snapshotCommandLog(this._id, callbackWrapper); | 146 |
| 147 this.target().layerTreeAgent().snapshotCommandLog(this._id, callbackWrap per); | |
| 143 }, | 148 }, |
| 144 | 149 |
| 150 __proto__: WebInspector.SDKObject.prototype | |
| 145 }; | 151 }; |
| 146 | 152 |
| 147 /** | 153 /** |
| 148 * @typedef {!{method: string, params: Array.<Object.<string, *>>}} | 154 * @typedef {!{method: string, params: Array.<Object.<string, *>>}} |
| 149 */ | 155 */ |
| 150 WebInspector.RawPaintProfilerLogItem; | 156 WebInspector.RawPaintProfilerLogItem; |
| 151 | 157 |
| 152 /** | 158 /** |
| 153 * @constructor | 159 * @constructor |
| 154 * @param {!WebInspector.RawPaintProfilerLogItem} rawEntry | 160 * @param {!WebInspector.RawPaintProfilerLogItem} rawEntry |
| 155 * @param {number} commandIndex | 161 * @param {number} commandIndex |
| 156 * @param {!Object.<string, string>=} annotations | 162 * @param {!Object.<string, string>=} annotations |
| 157 */ | 163 */ |
| 158 WebInspector.PaintProfilerLogItem = function(rawEntry, commandIndex, annotations ) | 164 WebInspector.PaintProfilerLogItem = function(rawEntry, commandIndex, annotations ) |
| 159 { | 165 { |
| 160 this.method = rawEntry.method; | 166 this.method = rawEntry.method; |
| 161 this.params = rawEntry.params; | 167 this.params = rawEntry.params; |
| 162 this.annotations = annotations; | 168 this.annotations = annotations; |
| 163 this.commandIndex = commandIndex; | 169 this.commandIndex = commandIndex; |
| 164 } | 170 } |
| OLD | NEW |