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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/sdk/PaintProfiler.js
diff --git a/Source/devtools/front_end/sdk/PaintProfiler.js b/Source/devtools/front_end/sdk/PaintProfiler.js
index 95d41b2eea1e4a485379a5b206c60d944f51e528..f035bf103b426ed74f72a559e8a74aba0936dce0 100644
--- a/Source/devtools/front_end/sdk/PaintProfiler.js
+++ b/Source/devtools/front_end/sdk/PaintProfiler.js
@@ -30,21 +30,24 @@
/**
* @constructor
+ * @param {!WeakReference.<!WebInspector.Target>} weakTarget
* @param {string} snapshotId
*/
-WebInspector.PaintProfilerSnapshot = function(snapshotId)
+WebInspector.PaintProfilerSnapshot = function(weakTarget, snapshotId)
{
+ this._weakTarget = weakTarget;
this._id = snapshotId;
}
/**
+ * @param {!WebInspector.Target} target
* @param {string} encodedPicture
* @param {function(?WebInspector.PaintProfilerSnapshot)} callback
*/
-WebInspector.PaintProfilerSnapshot.load = function(encodedPicture, callback)
+WebInspector.PaintProfilerSnapshot.load = function(target, encodedPicture, callback)
{
- var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTreeAgent.loadSnapshot(): ", WebInspector.PaintProfilerSnapshot);
- LayerTreeAgent.loadSnapshot(encodedPicture, wrappedCallback);
+ var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTreeAgent.loadSnapshot(): ", WebInspector.PaintProfilerSnapshot.bind(null, target.weakReference()));
+ target.layerTreeAgent().loadSnapshot(encodedPicture, wrappedCallback);
}
/**
@@ -97,7 +100,9 @@ WebInspector.PaintProfilerSnapshot._processAnnotations = function(log)
WebInspector.PaintProfilerSnapshot.prototype = {
dispose: function()
{
- LayerTreeAgent.releaseSnapshot(this._id);
+ var target = this._weakTarget.get();
+ if (target)
+ target.layerTreeAgent().releaseSnapshot(this._id);
},
/**
@@ -108,8 +113,13 @@ WebInspector.PaintProfilerSnapshot.prototype = {
*/
requestImage: function(firstStep, lastStep, scale, callback)
{
+ var target = this._weakTarget.get();
+ if (!target) {
+ callback();
+ return;
+ }
var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTreeAgent.replaySnapshot(): ");
- LayerTreeAgent.replaySnapshot(this._id, firstStep || undefined, lastStep || undefined, scale || 1.0, wrappedCallback);
+ target.layerTreeAgent().replaySnapshot(this._id, firstStep || undefined, lastStep || undefined, scale || 1.0, wrappedCallback);
},
/**
@@ -117,8 +127,13 @@ WebInspector.PaintProfilerSnapshot.prototype = {
*/
profile: function(callback)
{
+ var target = this._weakTarget.get();
+ if (!target) {
+ callback();
+ return;
+ }
var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTreeAgent.profileSnapshot(): ");
- LayerTreeAgent.profileSnapshot(this._id, 5, 1, wrappedCallback);
+ target.layerTreeAgent().profileSnapshot(this._id, 5, 1, wrappedCallback);
},
/**
@@ -126,6 +141,11 @@ WebInspector.PaintProfilerSnapshot.prototype = {
*/
commandLog: function(callback)
{
+ var target = this._weakTarget.get();
+ if (!target) {
+ callback();
+ return;
+ }
/**
* @param {?string} error
* @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log
@@ -139,9 +159,9 @@ WebInspector.PaintProfilerSnapshot.prototype = {
}
callback(WebInspector.PaintProfilerSnapshot._processAnnotations(log));
}
- LayerTreeAgent.snapshotCommandLog(this._id, callbackWrapper);
- },
+ target.layerTreeAgent().snapshotCommandLog(this._id, callbackWrapper);
+ }
};
/**
« 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