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

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

Issue 2851913002: [DevTools] Do not expose agents on Target
Patch Set: storage and tests.js 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/Target.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/Target.js b/third_party/WebKit/Source/devtools/front_end/sdk/Target.js
index 914911216d0ac1b8a833666fef4cc3ef03d957b8..0ba8b7e81511d2dda9a0fd9da0ff2643fadcb316 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/Target.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/Target.js
@@ -7,24 +7,25 @@
/**
* @unrestricted
*/
-SDK.Target = class extends Protocol.TargetBase {
+SDK.Target = class {
/**
* @param {!SDK.TargetManager} targetManager
* @param {string} id
* @param {string} name
* @param {number} capabilitiesMask
- * @param {!Protocol.InspectorBackend.Connection.Factory} connectionFactory
+ * @param {!Protocol.Dispatcher} dispatcher
* @param {?SDK.Target} parentTarget
*/
- constructor(targetManager, id, name, capabilitiesMask, connectionFactory, parentTarget) {
- super(connectionFactory);
+ constructor(targetManager, id, name, capabilitiesMask, dispatcher, parentTarget) {
this._targetManager = targetManager;
this._name = name;
this._inspectedURL = '';
this._capabilitiesMask = capabilitiesMask;
+ this._dispatcher = dispatcher;
this._parentTarget = parentTarget;
this._id = id;
this._modelByConstructor = new Map();
+ this._dispatcher.setDisposeCallback(this._dispose.bind(this));
}
createModels(required) {
@@ -138,17 +139,21 @@ SDK.Target = class extends Protocol.TargetBase {
return this._parentTarget;
}
- /**
- * @override
- */
- dispose() {
+ _dispose() {
this._targetManager.removeTarget(this);
for (var model of this._modelByConstructor.valuesArray())
model.dispose();
}
/**
- * @param {function(new:T, !SDK.Target)} modelClass
+ * @return {boolean}
+ */
+ isDisposed() {
+ return this._dispatcher.isDisposed();
+ }
+
+ /**
+ * @param {function(new:T, !SDK.Target, !Protocol.Dispatcher)} modelClass
* @return {?T}
* @template T
*/
@@ -158,7 +163,7 @@ SDK.Target = class extends Protocol.TargetBase {
if (info === undefined)
throw 'Model class is not registered @' + new Error().stack;
if ((this._capabilitiesMask & info.capabilities) === info.capabilities) {
- var model = new modelClass(this);
+ var model = new modelClass(this, this._dispatcher);
this._modelByConstructor.set(modelClass, model);
if (!this._creatingModels)
this._targetManager.modelAdded(this, modelClass, model);
@@ -168,7 +173,7 @@ SDK.Target = class extends Protocol.TargetBase {
}
/**
- * @return {!Map<function(new:SDK.SDKModel, !SDK.Target), !SDK.SDKModel>}
+ * @return {!Map<function(new:SDK.SDKModel, !SDK.Target, !Protocol.Dispatcher), !SDK.SDKModel>}
*/
models() {
return this._modelByConstructor;
@@ -225,8 +230,9 @@ SDK.Target.Capability = {
SDK.SDKModel = class extends Common.Object {
/**
* @param {!SDK.Target} target
+ * @param {!Protocol.Dispatcher} dispatcher
*/
- constructor(target) {
+ constructor(target, dispatcher) {
super();
this._target = target;
}
@@ -258,7 +264,7 @@ SDK.SDKModel = class extends Common.Object {
/**
- * @param {function(new:SDK.SDKModel, !SDK.Target)} modelClass
+ * @param {function(new:SDK.SDKModel, !SDK.Target, !Protocol.Dispatcher)} modelClass
* @param {number} capabilities
* @param {boolean} autostart
*/
@@ -268,5 +274,5 @@ SDK.SDKModel.register = function(modelClass, capabilities, autostart) {
SDK.SDKModel._registeredModels.set(modelClass, {capabilities: capabilities, autostart: autostart});
};
-/** @type {!Map<function(new:SDK.SDKModel, !SDK.Target), !{capabilities: number, autostart: boolean}>} */
+/** @type {!Map<function(new:SDK.SDKModel, !SDK.Target, !Protocol.Dispatcher), !{capabilities: number, autostart: boolean}>} */
SDK.SDKModel._registeredModels;

Powered by Google App Engine
This is Rietveld 408576698