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

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

Issue 2441933002: [DevTools] Refactor connection-related classes. (Closed)
Patch Set: test fixes 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 side-by-side diff with in-line comments
Download patch
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 82f9ee07038be1424c800846418a946a9eba8b53..0f6b95f109b3e6e65a960a1252b37cda0ad256b7 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/Target.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/Target.js
@@ -10,11 +10,12 @@
* @param {!WebInspector.TargetManager} targetManager
* @param {string} name
* @param {number} capabilitiesMask
- * @param {!InspectorBackendClass.Connection} connection
+ * @param {!InspectorBackendClass.Channel} channel
* @param {?WebInspector.Target} parentTarget
*/
-WebInspector.Target = function(targetManager, name, capabilitiesMask, connection, parentTarget)
+WebInspector.Target = function(targetManager, name, capabilitiesMask, channel, parentTarget)
{
+ var connection = new InspectorBackendClass.Connection(channel, this._dispose.bind(this));
Protocol.Agents.call(this, connection.agentsMap());
this._targetManager = targetManager;
this._name = name;
@@ -22,8 +23,8 @@ WebInspector.Target = function(targetManager, name, capabilitiesMask, connection
this._capabilitiesMask = capabilitiesMask;
this._connection = connection;
this._parentTarget = parentTarget;
- connection.addEventListener(InspectorBackendClass.Connection.Events.Disconnected, this.dispose, this);
this._id = WebInspector.Target._nextId++;
+ this._disposed = false;
/** @type {!Map.<!Function, !WebInspector.SDKModel>} */
this._modelByConstructor = new Map();
@@ -92,14 +93,6 @@ WebInspector.Target.prototype = {
},
/**
- * @return {!InspectorBackendClass.Connection}
- */
- connection: function()
- {
- return this._connection;
- },
-
- /**
* @param {string} label
* @return {string}
*/
@@ -174,8 +167,12 @@ WebInspector.Target.prototype = {
return this._parentTarget;
},
- dispose: function()
+ /**
+ * @param {string} reason
+ */
+ _dispose: function(reason)
{
+ this._disposed = true;
this._targetManager.removeTarget(this);
for (var model of this._modelByConstructor.valuesArray())
model.dispose();
@@ -186,9 +183,9 @@ WebInspector.Target.prototype = {
/**
* @return {boolean}
*/
- isDetached: function()
+ isDisposed: function()
{
- return this._connection.isClosed();
+ return this._disposed;
},
/**

Powered by Google App Engine
This is Rietveld 408576698