| 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 * @typedef {!{x: number, y: number, picture: string}} | 31 * @typedef {!{x: number, y: number, picture: string}} |
| 32 */ | 32 */ |
| 33 WebInspector.PictureFragment; | 33 SDK.PictureFragment; |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * @unrestricted | 36 * @unrestricted |
| 37 */ | 37 */ |
| 38 WebInspector.PaintProfilerSnapshot = class { | 38 SDK.PaintProfilerSnapshot = class { |
| 39 /** | 39 /** |
| 40 * @param {!WebInspector.Target} target | 40 * @param {!SDK.Target} target |
| 41 * @param {string} snapshotId | 41 * @param {string} snapshotId |
| 42 */ | 42 */ |
| 43 constructor(target, snapshotId) { | 43 constructor(target, snapshotId) { |
| 44 this._target = target; | 44 this._target = target; |
| 45 this._id = snapshotId; | 45 this._id = snapshotId; |
| 46 this._refCount = 1; | 46 this._refCount = 1; |
| 47 } | 47 } |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * @param {!WebInspector.Target} target | 50 * @param {!SDK.Target} target |
| 51 * @param {!Array.<!WebInspector.PictureFragment>} fragments | 51 * @param {!Array.<!SDK.PictureFragment>} fragments |
| 52 * @return {!Promise<?WebInspector.PaintProfilerSnapshot>} | 52 * @return {!Promise<?SDK.PaintProfilerSnapshot>} |
| 53 */ | 53 */ |
| 54 static loadFromFragments(target, fragments) { | 54 static loadFromFragments(target, fragments) { |
| 55 return target.layerTreeAgent().loadSnapshot( | 55 return target.layerTreeAgent().loadSnapshot( |
| 56 fragments, (error, snapshotId) => error ? null : new WebInspector.PaintP
rofilerSnapshot(target, snapshotId)); | 56 fragments, (error, snapshotId) => error ? null : new SDK.PaintProfilerSn
apshot(target, snapshotId)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * @param {!WebInspector.Target} target | 60 * @param {!SDK.Target} target |
| 61 * @param {string} encodedPicture | 61 * @param {string} encodedPicture |
| 62 * @return {!Promise<?WebInspector.PaintProfilerSnapshot>} | 62 * @return {!Promise<?SDK.PaintProfilerSnapshot>} |
| 63 */ | 63 */ |
| 64 static load(target, encodedPicture) { | 64 static load(target, encodedPicture) { |
| 65 var fragment = {x: 0, y: 0, picture: encodedPicture}; | 65 var fragment = {x: 0, y: 0, picture: encodedPicture}; |
| 66 return WebInspector.PaintProfilerSnapshot.loadFromFragments(target, [fragmen
t]); | 66 return SDK.PaintProfilerSnapshot.loadFromFragments(target, [fragment]); |
| 67 } | 67 } |
| 68 | 68 |
| 69 release() { | 69 release() { |
| 70 console.assert(this._refCount > 0, 'release is already called on the object'
); | 70 console.assert(this._refCount > 0, 'release is already called on the object'
); |
| 71 if (!--this._refCount) | 71 if (!--this._refCount) |
| 72 this._target.layerTreeAgent().releaseSnapshot(this._id); | 72 this._target.layerTreeAgent().releaseSnapshot(this._id); |
| 73 } | 73 } |
| 74 | 74 |
| 75 addReference() { | 75 addReference() { |
| 76 ++this._refCount; | 76 ++this._refCount; |
| 77 console.assert(this._refCount > 0, 'Referencing a dead object'); | 77 console.assert(this._refCount > 0, 'Referencing a dead object'); |
| 78 } | 78 } |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * @return {!WebInspector.Target} | 81 * @return {!SDK.Target} |
| 82 */ | 82 */ |
| 83 target() { | 83 target() { |
| 84 return this._target; | 84 return this._target; |
| 85 } | 85 } |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * @param {?number} firstStep | 88 * @param {?number} firstStep |
| 89 * @param {?number} lastStep | 89 * @param {?number} lastStep |
| 90 * @param {?number} scale | 90 * @param {?number} scale |
| 91 * @return {!Promise<?string>} | 91 * @return {!Promise<?string>} |
| 92 */ | 92 */ |
| 93 replay(firstStep, lastStep, scale) { | 93 replay(firstStep, lastStep, scale) { |
| 94 return this._target.layerTreeAgent().replaySnapshot( | 94 return this._target.layerTreeAgent().replaySnapshot( |
| 95 this._id, firstStep || undefined, lastStep || undefined, scale || 1.0, (
error, str) => error ? null : str); | 95 this._id, firstStep || undefined, lastStep || undefined, scale || 1.0, (
error, str) => error ? null : str); |
| 96 } | 96 } |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * @param {?Protocol.DOM.Rect} clipRect | 99 * @param {?Protocol.DOM.Rect} clipRect |
| 100 * @param {function(!Array.<!Protocol.LayerTree.PaintProfile>=)} callback | 100 * @param {function(!Array.<!Protocol.LayerTree.PaintProfile>=)} callback |
| 101 */ | 101 */ |
| 102 profile(clipRect, callback) { | 102 profile(clipRect, callback) { |
| 103 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, 'Protoco
l.LayerTree.profileSnapshot(): '); | 103 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, 'Protoco
l.LayerTree.profileSnapshot(): '); |
| 104 this._target.layerTreeAgent().profileSnapshot(this._id, 5, 1, clipRect || un
defined, wrappedCallback); | 104 this._target.layerTreeAgent().profileSnapshot(this._id, 5, 1, clipRect || un
defined, wrappedCallback); |
| 105 } | 105 } |
| 106 | 106 |
| 107 /** | 107 /** |
| 108 * @return {!Promise<?Array<!WebInspector.PaintProfilerLogItem>>} | 108 * @return {!Promise<?Array<!SDK.PaintProfilerLogItem>>} |
| 109 */ | 109 */ |
| 110 commandLog() { | 110 commandLog() { |
| 111 return this._target.layerTreeAgent().snapshotCommandLog(this._id, processLog
); | 111 return this._target.layerTreeAgent().snapshotCommandLog(this._id, processLog
); |
| 112 | 112 |
| 113 /** | 113 /** |
| 114 * @param {?string} error | 114 * @param {?string} error |
| 115 * @param {?Array<!Object>} log | 115 * @param {?Array<!Object>} log |
| 116 */ | 116 */ |
| 117 function processLog(error, log) { | 117 function processLog(error, log) { |
| 118 if (error) | 118 if (error) |
| 119 return null; | 119 return null; |
| 120 return log.map( | 120 return log.map( |
| 121 (entry, index) => new WebInspector.PaintProfilerLogItem( | 121 (entry, index) => new SDK.PaintProfilerLogItem( |
| 122 /** @type {!WebInspector.RawPaintProfilerLogItem} */ (entry), inde
x)); | 122 /** @type {!SDK.RawPaintProfilerLogItem} */ (entry), index)); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * @typedef {!{method: string, params: ?Object<string, *>}} | 129 * @typedef {!{method: string, params: ?Object<string, *>}} |
| 130 */ | 130 */ |
| 131 WebInspector.RawPaintProfilerLogItem; | 131 SDK.RawPaintProfilerLogItem; |
| 132 | 132 |
| 133 /** | 133 /** |
| 134 * @unrestricted | 134 * @unrestricted |
| 135 */ | 135 */ |
| 136 WebInspector.PaintProfilerLogItem = class { | 136 SDK.PaintProfilerLogItem = class { |
| 137 /** | 137 /** |
| 138 * @param {!WebInspector.RawPaintProfilerLogItem} rawEntry | 138 * @param {!SDK.RawPaintProfilerLogItem} rawEntry |
| 139 * @param {number} commandIndex | 139 * @param {number} commandIndex |
| 140 */ | 140 */ |
| 141 constructor(rawEntry, commandIndex) { | 141 constructor(rawEntry, commandIndex) { |
| 142 this.method = rawEntry.method; | 142 this.method = rawEntry.method; |
| 143 this.params = rawEntry.params; | 143 this.params = rawEntry.params; |
| 144 this.commandIndex = commandIndex; | 144 this.commandIndex = commandIndex; |
| 145 } | 145 } |
| 146 }; | 146 }; |
| OLD | NEW |