| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @constructor | 8 * @constructor |
| 9 * @extends {Protocol.Agents} | 9 * @extends {Protocol.Agents} |
| 10 * @param {!WebInspector.TargetManager} targetManager | 10 * @param {!WebInspector.TargetManager} targetManager |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 /** @type {!Map.<!Function, !WebInspector.SDKModel>} */ | 27 /** @type {!Map.<!Function, !WebInspector.SDKModel>} */ |
| 28 this._modelByConstructor = new Map(); | 28 this._modelByConstructor = new Map(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @enum {number} | 32 * @enum {number} |
| 33 */ | 33 */ |
| 34 WebInspector.Target.Type = { | 34 WebInspector.Target.Type = { |
| 35 Page: 1, | 35 Page: 1, |
| 36 DedicatedWorker: 2, | 36 DedicatedWorker: 2, |
| 37 ServiceWorker: 4 | 37 ServiceWorker: 4, |
| 38 JSInspector: 8 |
| 38 } | 39 } |
| 39 | 40 |
| 40 WebInspector.Target._nextId = 1; | 41 WebInspector.Target._nextId = 1; |
| 41 | 42 |
| 42 WebInspector.Target.prototype = { | 43 WebInspector.Target.prototype = { |
| 43 /** | 44 /** |
| 44 * @return {number} | 45 * @return {number} |
| 45 */ | 46 */ |
| 46 id: function() | 47 id: function() |
| 47 { | 48 { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 isPage: function() | 100 isPage: function() |
| 100 { | 101 { |
| 101 return this._type === WebInspector.Target.Type.Page; | 102 return this._type === WebInspector.Target.Type.Page; |
| 102 }, | 103 }, |
| 103 | 104 |
| 104 /** | 105 /** |
| 105 * @return {boolean} | 106 * @return {boolean} |
| 106 */ | 107 */ |
| 107 isWorker: function() | 108 isWorker: function() |
| 108 { | 109 { |
| 109 return this.isDedicatedWorker() || this.isServiceWorker(); | 110 return this.isDedicatedWorker() || this.isServiceWorker() || this.isJSIn
spector(); |
| 110 }, | 111 }, |
| 111 | 112 |
| 112 /** | 113 /** |
| 113 * @return {boolean} | 114 * @return {boolean} |
| 114 */ | 115 */ |
| 115 isDedicatedWorker: function() | 116 isDedicatedWorker: function() |
| 116 { | 117 { |
| 117 return this._type === WebInspector.Target.Type.DedicatedWorker; | 118 return this._type === WebInspector.Target.Type.DedicatedWorker; |
| 118 }, | 119 }, |
| 119 | 120 |
| 120 /** | 121 /** |
| 121 * @return {boolean} | 122 * @return {boolean} |
| 122 */ | 123 */ |
| 123 isServiceWorker: function() | 124 isServiceWorker: function() |
| 124 { | 125 { |
| 125 return this._type === WebInspector.Target.Type.ServiceWorker; | 126 return this._type === WebInspector.Target.Type.ServiceWorker; |
| 126 }, | 127 }, |
| 127 | 128 |
| 128 /** | 129 /** |
| 129 * @return {boolean} | 130 * @return {boolean} |
| 130 */ | 131 */ |
| 132 isJSInspector: function() |
| 133 { |
| 134 return this._type === WebInspector.Target.Type.JSInspector; |
| 135 }, |
| 136 |
| 137 /** |
| 138 * @return {boolean} |
| 139 */ |
| 131 hasJSContext: function() | 140 hasJSContext: function() |
| 132 { | 141 { |
| 133 return !this.isServiceWorker(); | 142 return !this.isServiceWorker(); |
| 134 }, | 143 }, |
| 135 | 144 |
| 136 /** | 145 /** |
| 146 * @return {boolean} |
| 147 */ |
| 148 supportsWorkers: function() |
| 149 { |
| 150 return this.isPage() || this.isServiceWorker(); |
| 151 }, |
| 152 |
| 153 /** |
| 137 * @return {?WebInspector.Target} | 154 * @return {?WebInspector.Target} |
| 138 */ | 155 */ |
| 139 parentTarget: function() | 156 parentTarget: function() |
| 140 { | 157 { |
| 141 return this._parentTarget; | 158 return this._parentTarget; |
| 142 }, | 159 }, |
| 143 | 160 |
| 144 _onDisconnect: function() | 161 _onDisconnect: function() |
| 145 { | 162 { |
| 146 this._targetManager.removeTarget(this); | 163 this._targetManager.removeTarget(this); |
| 147 this._dispose(); | 164 this._dispose(); |
| 148 }, | 165 }, |
| 149 | 166 |
| 150 _dispose: function() | 167 _dispose: function() |
| 151 { | 168 { |
| 152 this._targetManager.dispatchEventToListeners(WebInspector.TargetManager.
Events.TargetDisposed, this); | 169 this._targetManager.dispatchEventToListeners(WebInspector.TargetManager.
Events.TargetDisposed, this); |
| 153 this.networkManager.dispose(); | |
| 154 this.cpuProfilerModel.dispose(); | |
| 155 WebInspector.ServiceWorkerCacheModel.fromTarget(this).dispose(); | |
| 156 if (this.workerManager) | 170 if (this.workerManager) |
| 157 this.workerManager.dispose(); | 171 this.workerManager.dispose(); |
| 158 }, | 172 }, |
| 159 | 173 |
| 160 /** | 174 /** |
| 161 * @return {boolean} | 175 * @return {boolean} |
| 162 */ | 176 */ |
| 163 isDetached: function() | 177 isDetached: function() |
| 164 { | 178 { |
| 165 return this._connection.isClosed(); | 179 return this._connection.isClosed(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 /** | 225 /** |
| 212 * @constructor | 226 * @constructor |
| 213 * @extends {WebInspector.SDKObject} | 227 * @extends {WebInspector.SDKObject} |
| 214 * @param {!Function} modelClass | 228 * @param {!Function} modelClass |
| 215 * @param {!WebInspector.Target} target | 229 * @param {!WebInspector.Target} target |
| 216 */ | 230 */ |
| 217 WebInspector.SDKModel = function(modelClass, target) | 231 WebInspector.SDKModel = function(modelClass, target) |
| 218 { | 232 { |
| 219 WebInspector.SDKObject.call(this, target); | 233 WebInspector.SDKObject.call(this, target); |
| 220 target._modelByConstructor.set(modelClass, this); | 234 target._modelByConstructor.set(modelClass, this); |
| 235 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event
s.TargetDisposed, this._targetDisposed, this); |
| 221 } | 236 } |
| 222 | 237 |
| 223 WebInspector.SDKModel.prototype = { | 238 WebInspector.SDKModel.prototype = { |
| 224 /** | 239 /** |
| 225 * @return {!Promise} | 240 * @return {!Promise} |
| 226 */ | 241 */ |
| 227 suspendModel: function() | 242 suspendModel: function() |
| 228 { | 243 { |
| 229 return Promise.resolve(); | 244 return Promise.resolve(); |
| 230 }, | 245 }, |
| 231 | 246 |
| 232 /** | 247 /** |
| 233 * @return {!Promise} | 248 * @return {!Promise} |
| 234 */ | 249 */ |
| 235 resumeModel: function() | 250 resumeModel: function() |
| 236 { | 251 { |
| 237 return Promise.resolve(); | 252 return Promise.resolve(); |
| 238 }, | 253 }, |
| 239 | 254 |
| 255 dispose: function() { }, |
| 256 |
| 257 /** |
| 258 * @param {!WebInspector.Event} event |
| 259 */ |
| 260 _targetDisposed: function(event) |
| 261 { |
| 262 var target = /** @type {!WebInspector.Target} */ (event.data); |
| 263 if (target !== this._target) |
| 264 return; |
| 265 this.dispose(); |
| 266 WebInspector.targetManager.removeEventListener(WebInspector.TargetManage
r.Events.TargetDisposed, this._targetDisposed, this); |
| 267 }, |
| 268 |
| 240 __proto__: WebInspector.SDKObject.prototype | 269 __proto__: WebInspector.SDKObject.prototype |
| 241 } | 270 } |
| OLD | NEW |