Chromium Code Reviews| 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 f79d7fb37c061e8f5b376b01133469b184d6918c..165460d1dd2e3f485ee79a3d8be45685393f927f 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sdk/Target.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/Target.js |
| @@ -34,7 +34,8 @@ WebInspector.Target = function(targetManager, name, type, connection, parentTarg |
| WebInspector.Target.Type = { |
| Page: 1, |
| DedicatedWorker: 2, |
| - ServiceWorker: 4 |
| + ServiceWorker: 4, |
| + JSInspector: 8 |
| } |
| WebInspector.Target._nextId = 1; |
| @@ -106,7 +107,7 @@ WebInspector.Target.prototype = { |
| */ |
| isWorker: function() |
| { |
| - return this.isDedicatedWorker() || this.isServiceWorker(); |
| + return this.isDedicatedWorker() || this.isServiceWorker() || this.isJSInspector(); |
| }, |
| /** |
| @@ -128,12 +129,28 @@ WebInspector.Target.prototype = { |
| /** |
| * @return {boolean} |
| */ |
| + isJSInspector: function() |
| + { |
| + return this._type === WebInspector.Target.Type.JSInspector; |
| + }, |
| + |
| + /** |
| + * @return {boolean} |
| + */ |
| hasJSContext: function() |
| { |
| return !this.isServiceWorker(); |
| }, |
| /** |
| + * @return {boolean} |
| + */ |
| + supportsWorkers: function() |
| + { |
| + return this.isPage() || this.isServiceWorker(); |
| + }, |
| + |
| + /** |
| * @return {?WebInspector.Target} |
| */ |
| parentTarget: function() |
| @@ -150,7 +167,6 @@ WebInspector.Target.prototype = { |
| _dispose: function() |
| { |
| this._targetManager.dispatchEventToListeners(WebInspector.TargetManager.Events.TargetDisposed, this); |
| - this.networkManager.dispose(); |
| this.cpuProfilerModel.dispose(); |
|
dgozman
2016/07/05 17:54:31
Are all these classes SDKModel subclasses? We shou
eostroukhov-old
2016/07/06 20:37:53
Worker manager is not a subclass... I will not be
|
| WebInspector.ServiceWorkerCacheModel.fromTarget(this).dispose(); |
| if (this.workerManager) |
| @@ -218,6 +234,7 @@ WebInspector.SDKModel = function(modelClass, target) |
| { |
| WebInspector.SDKObject.call(this, target); |
| target._modelByConstructor.set(modelClass, this); |
| + WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.TargetDisposed, this._targetDisposed, this); |
| } |
| WebInspector.SDKModel.prototype = { |
| @@ -237,5 +254,19 @@ WebInspector.SDKModel.prototype = { |
| return Promise.resolve(); |
| }, |
| + dispose: function() { }, |
| + |
| + /** |
| + * @param {!WebInspector.Event} event |
| + */ |
| + _targetDisposed: function(event) |
| + { |
| + var target = /** @type {!WebInspector.Target} */ (event.data); |
| + if (target !== this._target) |
| + return; |
| + this.dispose(); |
| + WebInspector.targetManager.removeEventListener(WebInspector.TargetManager.Events.TargetDisposed, this._targetDisposed, this); |
| + }, |
| + |
| __proto__: WebInspector.SDKObject.prototype |
| } |