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

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: Created 6 years, 10 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..30887dc38536f6ac96d20b271a37122f78f33884
--- /dev/null
+++ b/Source/devtools/front_end/Target.js
@@ -0,0 +1,82 @@
+/**
+ * Copyright 2014 The Chromium Authors. All rights reserved.
aandrey 2014/03/04 10:05:16 odd licence
sergeyv 2014/03/04 12:42:37 Header was changed recently. http://www.chromium.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * @constructor
+ * @extends {WebInspector.Object}
+ * @param {!InspectorBackendClass.Connection} connection
+ */
+WebInspector.Target = function(connection)
+{
+ WebInspector.Object.call(this);
+ this.connection = connection;
+ this.canScreenCast = false;
+ this.canInspectWorkers = false;
+
+ connection.agent("Page").canScreencast(this._initializeCapability.bind(this, "canScreencast", null));
+ connection.agent("Worker").canInspectWorkers(this._initializeCapability.bind(this, "canInspectWorkers", this._loadedWithCapabilities.bind(this)));
+
+ // 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
aandrey 2014/03/04 10:05:16 add {} braces
sergeyv 2014/03/04 12:42:38 Done.
+ setTimeout(this._loadedWithCapabilities.bind(this), 0);
+}
+
+WebInspector.Target.Events = {
+ TargetIsReady: "TargetIsReady"
+}
+
+WebInspector.Target.prototype = {
+
+ _initializeCapability: function(name, callback, error, result)
+ {
+ this[name] = result;
+ if (callback)
+ callback();
+ },
+
+ _loadedWithCapabilities: function()
aandrey 2014/03/04 10:05:16 this does not seem to be private
sergeyv 2014/03/04 12:42:38 There is no usages of this function out of this fi
+ {
+ this.consoleModel = new WebInspector.ConsoleModel(this);
+ this.networkManager = new WebInspector.NetworkManager(this);
+ this.resourceTreeModel = new WebInspector.ResourceTreeModel(this);
+ this.debuggerModel = new WebInspector.DebuggerModel();
+ this.runtimeModel = new WebInspector.RuntimeModel(this);
+
+ this.dispatchEventToListeners(WebInspector.Target.Events.TargetIsReady);
+ },
+
+ __proto__: WebInspector.Object.prototype
+}
+
+/**
+ * @constructor
+ * @extends {WebInspector.Object}
+ */
+WebInspector.TargetManager = function()
+{
+ this._targets = [];
aandrey 2014/03/04 10:05:16 jsdoc
sergeyv 2014/03/04 12:42:38 Done.
+}
+
+WebInspector.TargetManager.Events = {
+ TargetSwitched: "TargetSwitched"
+}
+
+WebInspector.TargetManager.prototype = {
+
+ /**
+ * @param {!InspectorBackendClass.Connection} connection
+ * @return {!WebInspector.Target}
+ */
+ newConnectionAvailable: function(connection)
+ {
+ var newTarget = new WebInspector.Target(connection);
+ this._targets.push(newTarget);
+ return newTarget;
+ },
+
+ __proto__: WebInspector.Object.prototype
+}

Powered by Google App Engine
This is Rietveld 408576698