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

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

Issue 2451363002: [DevTools] Move main target/connection to TargetManager. (Closed)
Patch Set: rebased 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 {WebInspector.Object} 9 * @extends {WebInspector.Object}
10 */ 10 */
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 target.tracingManager = new WebInspector.TracingManager(target); 227 target.tracingManager = new WebInspector.TracingManager(target);
228 228
229 if (target.subTargetsManager && target.hasBrowserCapability()) 229 if (target.subTargetsManager && target.hasBrowserCapability())
230 target.serviceWorkerManager = new WebInspector.ServiceWorkerManager( target, target.subTargetsManager); 230 target.serviceWorkerManager = new WebInspector.ServiceWorkerManager( target, target.subTargetsManager);
231 231
232 this.addTarget(target); 232 this.addTarget(target);
233 return target; 233 return target;
234 }, 234 },
235 235
236 /** 236 /**
237 * @param {function(function(string)):!Promise<!InspectorBackendClass.Connec tion>} interceptor
238 */
239 setMainConnectionInterceptor: function(interceptor)
240 {
241 this._mainConnectionInterceptor = interceptor;
242 },
243
244 /**
245 * @param {function(string)} onMessage
246 * @return {!Promise<!InspectorBackendClass.Connection>}
247 */
248 interceptMainConnection: function(onMessage)
249 {
250 return this._mainConnectionInterceptor.call(null, onMessage);
251 },
252
253 /**
254 * @param {!WebInspector.Target} target 237 * @param {!WebInspector.Target} target
255 * @return {!Array<!WebInspector.TargetManager.Observer>} 238 * @return {!Array<!WebInspector.TargetManager.Observer>}
256 */ 239 */
257 _observersForTarget: function(target) 240 _observersForTarget: function(target)
258 { 241 {
259 return this._observers.filter((observer) => target.hasAllCapabilities(ob server[this._observerCapabiliesMaskSymbol] || 0)); 242 return this._observers.filter((observer) => target.hasAllCapabilities(ob server[this._observerCapabiliesMaskSymbol] || 0));
260 }, 243 },
261 244
262 /** 245 /**
263 * @param {!WebInspector.Target} target 246 * @param {!WebInspector.Target} target
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 /** 356 /**
374 * @param {!WebInspector.Target} target 357 * @param {!WebInspector.Target} target
375 */ 358 */
376 resumeReload: function(target) 359 resumeReload: function(target)
377 { 360 {
378 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(target ); 361 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(target );
379 if (resourceTreeModel) 362 if (resourceTreeModel)
380 setImmediate(resourceTreeModel.resumeReload.bind(resourceTreeModel)) ; 363 setImmediate(resourceTreeModel.resumeReload.bind(resourceTreeModel)) ;
381 }, 364 },
382 365
366 /**
367 * @param {function()} webSocketConnectionLostCallback
368 */
369 connectToMainTarget: function(webSocketConnectionLostCallback)
370 {
371 this._webSocketConnectionLostCallback = webSocketConnectionLostCallback;
372 this._connectAndCreateMainTarget();
373 },
374
375 _connectAndCreateMainTarget: function()
376 {
377 var capabilities =
378 WebInspector.Target.Capability.Browser | WebInspector.Target.Capabil ity.DOM |
379 WebInspector.Target.Capability.JS | WebInspector.Target.Capability.L og |
380 WebInspector.Target.Capability.Network | WebInspector.Target.Capabil ity.Target;
381 if (Runtime.queryParam("isSharedWorker")) {
382 capabilities =
383 WebInspector.Target.Capability.Browser | WebInspector.Target.Cap ability.Log |
384 WebInspector.Target.Capability.Network | WebInspector.Target.Cap ability.Target;
385 } else if (Runtime.queryParam("v8only")) {
386 capabilities = WebInspector.Target.Capability.JS;
387 }
388
389 var target = this.createTarget(WebInspector.UIString("Main"), capabiliti es, this._createMainConnection.bind(this), null);
390 target.runtimeAgent().runIfWaitingForDebugger();
391 },
392
393 /**
394 * @param {!InspectorBackendClass.Connection.Params} params
395 * @return {!InspectorBackendClass.Connection}
396 */
397 _createMainConnection: function(params)
398 {
399 if (Runtime.queryParam("ws")) {
400 var ws = "ws://" + Runtime.queryParam("ws");
401 this._mainConnection = new WebInspector.WebSocketConnection(ws, this ._webSocketConnectionLostCallback, params);
402 } else if (InspectorFrontendHost.isHostedMode()) {
403 this._mainConnection = new WebInspector.StubConnection(params);
404 } else {
405 this._mainConnection = new WebInspector.MainConnection(params);
406 }
407 return this._mainConnection;
408 },
409
410 /**
411 * @param {function(string)} onMessage
412 * @return {!Promise<!InspectorBackendClass.Connection>}
413 */
414 interceptMainConnection: function(onMessage)
415 {
416 var params = {
417 onMessage: onMessage,
418 onDisconnect: this._connectAndCreateMainTarget.bind(this)
419 };
420 return this._mainConnection.disconnect().then(this._createMainConnection .bind(this, params));
421 },
422
383 __proto__: WebInspector.Object.prototype 423 __proto__: WebInspector.Object.prototype
384 }; 424 };
385 425
386 /** 426 /**
387 * @interface 427 * @interface
388 */ 428 */
389 WebInspector.TargetManager.Observer = function() 429 WebInspector.TargetManager.Observer = function()
390 { 430 {
391 }; 431 };
392 432
393 WebInspector.TargetManager.Observer.prototype = { 433 WebInspector.TargetManager.Observer.prototype = {
394 /** 434 /**
395 * @param {!WebInspector.Target} target 435 * @param {!WebInspector.Target} target
396 */ 436 */
397 targetAdded: function(target) { }, 437 targetAdded: function(target) { },
398 438
399 /** 439 /**
400 * @param {!WebInspector.Target} target 440 * @param {!WebInspector.Target} target
401 */ 441 */
402 targetRemoved: function(target) { }, 442 targetRemoved: function(target) { },
403 }; 443 };
404 444
405 /** 445 /**
406 * @type {!WebInspector.TargetManager} 446 * @type {!WebInspector.TargetManager}
407 */ 447 */
408 WebInspector.targetManager = new WebInspector.TargetManager(); 448 WebInspector.targetManager = new WebInspector.TargetManager();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698