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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
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
4 * found in the LICENSE file.
5 */
6
7 /**
8 * @constructor
9 * @extends {Protocol.Agents}
10 * @param {!InspectorBackendClass.Connection} connection
11 * @param {function(!WebInspector.Target)=} callback
12 */
13 WebInspector.Target = function(connection, callback)
14 {
15 Protocol.Agents.call(this, connection.agentsMap());
16 this._connection = connection;
17 this.canInspectWorkers = false;
18
19 this.pageAgent().canScreencast(this._initializeCapability.bind(this, "canScr eencast", null));
20 this.workerAgent().canInspectWorkers(this._initializeCapability.bind(this, " canInspectWorkers", this._loadedWithCapabilities.bind(this, callback)));
21
22 // In case of loading as a web page with no bindings / harness, kick off ini tialization manually.
23 if (InspectorFrontendHost.isStub) {
24 // give a chance to add listeners of WebInspector.Target.Events.TargetIs Ready
25 setTimeout(this._loadedWithCapabilities.bind(this, callback), 0);
pfeldman 2014/03/08 16:07:17 This kills hosted mode - everything is initialized
26 }
27 }
28
29 WebInspector.Target.prototype = {
30
31 _initializeCapability: function(name, callback, error, result)
32 {
33 this[name] = result;
34 Capabilities[name] = result;
35 if (callback)
36 callback();
37 },
38
39 /**
40 * @param {function(!WebInspector.Target)=} callback
41 */
42 _loadedWithCapabilities: function(callback)
43 {
44 this.consoleModel = new WebInspector.ConsoleModel();
45 //This and similar lines are needed for compatibility
46 WebInspector.console = this.consoleModel;
47 this.networkManager = new WebInspector.NetworkManager();
48 WebInspector.networkManager = this.networkManager;
49 this.resourceTreeModel = new WebInspector.ResourceTreeModel(this.network Manager);
50 WebInspector.resourceTreeModel = this.resourceTreeModel;
51 this.debuggerModel = new WebInspector.DebuggerModel();
52 WebInspector.debuggerModel = this.debuggerModel;
53 this.runtimeModel = new WebInspector.RuntimeModel(this.resourceTreeModel );
54 WebInspector.runtimeModel = this.runtimeModel;
55
56 //we can't name it domAgent, because it clashes with function, WebInspec tor.DOMAgent should be renamed to DOMModel
57 this._domAgent = new WebInspector.DOMAgent();
58 WebInspector.domAgent = this._domAgent;
59 this.workerManager = new WebInspector.WorkerManager(this.canInspectWorke rs);
60 WebInspector.workerManager = this.workerManager;
61
62 if (callback)
63 callback(this);
64 },
65
66 __proto__: Protocol.Agents.prototype
67 }
68
69 /**
70 * @constructor
71 */
72 WebInspector.TargetManager = function()
73 {
74 /** @type {!Array.<!WebInspector.Target>} */
75 this._targets = [];
76 }
77
78 WebInspector.TargetManager.prototype = {
79
80 /**
81 * @param {!InspectorBackendClass.Connection} connection
82 * @param {function(!WebInspector.Target)=} callback
83 */
84 createTarget: function(connection, callback)
85 {
86 var newTarget = new WebInspector.Target(connection, callback);
87 this._targets.push(newTarget);
88 }
89
90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698