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

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

Issue 2408133004: [DevTools] Implement Target.setDiscoverTargets method. (Closed)
Patch Set: rebased 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/inspector/browser_protocol.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.SDKModel} 7 * @extends {WebInspector.SDKModel}
8 * @param {!WebInspector.Target} target 8 * @param {!WebInspector.Target} target
9 */ 9 */
10 WebInspector.SubTargetsManager = function(target) 10 WebInspector.SubTargetsManager = function(target)
11 { 11 {
12 WebInspector.SDKModel.call(this, WebInspector.SubTargetsManager, target); 12 WebInspector.SDKModel.call(this, WebInspector.SubTargetsManager, target);
13 target.registerTargetDispatcher(new WebInspector.SubTargetsDispatcher(this)) ; 13 target.registerTargetDispatcher(new WebInspector.SubTargetsDispatcher(this)) ;
14 this._lastAnonymousTargetId = 0; 14 this._lastAnonymousTargetId = 0;
15 this._agent = target.targetAgent(); 15 this._agent = target.targetAgent();
16 16
17 /** @type {!Map<string, !WebInspector.TargetInfo>} */
18 this._allTargets = new Map();
19
20 /** @type {!Map<string, !WebInspector.Target>} */ 17 /** @type {!Map<string, !WebInspector.Target>} */
21 this._attachedTargets = new Map(); 18 this._attachedTargets = new Map();
22 /** @type {!Map<string, !WebInspector.SubTargetConnection>} */ 19 /** @type {!Map<string, !WebInspector.SubTargetConnection>} */
23 this._connections = new Map(); 20 this._connections = new Map();
24 21
25 this._agent.setAutoAttach(true /* autoAttach */, true /* waitForDebuggerOnSt art */); 22 this._agent.setAutoAttach(true /* autoAttach */, true /* waitForDebuggerOnSt art */);
26 this._agent.setAttachToFrames(Runtime.experiments.isEnabled("autoAttachToCro ssProcessSubframes")); 23 this._agent.setAttachToFrames(Runtime.experiments.isEnabled("autoAttachToCro ssProcessSubframes"));
27 } 24 }
28 25
29 /** @enum {symbol} */ 26 /** @enum {symbol} */
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 return WebInspector.Target.Capability.Log | WebInspector.Target.Capa bility.Network | WebInspector.Target.Capability.Worker; 130 return WebInspector.Target.Capability.Log | WebInspector.Target.Capa bility.Network | WebInspector.Target.Capability.Worker;
134 if (type === "iframe") 131 if (type === "iframe")
135 return WebInspector.Target.Capability.Browser | WebInspector.Target. Capability.DOM | 132 return WebInspector.Target.Capability.Browser | WebInspector.Target. Capability.DOM |
136 WebInspector.Target.Capability.JS | WebInspector.Target.Capabili ty.Log | 133 WebInspector.Target.Capability.JS | WebInspector.Target.Capabili ty.Log |
137 WebInspector.Target.Capability.Network | WebInspector.Target.Cap ability.Worker; 134 WebInspector.Target.Capability.Network | WebInspector.Target.Cap ability.Worker;
138 return 0; 135 return 0;
139 }, 136 },
140 137
141 /** 138 /**
142 * @param {!WebInspector.TargetInfo} targetInfo 139 * @param {!WebInspector.TargetInfo} targetInfo
143 */
144 _targetCreated: function(targetInfo)
145 {
146 console.assert(!this._allTargets.has(targetInfo.id));
147 console.assert(!this._attachedTargets.has(targetInfo.id));
148 this._allTargets.set(targetInfo.id, targetInfo);
149 },
150
151 /**
152 * @param {string} targetId
153 */
154 _targetRemoved: function(targetId)
155 {
156 console.assert(this._allTargets.has(targetId));
157 console.assert(!this._attachedTargets.has(targetId));
158 this._allTargets.delete(targetId);
159 },
160
161 /**
162 * @param {string} targetId
163 * @param {boolean} waitingForDebugger 140 * @param {boolean} waitingForDebugger
164 */ 141 */
165 _attachedToTarget: function(targetId, waitingForDebugger) 142 _attachedToTarget: function(targetInfo, waitingForDebugger)
166 { 143 {
167 var targetInfo = /** @type {!WebInspector.TargetInfo} */ (this._allTarge ts.get(targetId)); 144 var connection = new WebInspector.SubTargetConnection(this._agent, targe tInfo.id);
168 145 this._connections.set(targetInfo.id, connection);
169 var connection = new WebInspector.SubTargetConnection(this._agent, targe tId);
170 this._connections.set(targetId, connection);
171 146
172 var targetName = ""; 147 var targetName = "";
173 if (targetInfo.type !== "iframe") { 148 if (targetInfo.type !== "iframe") {
174 var parsedURL = targetInfo.url.asParsedURL(); 149 var parsedURL = targetInfo.url.asParsedURL();
175 targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() : "#" + (++this._lastAnonymousTargetId); 150 targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() : "#" + (++this._lastAnonymousTargetId);
176 } 151 }
177 var target = WebInspector.targetManager.createTarget(targetName, this._c apabilitiesForType(targetInfo.type), connection, this.target()); 152 var target = WebInspector.targetManager.createTarget(targetName, this._c apabilitiesForType(targetInfo.type), connection, this.target());
178 target[WebInspector.SubTargetsManager._InfoSymbol] = targetInfo; 153 target[WebInspector.SubTargetsManager._InfoSymbol] = targetInfo;
179 this._attachedTargets.set(targetId, target); 154 this._attachedTargets.set(targetInfo.id, target);
180 155
181 // Only pause new worker if debugging SW - we are going through the paus e on start checkbox. 156 // Only pause new worker if debugging SW - we are going through the paus e on start checkbox.
182 var mainIsServiceWorker = !this.target().parentTarget() && this.target() .hasWorkerCapability() && !this.target().hasBrowserCapability(); 157 var mainIsServiceWorker = !this.target().parentTarget() && this.target() .hasWorkerCapability() && !this.target().hasBrowserCapability();
183 if (mainIsServiceWorker && waitingForDebugger) 158 if (mainIsServiceWorker && waitingForDebugger)
184 target.debuggerAgent().pause(); 159 target.debuggerAgent().pause();
185 target.runtimeAgent().runIfWaitingForDebugger(); 160 target.runtimeAgent().runIfWaitingForDebugger();
186 161
187 this.dispatchEventToListeners(WebInspector.SubTargetsManager.Events.SubT argetAdded, target); 162 this.dispatchEventToListeners(WebInspector.SubTargetsManager.Events.SubT argetAdded, target);
188 }, 163 },
189 164
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 this._manager = manager; 200 this._manager = manager;
226 } 201 }
227 202
228 WebInspector.SubTargetsDispatcher.prototype = { 203 WebInspector.SubTargetsDispatcher.prototype = {
229 /** 204 /**
230 * @override 205 * @override
231 * @param {!TargetAgent.TargetInfo} targetInfo 206 * @param {!TargetAgent.TargetInfo} targetInfo
232 */ 207 */
233 targetCreated: function(targetInfo) 208 targetCreated: function(targetInfo)
234 { 209 {
235 this._manager._targetCreated(new WebInspector.TargetInfo(targetInfo)); 210 // Ignored.
236 }, 211 },
237 212
238 /** 213 /**
239 * @override 214 * @override
240 * @param {string} targetId 215 * @param {string} targetId
241 */ 216 */
242 targetRemoved: function(targetId) 217 targetDestroyed: function(targetId)
243 { 218 {
244 this._manager._targetRemoved(targetId); 219 // Ignored.
245 }, 220 },
246 221
247 /** 222 /**
248 * @override 223 * @override
249 * @param {string} targetId 224 * @param {!TargetAgent.TargetInfo} targetInfo
250 * @param {boolean} waitingForDebugger 225 * @param {boolean} waitingForDebugger
251 */ 226 */
252 attachedToTarget: function(targetId, waitingForDebugger) 227 attachedToTarget: function(targetInfo, waitingForDebugger)
253 { 228 {
254 this._manager._attachedToTarget(targetId, waitingForDebugger); 229 this._manager._attachedToTarget(new WebInspector.TargetInfo(targetInfo), waitingForDebugger);
255 }, 230 },
256 231
257 /** 232 /**
258 * @override 233 * @override
259 * @param {string} targetId 234 * @param {string} targetId
260 */ 235 */
261 detachedFromTarget: function(targetId) 236 detachedFromTarget: function(targetId)
262 { 237 {
263 this._manager._detachedFromTarget(targetId); 238 this._manager._detachedFromTarget(targetId);
264 }, 239 },
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 this.url = payload.url; 298 this.url = payload.url;
324 this.type = payload.type; 299 this.type = payload.type;
325 if (this.type !== "page" && this.type !== "iframe") { 300 if (this.type !== "page" && this.type !== "iframe") {
326 this.title = WebInspector.UIString("Worker: %s", this.url); 301 this.title = WebInspector.UIString("Worker: %s", this.url);
327 this.canActivate = false; 302 this.canActivate = false;
328 } else { 303 } else {
329 this.title = payload.title; 304 this.title = payload.title;
330 this.canActivate = true; 305 this.canActivate = true;
331 } 306 }
332 } 307 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/inspector/browser_protocol.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698