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

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

Issue 2441933002: [DevTools] Refactor connection-related classes. (Closed)
Patch Set: tests.js 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 3c37163d2f11ba20893439590bf8cbf07b6e4760..ab9bc8ed6629456f711999d003fbfaa2bed01914 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/Target.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/Target.js
@@ -10,20 +10,22 @@
* @param {!WebInspector.TargetManager} targetManager
* @param {string} name
* @param {number} capabilitiesMask
- * @param {!InspectorBackendClass.Connection} connection
+ * @param {!InspectorBackendClass.Connection.Factory} connectionFactory
* @param {?WebInspector.Target} parentTarget
*/
-WebInspector.Target = function(targetManager, name, capabilitiesMask, connection, parentTarget)
+WebInspector.Target = function(targetManager, name, capabilitiesMask, connectionFactory, parentTarget)
{
- Protocol.Agents.call(this, connection.agentsMap());
+ // TODO(dgozman): inherit instead.
+ var targetProto = new InspectorBackendClass.TargetPrototype(connectionFactory, this._dispose.bind(this));
+ Protocol.Agents.call(this, targetProto.agentsMap());
this._targetManager = targetManager;
this._name = name;
this._inspectedURL = "";
this._capabilitiesMask = capabilitiesMask;
- this._connection = connection;
+ this._targetProto = targetProto;
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 +94,6 @@ WebInspector.Target.prototype = {
},
/**
- * @return {!InspectorBackendClass.Connection}
- */
- connection: function()
- {
- return this._connection;
- },
-
- /**
* @param {string} label
* @return {string}
*/
@@ -115,7 +109,7 @@ WebInspector.Target.prototype = {
*/
registerDispatcher: function(domain, dispatcher)
{
- this._connection.registerDispatcher(domain, dispatcher);
+ this._targetProto.registerDispatcher(domain, dispatcher);
},
/**
@@ -174,8 +168,9 @@ WebInspector.Target.prototype = {
return this._parentTarget;
},
- dispose: function()
+ _dispose: function()
{
+ this._disposed = true;
this._targetManager.removeTarget(this);
for (var model of this._modelByConstructor.valuesArray())
model.dispose();
@@ -186,9 +181,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