| 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 {!WeakReference.<!WebInspector.Target>} weakTarget | 33 * @param {!WebInspector.Target} target |
| 34 * @param {string} snapshotId | 34 * @param {string} snapshotId |
| 35 */ | 35 */ |
| 36 WebInspector.PaintProfilerSnapshot = function(weakTarget, snapshotId) | 36 WebInspector.PaintProfilerSnapshot = function(target, snapshotId) |
| 37 { | 37 { |
| 38 this._weakTarget = weakTarget; | 38 this._target = target; |
| 39 this._id = snapshotId; | 39 this._id = snapshotId; |
| 40 } | 40 } |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * @param {!WebInspector.Target} target | 43 * @param {!WebInspector.Target} target |
| 44 * @param {string} encodedPicture | 44 * @param {string} encodedPicture |
| 45 * @param {function(?WebInspector.PaintProfilerSnapshot)} callback | 45 * @param {function(?WebInspector.PaintProfilerSnapshot)} callback |
| 46 */ | 46 */ |
| 47 WebInspector.PaintProfilerSnapshot.load = function(target, encodedPicture, callb
ack) | 47 WebInspector.PaintProfilerSnapshot.load = function(target, encodedPicture, callb
ack) |
| 48 { | 48 { |
| 49 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTr
eeAgent.loadSnapshot(): ", WebInspector.PaintProfilerSnapshot.bind(null, target.
weakReference())); | 49 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTr
eeAgent.loadSnapshot(): ", WebInspector.PaintProfilerSnapshot.bind(null, target)
); |
| 50 target.layerTreeAgent().loadSnapshot(encodedPicture, wrappedCallback); | 50 target.layerTreeAgent().loadSnapshot(encodedPicture, wrappedCallback); |
| 51 } | 51 } |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log | 54 * @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log |
| 55 * @return {!Array.<!WebInspector.PaintProfilerLogItem>} | 55 * @return {!Array.<!WebInspector.PaintProfilerLogItem>} |
| 56 */ | 56 */ |
| 57 WebInspector.PaintProfilerSnapshot._processAnnotations = function(log) | 57 WebInspector.PaintProfilerSnapshot._processAnnotations = function(log) |
| 58 { | 58 { |
| 59 var result = []; | 59 var result = []; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 default: | 93 default: |
| 94 result.push(new WebInspector.PaintProfilerLogItem(log[i], i, comment
GroupStack.peekLast())); | 94 result.push(new WebInspector.PaintProfilerLogItem(log[i], i, comment
GroupStack.peekLast())); |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 return result; | 97 return result; |
| 98 } | 98 } |
| 99 | 99 |
| 100 WebInspector.PaintProfilerSnapshot.prototype = { | 100 WebInspector.PaintProfilerSnapshot.prototype = { |
| 101 dispose: function() | 101 dispose: function() |
| 102 { | 102 { |
| 103 var target = this._weakTarget.get(); | 103 this._target.layerTreeAgent().releaseSnapshot(this._id); |
| 104 if (target) | |
| 105 target.layerTreeAgent().releaseSnapshot(this._id); | |
| 106 }, | 104 }, |
| 107 | 105 |
| 108 /** | 106 /** |
| 109 * @return {?WebInspector.Target} | 107 * @return {!WebInspector.Target} |
| 110 */ | 108 */ |
| 111 target: function() | 109 target: function() |
| 112 { | 110 { |
| 113 return this._weakTarget.get(); | 111 return this._target; |
| 114 }, | 112 }, |
| 115 | 113 |
| 116 /** | 114 /** |
| 117 * @param {?number} firstStep | 115 * @param {?number} firstStep |
| 118 * @param {?number} lastStep | 116 * @param {?number} lastStep |
| 119 * @param {?number} scale | 117 * @param {?number} scale |
| 120 * @param {function(string=)} callback | 118 * @param {function(string=)} callback |
| 121 */ | 119 */ |
| 122 requestImage: function(firstStep, lastStep, scale, callback) | 120 requestImage: function(firstStep, lastStep, scale, callback) |
| 123 { | 121 { |
| 124 var target = this._weakTarget.get(); | |
| 125 if (!target) { | |
| 126 callback(); | |
| 127 return; | |
| 128 } | |
| 129 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay
erTreeAgent.replaySnapshot(): "); | 122 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay
erTreeAgent.replaySnapshot(): "); |
| 130 target.layerTreeAgent().replaySnapshot(this._id, firstStep || undefined,
lastStep || undefined, scale || 1.0, wrappedCallback); | 123 this._target.layerTreeAgent().replaySnapshot(this._id, firstStep || unde
fined, lastStep || undefined, scale || 1.0, wrappedCallback); |
| 131 }, | 124 }, |
| 132 | 125 |
| 133 /** | 126 /** |
| 134 * @param {function(!Array.<!LayerTreeAgent.PaintProfile>=)} callback | 127 * @param {function(!Array.<!LayerTreeAgent.PaintProfile>=)} callback |
| 135 */ | 128 */ |
| 136 profile: function(callback) | 129 profile: function(callback) |
| 137 { | 130 { |
| 138 var target = this._weakTarget.get(); | |
| 139 if (!target) { | |
| 140 callback(); | |
| 141 return; | |
| 142 } | |
| 143 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay
erTreeAgent.profileSnapshot(): "); | 131 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay
erTreeAgent.profileSnapshot(): "); |
| 144 target.layerTreeAgent().profileSnapshot(this._id, 5, 1, wrappedCallback)
; | 132 this._target.layerTreeAgent().profileSnapshot(this._id, 5, 1, wrappedCal
lback); |
| 145 }, | 133 }, |
| 146 | 134 |
| 147 /** | 135 /** |
| 148 * @param {function(!Array.<!WebInspector.PaintProfilerLogItem>=)} callback | 136 * @param {function(!Array.<!WebInspector.PaintProfilerLogItem>=)} callback |
| 149 */ | 137 */ |
| 150 commandLog: function(callback) | 138 commandLog: function(callback) |
| 151 { | 139 { |
| 152 var target = this._weakTarget.get(); | |
| 153 if (!target) { | |
| 154 callback(); | |
| 155 return; | |
| 156 } | |
| 157 /** | 140 /** |
| 158 * @param {?string} error | 141 * @param {?string} error |
| 159 * @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log | 142 * @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log |
| 160 */ | 143 */ |
| 161 function callbackWrapper(error, log) | 144 function callbackWrapper(error, log) |
| 162 { | 145 { |
| 163 if (error) { | 146 if (error) { |
| 164 console.error("LayerTreeAgent.snapshotCommandLog(): " + error); | 147 console.error("LayerTreeAgent.snapshotCommandLog(): " + error); |
| 165 callback(); | 148 callback(); |
| 166 return; | 149 return; |
| 167 } | 150 } |
| 168 callback(WebInspector.PaintProfilerSnapshot._processAnnotations(log)
); | 151 callback(WebInspector.PaintProfilerSnapshot._processAnnotations(log)
); |
| 169 } | 152 } |
| 170 | 153 |
| 171 target.layerTreeAgent().snapshotCommandLog(this._id, callbackWrapper); | 154 this._target.layerTreeAgent().snapshotCommandLog(this._id, callbackWrapp
er); |
| 172 } | 155 } |
| 173 }; | 156 }; |
| 174 | 157 |
| 175 /** | 158 /** |
| 176 * @typedef {!{method: string, params: Array.<Object.<string, *>>}} | 159 * @typedef {!{method: string, params: Array.<Object.<string, *>>}} |
| 177 */ | 160 */ |
| 178 WebInspector.RawPaintProfilerLogItem; | 161 WebInspector.RawPaintProfilerLogItem; |
| 179 | 162 |
| 180 /** | 163 /** |
| 181 * @constructor | 164 * @constructor |
| (...skipping 14 matching lines...) Expand all Loading... |
| 196 * @return {number} | 179 * @return {number} |
| 197 */ | 180 */ |
| 198 nodeId: function() | 181 nodeId: function() |
| 199 { | 182 { |
| 200 if (!this.annotations) | 183 if (!this.annotations) |
| 201 return 0; | 184 return 0; |
| 202 var inspectorId = this.annotations["INSPECTOR_ID"]; | 185 var inspectorId = this.annotations["INSPECTOR_ID"]; |
| 203 return Number(inspectorId); | 186 return Number(inspectorId); |
| 204 } | 187 } |
| 205 } | 188 } |
| OLD | NEW |