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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/PaintProfiler.js

Issue 2845813003: [DevTools] Host paint profiles in PaintProfilerModel (Closed)
Patch Set: addressed comments Created 3 years, 8 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
Index: third_party/WebKit/Source/devtools/front_end/sdk/PaintProfiler.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/PaintProfiler.js b/third_party/WebKit/Source/devtools/front_end/sdk/PaintProfiler.js
index 6f07ce28b9ff5d22807624d4a3002508892f4994..058e3e1811415a62fbf48f1731d4202db85f03d1 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/PaintProfiler.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/PaintProfiler.js
@@ -27,49 +27,66 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/**
- * @typedef {!{x: number, y: number, picture: string}}
- */
-SDK.PictureFragment;
-/**
- * @unrestricted
- */
-SDK.PaintProfilerSnapshot = class {
+SDK.PaintProfilerModel = class extends SDK.SDKModel {
/**
* @param {!SDK.Target} target
- * @param {string} snapshotId
*/
- constructor(target, snapshotId) {
- this._target = target;
- this._id = snapshotId;
- this._refCount = 1;
+ constructor(target) {
+ super(target);
+ this._layerTreeAgent = target.layerTreeAgent();
}
/**
- * @param {!SDK.Target} target
* @param {!Array.<!SDK.PictureFragment>} fragments
* @return {!Promise<?SDK.PaintProfilerSnapshot>}
*/
- static loadFromFragments(target, fragments) {
- return target.layerTreeAgent().loadSnapshot(
- fragments, (error, snapshotId) => error ? null : new SDK.PaintProfilerSnapshot(target, snapshotId));
+ loadSnapshotFromFragments(fragments) {
+ return this._layerTreeAgent.loadSnapshot(
+ fragments, (error, snapshotId) => error ? null : new SDK.PaintProfilerSnapshot(this, snapshotId));
}
/**
- * @param {!SDK.Target} target
* @param {string} encodedPicture
* @return {!Promise<?SDK.PaintProfilerSnapshot>}
*/
- static load(target, encodedPicture) {
+ loadSnapshot(encodedPicture) {
var fragment = {x: 0, y: 0, picture: encodedPicture};
- return SDK.PaintProfilerSnapshot.loadFromFragments(target, [fragment]);
+ return this.loadSnapshotFromFragments([fragment]);
+ }
+
+ /**
+ * @param {string} layerId
+ * @return {!Promise<?SDK.PaintProfilerSnapshot>}
+ */
+ makeSnapshot(layerId) {
+ return this._layerTreeAgent.makeSnapshot(
+ layerId, (error, snapshotId) => error ? null : new SDK.PaintProfilerSnapshot(this, snapshotId));
+ }
+};
+
+SDK.SDKModel.register(SDK.PaintProfilerModel, SDK.Target.Capability.DOM, false);
+
+/**
+ * @typedef {!{x: number, y: number, picture: string}}
+ */
+SDK.PictureFragment;
+
+SDK.PaintProfilerSnapshot = class {
+ /**
+ * @param {!SDK.PaintProfilerModel} paintProfilerModel
+ * @param {string} snapshotId
+ */
+ constructor(paintProfilerModel, snapshotId) {
+ this._paintProfilerModel = paintProfilerModel;
+ this._id = snapshotId;
+ this._refCount = 1;
}
release() {
console.assert(this._refCount > 0, 'release is already called on the object');
if (!--this._refCount)
- this._target.layerTreeAgent().releaseSnapshot(this._id);
+ this._paintProfilerModel._layerTreeAgent.releaseSnapshot(this._id);
}
addReference() {
@@ -78,20 +95,13 @@ SDK.PaintProfilerSnapshot = class {
}
/**
- * @return {!SDK.Target}
- */
- target() {
- return this._target;
- }
-
- /**
* @param {?number} firstStep
* @param {?number} lastStep
* @param {?number} scale
* @return {!Promise<?string>}
*/
replay(firstStep, lastStep, scale) {
- return this._target.layerTreeAgent().replaySnapshot(
+ return this._paintProfilerModel._layerTreeAgent.replaySnapshot(
this._id, firstStep || undefined, lastStep || undefined, scale || 1.0, (error, str) => error ? null : str);
}
@@ -102,14 +112,14 @@ SDK.PaintProfilerSnapshot = class {
profile(clipRect, callback) {
var wrappedCallback =
Protocol.inspectorBackend.wrapClientCallback(callback, 'Protocol.LayerTree.profileSnapshot(): ');
- this._target.layerTreeAgent().profileSnapshot(this._id, 5, 1, clipRect || undefined, wrappedCallback);
+ this._paintProfilerModel._layerTreeAgent.profileSnapshot(this._id, 5, 1, clipRect || undefined, wrappedCallback);
}
/**
* @return {!Promise<?Array<!SDK.PaintProfilerLogItem>>}
*/
commandLog() {
- return this._target.layerTreeAgent().snapshotCommandLog(this._id, processLog);
+ return this._paintProfilerModel._layerTreeAgent.snapshotCommandLog(this._id, processLog);
/**
* @param {?string} error
@@ -125,7 +135,6 @@ SDK.PaintProfilerSnapshot = class {
}
};
-
/**
* @typedef {!{method: string, params: ?Object<string, *>}}
*/

Powered by Google App Engine
This is Rietveld 408576698