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

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

Issue 2442083002: [DevTools] Merge Worker domain to Target, migrate clients. (Closed)
Patch Set: rebased all tests 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 // 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.Target>} */ 17 /** @type {!Map<string, !WebInspector.Target>} */
18 this._attachedTargets = new Map(); 18 this._attachedTargets = new Map();
19 /** @type {!Map<string, !WebInspector.SubTargetConnection>} */ 19 /** @type {!Map<string, !WebInspector.SubTargetConnection>} */
20 this._connections = new Map(); 20 this._connections = new Map();
21 21
22 this._agent.setAutoAttach(true /* autoAttach */, true /* waitForDebuggerOnSt art */); 22 this._agent.setAutoAttach(true /* autoAttach */, true /* waitForDebuggerOnSt art */);
23 this._agent.setAttachToFrames(Runtime.experiments.isEnabled("autoAttachToCro ssProcessSubframes")); 23 if (Runtime.experiments.isEnabled("autoAttachToCrossProcessSubframes"))
24 this._agent.setAttachToFrames(true);
24 25
25 if (Runtime.experiments.isEnabled("nodeDebugging") && !target.parentTarget() ) { 26 if (Runtime.experiments.isEnabled("nodeDebugging") && !target.parentTarget() ) {
26 var defaultLocations = [{host: "localhost", port: 9229}]; 27 var defaultLocations = [{host: "localhost", port: 9229}];
27 this._agent.setRemoteLocations(defaultLocations); 28 this._agent.setRemoteLocations(defaultLocations);
28 this._agent.setDiscoverTargets(true); 29 this._agent.setDiscoverTargets(true);
29 } 30 }
31 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.MainFrameNavigated, this._mainFrameNavigated, this);
30 }; 32 };
31 33
32 /** @enum {symbol} */ 34 /** @enum {symbol} */
33 WebInspector.SubTargetsManager.Events = { 35 WebInspector.SubTargetsManager.Events = {
34 SubTargetAdded: Symbol("SubTargetAdded"), 36 SubTargetAdded: Symbol("SubTargetAdded"),
35 SubTargetRemoved: Symbol("SubTargetRemoved"), 37 SubTargetRemoved: Symbol("SubTargetRemoved"),
36 }; 38 };
37 39
38 WebInspector.SubTargetsManager._InfoSymbol = Symbol("SubTargetInfo"); 40 WebInspector.SubTargetsManager._InfoSymbol = Symbol("SubTargetInfo");
39 41
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 130
129 /** 131 /**
130 * @param {string} type 132 * @param {string} type
131 * @return {number} 133 * @return {number}
132 */ 134 */
133 _capabilitiesForType: function(type) 135 _capabilitiesForType: function(type)
134 { 136 {
135 if (type === "worker") 137 if (type === "worker")
136 return WebInspector.Target.Capability.JS | WebInspector.Target.Capab ility.Log; 138 return WebInspector.Target.Capability.JS | WebInspector.Target.Capab ility.Log;
137 if (type === "service_worker") 139 if (type === "service_worker")
138 return WebInspector.Target.Capability.Log | WebInspector.Target.Capa bility.Network | WebInspector.Target.Capability.Worker; 140 return WebInspector.Target.Capability.Log | WebInspector.Target.Capa bility.Network | WebInspector.Target.Capability.Target;
139 if (type === "iframe") 141 if (type === "iframe")
140 return WebInspector.Target.Capability.Browser | WebInspector.Target. Capability.DOM | 142 return WebInspector.Target.Capability.Browser | WebInspector.Target. Capability.DOM |
141 WebInspector.Target.Capability.JS | WebInspector.Target.Capabili ty.Log | 143 WebInspector.Target.Capability.JS | WebInspector.Target.Capabili ty.Log |
142 WebInspector.Target.Capability.Network | WebInspector.Target.Cap ability.Worker; 144 WebInspector.Target.Capability.Network | WebInspector.Target.Cap ability.Target;
143 if (type === "node") 145 if (type === "node")
144 return WebInspector.Target.Capability.JS; 146 return WebInspector.Target.Capability.JS;
145 return 0; 147 return 0;
146 }, 148 },
147 149
148 /** 150 /**
149 * @param {!WebInspector.TargetInfo} targetInfo 151 * @param {!WebInspector.TargetInfo} targetInfo
150 * @param {boolean} waitingForDebugger 152 * @param {boolean} waitingForDebugger
151 */ 153 */
152 _attachedToTarget: function(targetInfo, waitingForDebugger) 154 _attachedToTarget: function(targetInfo, waitingForDebugger)
153 { 155 {
154 var targetName = ""; 156 var targetName = "";
155 if (targetInfo.type === "node") { 157 if (targetInfo.type === "node") {
156 targetName = targetInfo.title; 158 targetName = targetInfo.title;
157 } else if (targetInfo.type !== "iframe") { 159 } else if (targetInfo.type !== "iframe") {
158 var parsedURL = targetInfo.url.asParsedURL(); 160 var parsedURL = targetInfo.url.asParsedURL();
159 targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() : "#" + (++this._lastAnonymousTargetId); 161 targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() : "#" + (++this._lastAnonymousTargetId);
160 } 162 }
161 var target = WebInspector.targetManager.createTarget(targetName, this._c apabilitiesForType(targetInfo.type), this._createConnection.bind(this, targetInf o.id), this.target()); 163 var target = WebInspector.targetManager.createTarget(targetName, this._c apabilitiesForType(targetInfo.type), this._createConnection.bind(this, targetInf o.id), this.target());
162 target[WebInspector.SubTargetsManager._InfoSymbol] = targetInfo; 164 target[WebInspector.SubTargetsManager._InfoSymbol] = targetInfo;
163 this._attachedTargets.set(targetInfo.id, target); 165 this._attachedTargets.set(targetInfo.id, target);
164 166
165 // Only pause new worker if debugging SW - we are going through the paus e on start checkbox. 167 // Only pause new worker if debugging SW - we are going through the paus e on start checkbox.
166 var mainIsServiceWorker = !this.target().parentTarget() && this.target() .hasWorkerCapability() && !this.target().hasBrowserCapability(); 168 var mainIsServiceWorker = !this.target().parentTarget() && this.target() .hasTargetCapability() && !this.target().hasBrowserCapability();
167 if (mainIsServiceWorker && waitingForDebugger) 169 if (mainIsServiceWorker && waitingForDebugger)
168 target.debuggerAgent().pause(); 170 target.debuggerAgent().pause();
169 target.runtimeAgent().runIfWaitingForDebugger(); 171 target.runtimeAgent().runIfWaitingForDebugger();
170 172
171 this.dispatchEventToListeners(WebInspector.SubTargetsManager.Events.SubT argetAdded, target); 173 this.dispatchEventToListeners(WebInspector.SubTargetsManager.Events.SubT argetAdded, target);
172 }, 174 },
173 175
174 /** 176 /**
175 * @param {string} targetId 177 * @param {string} targetId
176 * @param {!InspectorBackendClass.Connection.Params} params 178 * @param {!InspectorBackendClass.Connection.Params} params
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 }, 221 },
220 222
221 /** 223 /**
222 * @param {string} targetId 224 * @param {string} targetId
223 */ 225 */
224 _targetDestroyed: function(targetId) 226 _targetDestroyed: function(targetId)
225 { 227 {
226 // All the work is done in _detachedFromTarget. 228 // All the work is done in _detachedFromTarget.
227 }, 229 },
228 230
231 /**
232 * @param {!WebInspector.Event} event
233 */
234 _mainFrameNavigated: function(event)
235 {
236 if (event.data.target() !== this.target())
237 return;
238
239 var idsToDetach = [];
240 for (var targetId of this._attachedTargets.keys()) {
241 var target = this._attachedTargets.get(targetId);
242 var targetInfo = this.targetInfo(target);
243 if (targetInfo.type === "worker")
244 idsToDetach.push(targetId);
245 }
246 idsToDetach.forEach(id => this._detachedFromTarget(id));
247 },
248
229 __proto__: WebInspector.SDKModel.prototype 249 __proto__: WebInspector.SDKModel.prototype
230 }; 250 };
231 251
232 /** 252 /**
233 * @constructor 253 * @constructor
234 * @implements {TargetAgent.Dispatcher} 254 * @implements {TargetAgent.Dispatcher}
235 * @param {!WebInspector.SubTargetsManager} manager 255 * @param {!WebInspector.SubTargetsManager} manager
236 */ 256 */
237 WebInspector.SubTargetsDispatcher = function(manager) 257 WebInspector.SubTargetsDispatcher = function(manager)
238 { 258 {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 this.url = payload.url; 353 this.url = payload.url;
334 this.type = payload.type; 354 this.type = payload.type;
335 if (this.type !== "page" && this.type !== "iframe") { 355 if (this.type !== "page" && this.type !== "iframe") {
336 this.title = WebInspector.UIString("Worker: %s", this.url); 356 this.title = WebInspector.UIString("Worker: %s", this.url);
337 this.canActivate = false; 357 this.canActivate = false;
338 } else { 358 } else {
339 this.title = payload.title; 359 this.title = payload.title;
340 this.canActivate = true; 360 this.canActivate = true;
341 } 361 }
342 }; 362 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698