Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: Source/devtools/front_end/sdk/PaintProfiler.js

Issue 389563002: DevTools: make paint profiler target-aware (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixed a test and a stray line Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 {string} snapshotId 34 * @param {string} snapshotId
34 */ 35 */
35 WebInspector.PaintProfilerSnapshot = function(snapshotId) 36 WebInspector.PaintProfilerSnapshot = function(weakTarget, snapshotId)
36 { 37 {
38 this._weakTarget = weakTarget;
37 this._id = snapshotId; 39 this._id = snapshotId;
38 } 40 }
39 41
40 /** 42 /**
43 * @param {!WebInspector.Target} target
41 * @param {string} encodedPicture 44 * @param {string} encodedPicture
42 * @param {function(?WebInspector.PaintProfilerSnapshot)} callback 45 * @param {function(?WebInspector.PaintProfilerSnapshot)} callback
43 */ 46 */
44 WebInspector.PaintProfilerSnapshot.load = function(encodedPicture, callback) 47 WebInspector.PaintProfilerSnapshot.load = function(target, encodedPicture, callb ack)
45 { 48 {
46 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTr eeAgent.loadSnapshot(): ", WebInspector.PaintProfilerSnapshot); 49 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTr eeAgent.loadSnapshot(): ", WebInspector.PaintProfilerSnapshot.bind(null, target. weakReference()));
47 LayerTreeAgent.loadSnapshot(encodedPicture, wrappedCallback); 50 target.layerTreeAgent().loadSnapshot(encodedPicture, wrappedCallback);
48 } 51 }
49 52
50 /** 53 /**
51 * @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log 54 * @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log
52 * @return {!Array.<!WebInspector.PaintProfilerLogItem>} 55 * @return {!Array.<!WebInspector.PaintProfilerLogItem>}
53 */ 56 */
54 WebInspector.PaintProfilerSnapshot._processAnnotations = function(log) 57 WebInspector.PaintProfilerSnapshot._processAnnotations = function(log)
55 { 58 {
56 var result = []; 59 var result = [];
57 /** @type {!Array.<!Object.<string, string>>} */ 60 /** @type {!Array.<!Object.<string, string>>} */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 default: 93 default:
91 result.push(new WebInspector.PaintProfilerLogItem(log[i], i, comment GroupStack.peekLast())); 94 result.push(new WebInspector.PaintProfilerLogItem(log[i], i, comment GroupStack.peekLast()));
92 } 95 }
93 } 96 }
94 return result; 97 return result;
95 } 98 }
96 99
97 WebInspector.PaintProfilerSnapshot.prototype = { 100 WebInspector.PaintProfilerSnapshot.prototype = {
98 dispose: function() 101 dispose: function()
99 { 102 {
100 LayerTreeAgent.releaseSnapshot(this._id); 103 var target = this._weakTarget.get();
104 if (target)
105 target.layerTreeAgent().releaseSnapshot(this._id);
101 }, 106 },
102 107
103 /** 108 /**
104 * @param {?number} firstStep 109 * @param {?number} firstStep
105 * @param {?number} lastStep 110 * @param {?number} lastStep
106 * @param {?number} scale 111 * @param {?number} scale
107 * @param {function(string=)} callback 112 * @param {function(string=)} callback
108 */ 113 */
109 requestImage: function(firstStep, lastStep, scale, callback) 114 requestImage: function(firstStep, lastStep, scale, callback)
110 { 115 {
116 var target = this._weakTarget.get();
117 if (!target) {
118 callback();
119 return;
120 }
111 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay erTreeAgent.replaySnapshot(): "); 121 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay erTreeAgent.replaySnapshot(): ");
112 LayerTreeAgent.replaySnapshot(this._id, firstStep || undefined, lastStep || undefined, scale || 1.0, wrappedCallback); 122 target.layerTreeAgent().replaySnapshot(this._id, firstStep || undefined, lastStep || undefined, scale || 1.0, wrappedCallback);
113 }, 123 },
114 124
115 /** 125 /**
116 * @param {function(!Array.<!LayerTreeAgent.PaintProfile>=)} callback 126 * @param {function(!Array.<!LayerTreeAgent.PaintProfile>=)} callback
117 */ 127 */
118 profile: function(callback) 128 profile: function(callback)
119 { 129 {
130 var target = this._weakTarget.get();
131 if (!target) {
132 callback();
133 return;
134 }
120 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay erTreeAgent.profileSnapshot(): "); 135 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay erTreeAgent.profileSnapshot(): ");
121 LayerTreeAgent.profileSnapshot(this._id, 5, 1, wrappedCallback); 136 target.layerTreeAgent().profileSnapshot(this._id, 5, 1, wrappedCallback) ;
122 }, 137 },
123 138
124 /** 139 /**
125 * @param {function(!Array.<!WebInspector.PaintProfilerLogItem>=)} callback 140 * @param {function(!Array.<!WebInspector.PaintProfilerLogItem>=)} callback
126 */ 141 */
127 commandLog: function(callback) 142 commandLog: function(callback)
128 { 143 {
144 var target = this._weakTarget.get();
145 if (!target) {
146 callback();
147 return;
148 }
129 /** 149 /**
130 * @param {?string} error 150 * @param {?string} error
131 * @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log 151 * @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log
132 */ 152 */
133 function callbackWrapper(error, log) 153 function callbackWrapper(error, log)
134 { 154 {
135 if (error) { 155 if (error) {
136 console.error("LayerTreeAgent.snapshotCommandLog(): " + error); 156 console.error("LayerTreeAgent.snapshotCommandLog(): " + error);
137 callback(); 157 callback();
138 return; 158 return;
139 } 159 }
140 callback(WebInspector.PaintProfilerSnapshot._processAnnotations(log) ); 160 callback(WebInspector.PaintProfilerSnapshot._processAnnotations(log) );
141 } 161 }
142 LayerTreeAgent.snapshotCommandLog(this._id, callbackWrapper);
143 },
144 162
163 target.layerTreeAgent().snapshotCommandLog(this._id, callbackWrapper);
164 }
145 }; 165 };
146 166
147 /** 167 /**
148 * @typedef {!{method: string, params: Array.<Object.<string, *>>}} 168 * @typedef {!{method: string, params: Array.<Object.<string, *>>}}
149 */ 169 */
150 WebInspector.RawPaintProfilerLogItem; 170 WebInspector.RawPaintProfilerLogItem;
151 171
152 /** 172 /**
153 * @constructor 173 * @constructor
154 * @param {!WebInspector.RawPaintProfilerLogItem} rawEntry 174 * @param {!WebInspector.RawPaintProfilerLogItem} rawEntry
155 * @param {number} commandIndex 175 * @param {number} commandIndex
156 * @param {!Object.<string, string>=} annotations 176 * @param {!Object.<string, string>=} annotations
157 */ 177 */
158 WebInspector.PaintProfilerLogItem = function(rawEntry, commandIndex, annotations ) 178 WebInspector.PaintProfilerLogItem = function(rawEntry, commandIndex, annotations )
159 { 179 {
160 this.method = rawEntry.method; 180 this.method = rawEntry.method;
161 this.params = rawEntry.params; 181 this.params = rawEntry.params;
162 this.annotations = annotations; 182 this.annotations = annotations;
163 this.commandIndex = commandIndex; 183 this.commandIndex = commandIndex;
164 } 184 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/sdk/LayerTreeModel.js ('k') | Source/devtools/front_end/sdk/Target.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698