Chromium Code Reviews| 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(); | 170 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
| |
| 155 WebInspector.ServiceWorkerCacheModel.fromTarget(this).dispose(); | 171 WebInspector.ServiceWorkerCacheModel.fromTarget(this).dispose(); |
| 156 if (this.workerManager) | 172 if (this.workerManager) |
| 157 this.workerManager.dispose(); | 173 this.workerManager.dispose(); |
| 158 }, | 174 }, |
| 159 | 175 |
| 160 /** | 176 /** |
| 161 * @return {boolean} | 177 * @return {boolean} |
| 162 */ | 178 */ |
| 163 isDetached: function() | 179 isDetached: function() |
| 164 { | 180 { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 /** | 227 /** |
| 212 * @constructor | 228 * @constructor |
| 213 * @extends {WebInspector.SDKObject} | 229 * @extends {WebInspector.SDKObject} |
| 214 * @param {!Function} modelClass | 230 * @param {!Function} modelClass |
| 215 * @param {!WebInspector.Target} target | 231 * @param {!WebInspector.Target} target |
| 216 */ | 232 */ |
| 217 WebInspector.SDKModel = function(modelClass, target) | 233 WebInspector.SDKModel = function(modelClass, target) |
| 218 { | 234 { |
| 219 WebInspector.SDKObject.call(this, target); | 235 WebInspector.SDKObject.call(this, target); |
| 220 target._modelByConstructor.set(modelClass, this); | 236 target._modelByConstructor.set(modelClass, this); |
| 237 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.TargetDisposed, this._targetDisposed, this); | |
| 221 } | 238 } |
| 222 | 239 |
| 223 WebInspector.SDKModel.prototype = { | 240 WebInspector.SDKModel.prototype = { |
| 224 /** | 241 /** |
| 225 * @return {!Promise} | 242 * @return {!Promise} |
| 226 */ | 243 */ |
| 227 suspendModel: function() | 244 suspendModel: function() |
| 228 { | 245 { |
| 229 return Promise.resolve(); | 246 return Promise.resolve(); |
| 230 }, | 247 }, |
| 231 | 248 |
| 232 /** | 249 /** |
| 233 * @return {!Promise} | 250 * @return {!Promise} |
| 234 */ | 251 */ |
| 235 resumeModel: function() | 252 resumeModel: function() |
| 236 { | 253 { |
| 237 return Promise.resolve(); | 254 return Promise.resolve(); |
| 238 }, | 255 }, |
| 239 | 256 |
| 257 dispose: function() { }, | |
| 258 | |
| 259 /** | |
| 260 * @param {!WebInspector.Event} event | |
| 261 */ | |
| 262 _targetDisposed: function(event) | |
| 263 { | |
| 264 var target = /** @type {!WebInspector.Target} */ (event.data); | |
| 265 if (target !== this._target) | |
| 266 return; | |
| 267 this.dispose(); | |
| 268 WebInspector.targetManager.removeEventListener(WebInspector.TargetManage r.Events.TargetDisposed, this._targetDisposed, this); | |
| 269 }, | |
| 270 | |
| 240 __proto__: WebInspector.SDKObject.prototype | 271 __proto__: WebInspector.SDKObject.prototype |
| 241 } | 272 } |
| OLD | NEW |