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

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

Issue 2421913003: DevTools: allow reattaching main target live. (Closed)
Patch Set: link fixed Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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
11 * @param {string} name 11 * @param {string} name
12 * @param {number} capabilitiesMask 12 * @param {number} capabilitiesMask
13 * @param {!InspectorBackendClass.Connection} connection 13 * @param {!InspectorBackendClass.Connection} connection
14 * @param {?WebInspector.Target} parentTarget 14 * @param {?WebInspector.Target} parentTarget
15 */ 15 */
16 WebInspector.Target = function(targetManager, name, capabilitiesMask, connection , parentTarget) 16 WebInspector.Target = function(targetManager, name, capabilitiesMask, connection , parentTarget)
17 { 17 {
18 Protocol.Agents.call(this, connection.agentsMap()); 18 Protocol.Agents.call(this, connection.agentsMap());
19 this._targetManager = targetManager; 19 this._targetManager = targetManager;
20 this._name = name; 20 this._name = name;
21 this._inspectedURL = ""; 21 this._inspectedURL = "";
22 this._capabilitiesMask = capabilitiesMask; 22 this._capabilitiesMask = capabilitiesMask;
23 this._connection = connection; 23 this._connection = connection;
24 this._parentTarget = parentTarget; 24 this._parentTarget = parentTarget;
25 connection.addEventListener(InspectorBackendClass.Connection.Events.Disconne cted, this._onDisconnect, this); 25 connection.addEventListener(InspectorBackendClass.Connection.Events.Disconne cted, this.dispose, this);
26 this._id = WebInspector.Target._nextId++; 26 this._id = WebInspector.Target._nextId++;
27 27
28 /** @type {!Map.<!Function, !WebInspector.SDKModel>} */ 28 /** @type {!Map.<!Function, !WebInspector.SDKModel>} */
29 this._modelByConstructor = new Map(); 29 this._modelByConstructor = new Map();
30 } 30 }
31 31
32 /** 32 /**
33 * @enum {number} 33 * @enum {number}
34 */ 34 */
35 WebInspector.Target.Capability = { 35 WebInspector.Target.Capability = {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 /** 71 /**
72 * @param {number} capabilitiesMask 72 * @param {number} capabilitiesMask
73 * @return {boolean} 73 * @return {boolean}
74 */ 74 */
75 hasAllCapabilities: function(capabilitiesMask) 75 hasAllCapabilities: function(capabilitiesMask)
76 { 76 {
77 return (this._capabilitiesMask & capabilitiesMask) === capabilitiesMask; 77 return (this._capabilitiesMask & capabilitiesMask) === capabilitiesMask;
78 }, 78 },
79 79
80 /** 80 /**
81 *
82 * @return {!InspectorBackendClass.Connection} 81 * @return {!InspectorBackendClass.Connection}
83 */ 82 */
84 connection: function() 83 connection: function()
85 { 84 {
86 return this._connection; 85 return this._connection;
87 }, 86 },
88 87
89 /** 88 /**
90 * @param {string} label 89 * @param {string} label
91 * @return {string} 90 * @return {string}
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 }, 153 },
155 154
156 /** 155 /**
157 * @return {?WebInspector.Target} 156 * @return {?WebInspector.Target}
158 */ 157 */
159 parentTarget: function() 158 parentTarget: function()
160 { 159 {
161 return this._parentTarget; 160 return this._parentTarget;
162 }, 161 },
163 162
164 _onDisconnect: function() 163 dispose: function()
165 { 164 {
166 this._targetManager.removeTarget(this); 165 this._targetManager.removeTarget(this);
167 this._dispose(); 166 for (var model of this._modelByConstructor.valuesArray())
168 }, 167 model.dispose();
169
170 _dispose: function()
171 {
172 this._targetManager.dispatchEventToListeners(WebInspector.TargetManager. Events.TargetDisposed, this);
173 if (this.workerManager) 168 if (this.workerManager)
174 this.workerManager.dispose(); 169 this.workerManager.dispose();
175 }, 170 },
176 171
177 /** 172 /**
178 * @return {boolean} 173 * @return {boolean}
179 */ 174 */
180 isDetached: function() 175 isDetached: function()
181 { 176 {
182 return this._connection.isClosed(); 177 return this._connection.isClosed();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 /** 246 /**
252 * @constructor 247 * @constructor
253 * @extends {WebInspector.SDKObject} 248 * @extends {WebInspector.SDKObject}
254 * @param {!Function} modelClass 249 * @param {!Function} modelClass
255 * @param {!WebInspector.Target} target 250 * @param {!WebInspector.Target} target
256 */ 251 */
257 WebInspector.SDKModel = function(modelClass, target) 252 WebInspector.SDKModel = function(modelClass, target)
258 { 253 {
259 WebInspector.SDKObject.call(this, target); 254 WebInspector.SDKObject.call(this, target);
260 target._modelByConstructor.set(modelClass, this); 255 target._modelByConstructor.set(modelClass, this);
261 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.TargetDisposed, this._targetDisposed, this);
262 } 256 }
263 257
264 WebInspector.SDKModel.prototype = { 258 WebInspector.SDKModel.prototype = {
265 /** 259 /**
266 * @return {!Promise} 260 * @return {!Promise}
267 */ 261 */
268 suspendModel: function() 262 suspendModel: function()
269 { 263 {
270 return Promise.resolve(); 264 return Promise.resolve();
271 }, 265 },
(...skipping 10 matching lines...) Expand all
282 276
283 /** 277 /**
284 * @param {!WebInspector.Event} event 278 * @param {!WebInspector.Event} event
285 */ 279 */
286 _targetDisposed: function(event) 280 _targetDisposed: function(event)
287 { 281 {
288 var target = /** @type {!WebInspector.Target} */ (event.data); 282 var target = /** @type {!WebInspector.Target} */ (event.data);
289 if (target !== this._target) 283 if (target !== this._target)
290 return; 284 return;
291 this.dispose(); 285 this.dispose();
292 WebInspector.targetManager.removeEventListener(WebInspector.TargetManage r.Events.TargetDisposed, this._targetDisposed, this);
293 }, 286 },
294 287
295 __proto__: WebInspector.SDKObject.prototype 288 __proto__: WebInspector.SDKObject.prototype
296 } 289 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698