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

Unified Diff: Source/devtools/front_end/Target.js

Issue 185463010: DevTools: Introduce Target class which holds connection & models (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@gr-RuntimeAgent
Patch Set: Address vsevik's comments Created 6 years, 9 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: Source/devtools/front_end/Target.js
diff --git a/Source/devtools/front_end/Target.js b/Source/devtools/front_end/Target.js
new file mode 100644
index 0000000000000000000000000000000000000000..1dc4c70318e28d6386b7f2e20710e2192ad73245
--- /dev/null
+++ b/Source/devtools/front_end/Target.js
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2014 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * @constructor
+ * @extends {Protocol.Agents}
+ * @param {!InspectorBackendClass.Connection} connection
+ * @param {function(!WebInspector.Target)=} callback
+ */
+WebInspector.Target = function(connection, callback)
+{
+ Protocol.Agents.call(this, connection.agentsMap());
+ this._connection = connection;
+ this.canInspectWorkers = false;
+
+ this.pageAgent().canScreencast(this._initializeCapability.bind(this, "canScreencast", null));
+ this.workerAgent().canInspectWorkers(this._initializeCapability.bind(this, "canInspectWorkers", this._loadedWithCapabilities.bind(this, callback)));
+
+ // In case of loading as a web page with no bindings / harness, kick off initialization manually.
+ if (InspectorFrontendHost.isStub) {
+ // give a chance to add listeners of WebInspector.Target.Events.TargetIsReady
+ setTimeout(this._loadedWithCapabilities.bind(this, callback), 0);
pfeldman 2014/03/08 16:07:17 This kills hosted mode - everything is initialized
+ }
+}
+
+WebInspector.Target.prototype = {
+
+ _initializeCapability: function(name, callback, error, result)
+ {
+ this[name] = result;
+ Capabilities[name] = result;
+ if (callback)
+ callback();
+ },
+
+ /**
+ * @param {function(!WebInspector.Target)=} callback
+ */
+ _loadedWithCapabilities: function(callback)
+ {
+ this.consoleModel = new WebInspector.ConsoleModel();
+ //This and similar lines are needed for compatibility
+ WebInspector.console = this.consoleModel;
+ this.networkManager = new WebInspector.NetworkManager();
+ WebInspector.networkManager = this.networkManager;
+ this.resourceTreeModel = new WebInspector.ResourceTreeModel(this.networkManager);
+ WebInspector.resourceTreeModel = this.resourceTreeModel;
+ this.debuggerModel = new WebInspector.DebuggerModel();
+ WebInspector.debuggerModel = this.debuggerModel;
+ this.runtimeModel = new WebInspector.RuntimeModel(this.resourceTreeModel);
+ WebInspector.runtimeModel = this.runtimeModel;
+
+ //we can't name it domAgent, because it clashes with function, WebInspector.DOMAgent should be renamed to DOMModel
+ this._domAgent = new WebInspector.DOMAgent();
+ WebInspector.domAgent = this._domAgent;
+ this.workerManager = new WebInspector.WorkerManager(this.canInspectWorkers);
+ WebInspector.workerManager = this.workerManager;
+
+ if (callback)
+ callback(this);
+ },
+
+ __proto__: Protocol.Agents.prototype
+}
+
+/**
+ * @constructor
+ */
+WebInspector.TargetManager = function()
+{
+ /** @type {!Array.<!WebInspector.Target>} */
+ this._targets = [];
+}
+
+WebInspector.TargetManager.prototype = {
+
+ /**
+ * @param {!InspectorBackendClass.Connection} connection
+ * @param {function(!WebInspector.Target)=} callback
+ */
+ createTarget: function(connection, callback)
+ {
+ var newTarget = new WebInspector.Target(connection, callback);
+ this._targets.push(newTarget);
+ }
+
+}

Powered by Google App Engine
This is Rietveld 408576698