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

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

Issue 2450973002: [DevTools] Inherit WI.Target from Protocol.Target. (Closed)
Patch Set: Created 4 years, 1 month 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
1 /* 1 /*
2 * Copyright 2014 The Chromium Authors. All rights reserved. 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 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /** 7 /**
8 * @constructor 8 * @constructor
9 * @extends {Protocol.Agents} 9 * @extends {Protocol.Target}
10 * @param {!WebInspector.TargetManager} targetManager 10 * @param {!WebInspector.TargetManager} targetManager
11 * @param {string} name 11 * @param {string} name
12 * @param {number} capabilitiesMask 12 * @param {number} capabilitiesMask
13 * @param {!InspectorBackendClass.Connection.Factory} connectionFactory 13 * @param {!InspectorBackendClass.Connection.Factory} connectionFactory
14 * @param {?WebInspector.Target} parentTarget 14 * @param {?WebInspector.Target} parentTarget
15 */ 15 */
16 WebInspector.Target = function(targetManager, name, capabilitiesMask, connection Factory, parentTarget) 16 WebInspector.Target = function(targetManager, name, capabilitiesMask, connection Factory, parentTarget)
17 { 17 {
18 // TODO(dgozman): inherit instead. 18 Protocol.Target.call(this, connectionFactory);
19 var targetProto = new InspectorBackendClass.TargetPrototype(connectionFactor y, this._dispose.bind(this));
20 Protocol.Agents.call(this, targetProto.agentsMap());
21 this._targetManager = targetManager; 19 this._targetManager = targetManager;
22 this._name = name; 20 this._name = name;
23 this._inspectedURL = ""; 21 this._inspectedURL = "";
24 this._capabilitiesMask = capabilitiesMask; 22 this._capabilitiesMask = capabilitiesMask;
25 this._targetProto = targetProto;
26 this._parentTarget = parentTarget; 23 this._parentTarget = parentTarget;
27 this._id = WebInspector.Target._nextId++; 24 this._id = WebInspector.Target._nextId++;
28 this._disposed = false;
29 25
30 /** @type {!Map.<!Function, !WebInspector.SDKModel>} */ 26 /** @type {!Map.<!Function, !WebInspector.SDKModel>} */
31 this._modelByConstructor = new Map(); 27 this._modelByConstructor = new Map();
32 }; 28 };
33 29
34 /** 30 /**
35 * @enum {number} 31 * @enum {number}
36 */ 32 */
37 WebInspector.Target.Capability = { 33 WebInspector.Target.Capability = {
38 Browser: 1, 34 Browser: 1,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 /** 92 /**
97 * @param {string} label 93 * @param {string} label
98 * @return {string} 94 * @return {string}
99 */ 95 */
100 decorateLabel: function(label) 96 decorateLabel: function(label)
101 { 97 {
102 return !this.hasBrowserCapability() ? "\u2699 " + label : label; 98 return !this.hasBrowserCapability() ? "\u2699 " + label : label;
103 }, 99 },
104 100
105 /** 101 /**
106 * @override
107 * @param {string} domain
108 * @param {!Object} dispatcher
109 */
110 registerDispatcher: function(domain, dispatcher)
111 {
112 this._targetProto.registerDispatcher(domain, dispatcher);
113 },
114
115 /**
116 * @return {boolean} 102 * @return {boolean}
117 */ 103 */
118 hasBrowserCapability: function() 104 hasBrowserCapability: function()
119 { 105 {
120 return this.hasAllCapabilities(WebInspector.Target.Capability.Browser); 106 return this.hasAllCapabilities(WebInspector.Target.Capability.Browser);
121 }, 107 },
122 108
123 /** 109 /**
124 * @return {boolean} 110 * @return {boolean}
125 */ 111 */
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 }, 147 },
162 148
163 /** 149 /**
164 * @return {?WebInspector.Target} 150 * @return {?WebInspector.Target}
165 */ 151 */
166 parentTarget: function() 152 parentTarget: function()
167 { 153 {
168 return this._parentTarget; 154 return this._parentTarget;
169 }, 155 },
170 156
171 _dispose: function() 157 /**
158 * @override
159 */
160 dispose: function()
172 { 161 {
173 this._disposed = true;
174 this._targetManager.removeTarget(this); 162 this._targetManager.removeTarget(this);
175 for (var model of this._modelByConstructor.valuesArray()) 163 for (var model of this._modelByConstructor.valuesArray())
176 model.dispose(); 164 model.dispose();
177 if (this.workerManager) 165 if (this.workerManager)
178 this.workerManager.dispose(); 166 this.workerManager.dispose();
179 }, 167 },
180 168
181 /** 169 /**
182 * @return {boolean}
183 */
184 isDisposed: function()
185 {
186 return this._disposed;
187 },
188
189 /**
190 * @param {!Function} modelClass 170 * @param {!Function} modelClass
191 * @return {?WebInspector.SDKModel} 171 * @return {?WebInspector.SDKModel}
192 */ 172 */
193 model: function(modelClass) 173 model: function(modelClass)
194 { 174 {
195 return this._modelByConstructor.get(modelClass) || null; 175 return this._modelByConstructor.get(modelClass) || null;
196 }, 176 },
197 177
198 /** 178 /**
199 * @return {!Array<!WebInspector.SDKModel>} 179 * @return {!Array<!WebInspector.SDKModel>}
(...skipping 19 matching lines...) Expand all
219 this._inspectedURL = inspectedURL; 199 this._inspectedURL = inspectedURL;
220 var parsedURL = inspectedURL.asParsedURL(); 200 var parsedURL = inspectedURL.asParsedURL();
221 this._inspectedURLName = parsedURL ? parsedURL.lastPathComponentWithFrag ment() : "#" + this._id; 201 this._inspectedURLName = parsedURL ? parsedURL.lastPathComponentWithFrag ment() : "#" + this._id;
222 if (!this.parentTarget()) 202 if (!this.parentTarget())
223 InspectorFrontendHost.inspectedURLChanged(inspectedURL || ""); 203 InspectorFrontendHost.inspectedURLChanged(inspectedURL || "");
224 this._targetManager.dispatchEventToListeners(WebInspector.TargetManager. Events.InspectedURLChanged, this); 204 this._targetManager.dispatchEventToListeners(WebInspector.TargetManager. Events.InspectedURLChanged, this);
225 if (!this._name) 205 if (!this._name)
226 this._targetManager.dispatchEventToListeners(WebInspector.TargetMana ger.Events.NameChanged, this); 206 this._targetManager.dispatchEventToListeners(WebInspector.TargetMana ger.Events.NameChanged, this);
227 }, 207 },
228 208
229 __proto__: Protocol.Agents.prototype 209 __proto__: Protocol.Target.prototype
230 }; 210 };
231 211
232 /** 212 /**
233 * @constructor 213 * @constructor
234 * @extends {WebInspector.Object} 214 * @extends {WebInspector.Object}
235 * @param {!WebInspector.Target} target 215 * @param {!WebInspector.Target} target
236 */ 216 */
237 WebInspector.SDKObject = function(target) 217 WebInspector.SDKObject = function(target)
238 { 218 {
239 WebInspector.Object.call(this); 219 WebInspector.Object.call(this);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 _targetDisposed: function(event) 269 _targetDisposed: function(event)
290 { 270 {
291 var target = /** @type {!WebInspector.Target} */ (event.data); 271 var target = /** @type {!WebInspector.Target} */ (event.data);
292 if (target !== this._target) 272 if (target !== this._target)
293 return; 273 return;
294 this.dispose(); 274 this.dispose();
295 }, 275 },
296 276
297 __proto__: WebInspector.SDKObject.prototype 277 __proto__: WebInspector.SDKObject.prototype
298 }; 278 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698