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

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

Issue 2600323002: DevTools: extract protocol module (Closed)
Patch Set: move inspector backend commands.js Created 3 years, 11 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
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 * @unrestricted 8 * @unrestricted
9 */ 9 */
10 SDK.TargetManager = class extends Common.Object { 10 SDK.TargetManager = class extends Common.Object {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 * @param {!SDK.TargetManager.Observer} targetObserver 150 * @param {!SDK.TargetManager.Observer} targetObserver
151 */ 151 */
152 unobserveTargets(targetObserver) { 152 unobserveTargets(targetObserver) {
153 delete targetObserver[this._observerCapabiliesMaskSymbol]; 153 delete targetObserver[this._observerCapabiliesMaskSymbol];
154 this._observers.remove(targetObserver); 154 this._observers.remove(targetObserver);
155 } 155 }
156 156
157 /** 157 /**
158 * @param {string} name 158 * @param {string} name
159 * @param {number} capabilitiesMask 159 * @param {number} capabilitiesMask
160 * @param {!InspectorBackendClass.Connection.Factory} connectionFactory 160 * @param {!Protocol.InspectorBackend.Connection.Factory} connectionFactory
161 * @param {?SDK.Target} parentTarget 161 * @param {?SDK.Target} parentTarget
162 * @return {!SDK.Target} 162 * @return {!SDK.Target}
163 */ 163 */
164 createTarget(name, capabilitiesMask, connectionFactory, parentTarget) { 164 createTarget(name, capabilitiesMask, connectionFactory, parentTarget) {
165 var target = new SDK.Target(this, name, capabilitiesMask, connectionFactory, parentTarget); 165 var target = new SDK.Target(this, name, capabilitiesMask, connectionFactory, parentTarget);
166 166
167 var logAgent = target.hasLogCapability() ? target.logAgent() : null; 167 var logAgent = target.hasLogCapability() ? target.logAgent() : null;
168 168
169 /** @type {!SDK.ConsoleModel} */ 169 /** @type {!SDK.ConsoleModel} */
170 target.consoleModel = new SDK.ConsoleModel(target, logAgent); 170 target.consoleModel = new SDK.ConsoleModel(target, logAgent);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 SDK.Target.Capability.Target; 347 SDK.Target.Capability.Target;
348 } else if (Runtime.queryParam('v8only')) { 348 } else if (Runtime.queryParam('v8only')) {
349 capabilities = SDK.Target.Capability.JS; 349 capabilities = SDK.Target.Capability.JS;
350 } 350 }
351 351
352 var target = this.createTarget(Common.UIString('Main'), capabilities, this._ createMainConnection.bind(this), null); 352 var target = this.createTarget(Common.UIString('Main'), capabilities, this._ createMainConnection.bind(this), null);
353 target.runtimeAgent().runIfWaitingForDebugger(); 353 target.runtimeAgent().runIfWaitingForDebugger();
354 } 354 }
355 355
356 /** 356 /**
357 * @param {!InspectorBackendClass.Connection.Params} params 357 * @param {!Protocol.InspectorBackend.Connection.Params} params
358 * @return {!InspectorBackendClass.Connection} 358 * @return {!Protocol.InspectorBackend.Connection}
359 */ 359 */
360 _createMainConnection(params) { 360 _createMainConnection(params) {
361 if (Runtime.queryParam('ws')) { 361 if (Runtime.queryParam('ws')) {
362 var ws = 'ws://' + Runtime.queryParam('ws'); 362 var ws = 'ws://' + Runtime.queryParam('ws');
363 this._mainConnection = new SDK.WebSocketConnection(ws, this._webSocketConn ectionLostCallback, params); 363 this._mainConnection = new SDK.WebSocketConnection(ws, this._webSocketConn ectionLostCallback, params);
364 } else if (InspectorFrontendHost.isHostedMode()) { 364 } else if (InspectorFrontendHost.isHostedMode()) {
365 this._mainConnection = new SDK.StubConnection(params); 365 this._mainConnection = new SDK.StubConnection(params);
366 } else { 366 } else {
367 this._mainConnection = new SDK.MainConnection(params); 367 this._mainConnection = new SDK.MainConnection(params);
368 } 368 }
369 return this._mainConnection; 369 return this._mainConnection;
370 } 370 }
371 371
372 /** 372 /**
373 * @param {function(string)} onMessage 373 * @param {function(string)} onMessage
374 * @return {!Promise<!InspectorBackendClass.Connection>} 374 * @return {!Promise<!Protocol.InspectorBackend.Connection>}
375 */ 375 */
376 interceptMainConnection(onMessage) { 376 interceptMainConnection(onMessage) {
377 var params = {onMessage: onMessage, onDisconnect: this._connectAndCreateMain Target.bind(this)}; 377 var params = {onMessage: onMessage, onDisconnect: this._connectAndCreateMain Target.bind(this)};
378 return this._mainConnection.disconnect().then(this._createMainConnection.bin d(this, params)); 378 return this._mainConnection.disconnect().then(this._createMainConnection.bin d(this, params));
379 } 379 }
380 }; 380 };
381 381
382 /** @enum {symbol} */ 382 /** @enum {symbol} */
383 SDK.TargetManager.Events = { 383 SDK.TargetManager.Events = {
384 InspectedURLChanged: Symbol('InspectedURLChanged'), 384 InspectedURLChanged: Symbol('InspectedURLChanged'),
(...skipping 22 matching lines...) Expand all
407 /** 407 /**
408 * @param {!SDK.Target} target 408 * @param {!SDK.Target} target
409 */ 409 */
410 targetRemoved(target) {}, 410 targetRemoved(target) {},
411 }; 411 };
412 412
413 /** 413 /**
414 * @type {!SDK.TargetManager} 414 * @type {!SDK.TargetManager}
415 */ 415 */
416 SDK.targetManager = new SDK.TargetManager(); 416 SDK.targetManager = new SDK.TargetManager();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698