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

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

Issue 473553003: DevTools: Process correctly a disconnection during target initialization (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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 {string} name 10 * @param {string} name
11 * @param {!InspectorBackendClass.Connection} connection 11 * @param {!InspectorBackendClass.Connection} connection
12 * @param {function(!WebInspector.Target)=} callback 12 * @param {function(?WebInspector.Target)=} callback
13 */ 13 */
14 WebInspector.Target = function(name, connection, callback) 14 WebInspector.Target = function(name, connection, callback)
15 { 15 {
16 Protocol.Agents.call(this, connection.agentsMap()); 16 Protocol.Agents.call(this, connection.agentsMap());
17 /** @type {!WeakReference.<!WebInspector.Target>} */ 17 /** @type {!WeakReference.<!WebInspector.Target>} */
18 this._weakReference = new WeakReference(this); 18 this._weakReference = new WeakReference(this);
19 this._name = name; 19 this._name = name;
20 this._connection = connection; 20 this._connection = connection;
21 connection.addEventListener(InspectorBackendClass.Connection.Events.Disconne cted, this._onDisconnect, this); 21 connection.addEventListener(InspectorBackendClass.Connection.Events.Disconne cted, this._onDisconnect, this);
22 this._id = WebInspector.Target._nextId++; 22 this._id = WebInspector.Target._nextId++;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 /** 89 /**
90 * @param {string} capability 90 * @param {string} capability
91 * @return {boolean} 91 * @return {boolean}
92 */ 92 */
93 hasCapability: function(capability) 93 hasCapability: function(capability)
94 { 94 {
95 return !!this._capabilities[capability]; 95 return !!this._capabilities[capability];
96 }, 96 },
97 97
98 /** 98 /**
99 * @param {function(!WebInspector.Target)=} callback 99 * @param {function(?WebInspector.Target)=} callback
100 */ 100 */
101 _loadedWithCapabilities: function(callback) 101 _loadedWithCapabilities: function(callback)
102 { 102 {
103 if (this._connection.isClosed()) {
104 callback(null);
105 return;
106 }
107
103 /** @type {!WebInspector.ConsoleModel} */ 108 /** @type {!WebInspector.ConsoleModel} */
104 this.consoleModel = new WebInspector.ConsoleModel(this); 109 this.consoleModel = new WebInspector.ConsoleModel(this);
105 110
106 /** @type {!WebInspector.NetworkManager} */ 111 /** @type {!WebInspector.NetworkManager} */
107 this.networkManager = new WebInspector.NetworkManager(this); 112 this.networkManager = new WebInspector.NetworkManager(this);
108 113
109 /** @type {!WebInspector.ResourceTreeModel} */ 114 /** @type {!WebInspector.ResourceTreeModel} */
110 this.resourceTreeModel = new WebInspector.ResourceTreeModel(this); 115 this.resourceTreeModel = new WebInspector.ResourceTreeModel(this);
111 if (!WebInspector.resourceTreeModel) 116 if (!WebInspector.resourceTreeModel)
112 WebInspector.resourceTreeModel = this.resourceTreeModel; 117 WebInspector.resourceTreeModel = this.resourceTreeModel;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 * @param {!WebInspector.TargetManager.Observer} targetObserver 332 * @param {!WebInspector.TargetManager.Observer} targetObserver
328 */ 333 */
329 unobserveTargets: function(targetObserver) 334 unobserveTargets: function(targetObserver)
330 { 335 {
331 this._observers.remove(targetObserver); 336 this._observers.remove(targetObserver);
332 }, 337 },
333 338
334 /** 339 /**
335 * @param {string} name 340 * @param {string} name
336 * @param {!InspectorBackendClass.Connection} connection 341 * @param {!InspectorBackendClass.Connection} connection
337 * @param {function(!WebInspector.Target)=} callback 342 * @param {function(?WebInspector.Target)=} callback
338 */ 343 */
339 createTarget: function(name, connection, callback) 344 createTarget: function(name, connection, callback)
340 { 345 {
341 var target = new WebInspector.Target(name, connection, callbackWrapper.b ind(this)); 346 var target = new WebInspector.Target(name, connection, callbackWrapper.b ind(this));
342 347
343 /** 348 /**
344 * @this {WebInspector.TargetManager} 349 * @this {WebInspector.TargetManager}
345 * @param {!WebInspector.Target} newTarget 350 * @param {?WebInspector.Target} newTarget
346 */ 351 */
347 function callbackWrapper(newTarget) 352 function callbackWrapper(newTarget)
348 { 353 {
349 this.addTarget(newTarget); 354 if (newTarget)
355 this.addTarget(newTarget);
350 if (callback) 356 if (callback)
351 callback(newTarget); 357 callback(newTarget);
352 } 358 }
353 }, 359 },
354 360
355 /** 361 /**
356 * @param {!WebInspector.Target} target 362 * @param {!WebInspector.Target} target
357 */ 363 */
358 addTarget: function(target) 364 addTarget: function(target)
359 { 365 {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 /** 429 /**
424 * @param {!WebInspector.Target} target 430 * @param {!WebInspector.Target} target
425 */ 431 */
426 targetRemoved: function(target) { }, 432 targetRemoved: function(target) { },
427 } 433 }
428 434
429 /** 435 /**
430 * @type {!WebInspector.TargetManager} 436 * @type {!WebInspector.TargetManager}
431 */ 437 */
432 WebInspector.targetManager = new WebInspector.TargetManager(); 438 WebInspector.targetManager = new WebInspector.TargetManager();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698