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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/main/Main.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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/sdk/Connections.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 new WebInspector.NetworkPanelIndicator(); 200 new WebInspector.NetworkPanelIndicator();
201 new WebInspector.SourcesPanelIndicator(); 201 new WebInspector.SourcesPanelIndicator();
202 new WebInspector.BackendSettingsSync(); 202 new WebInspector.BackendSettingsSync();
203 WebInspector.domBreakpointsSidebarPane = new WebInspector.DOMBreakpoints SidebarPane(); 203 WebInspector.domBreakpointsSidebarPane = new WebInspector.DOMBreakpoints SidebarPane();
204 204
205 WebInspector.actionRegistry = new WebInspector.ActionRegistry(); 205 WebInspector.actionRegistry = new WebInspector.ActionRegistry();
206 WebInspector.shortcutRegistry = new WebInspector.ShortcutRegistry(WebIns pector.actionRegistry, document); 206 WebInspector.shortcutRegistry = new WebInspector.ShortcutRegistry(WebIns pector.actionRegistry, document);
207 WebInspector.ShortcutsScreen.registerShortcuts(); 207 WebInspector.ShortcutsScreen.registerShortcuts();
208 this._registerForwardedShortcuts(); 208 this._registerForwardedShortcuts();
209 this._registerMessageSinkListener(); 209 this._registerMessageSinkListener();
210 new WebInspector.Main.InspectorDomainObserver();
210 211
211 self.runtime.extension(WebInspector.AppProvider).instance().then(this._s howAppUI.bind(this)); 212 self.runtime.extension(WebInspector.AppProvider).instance().then(this._s howAppUI.bind(this));
212 console.timeEnd("Main._createAppUI"); 213 console.timeEnd("Main._createAppUI");
213 }, 214 },
214 215
215 /** 216 /**
216 * @param {!Object} appProvider 217 * @param {!Object} appProvider
217 * @suppressGlobalPropertiesCheck 218 * @suppressGlobalPropertiesCheck
218 */ 219 */
219 _showAppUI: function(appProvider) 220 _showAppUI: function(appProvider)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 260
260 _didInitializeFileSystemManager: function() 261 _didInitializeFileSystemManager: function()
261 { 262 {
262 this._fileSystemManagerInitialized = true; 263 this._fileSystemManagerInitialized = true;
263 if (this._appUIShown) 264 if (this._appUIShown)
264 this._initializeTarget(); 265 this._initializeTarget();
265 }, 266 },
266 267
267 _initializeTarget: function() 268 _initializeTarget: function()
268 { 269 {
269 this._connectAndCreateTarget(); 270 console.time("Main._initializeTarget");
271 WebInspector.targetManager.connectToMainTarget(webSocketConnectionLost);
272
270 InspectorFrontendHost.readyForTest(); 273 InspectorFrontendHost.readyForTest();
271 WebInspector.targetManager.setMainConnectionInterceptor(this._interceptM ainConnection.bind(this));
272 // Asynchronously run the extensions. 274 // Asynchronously run the extensions.
273 setTimeout(this._lateInitialization.bind(this), 100); 275 setTimeout(this._lateInitialization.bind(this), 100);
274 }, 276 console.timeEnd("Main._initializeTarget");
275 277
276 _connectAndCreateTarget: function() 278 function webSocketConnectionLost()
277 {
278 console.time("Main._connectAndCreateTarget");
279
280 var capabilities =
281 WebInspector.Target.Capability.Browser | WebInspector.Target.Capabil ity.DOM |
282 WebInspector.Target.Capability.JS | WebInspector.Target.Capability.L og |
283 WebInspector.Target.Capability.Network | WebInspector.Target.Capabil ity.Target;
284 if (Runtime.queryParam("isSharedWorker")) {
285 capabilities =
286 WebInspector.Target.Capability.Browser | WebInspector.Target.Cap ability.Log |
287 WebInspector.Target.Capability.Network | WebInspector.Target.Cap ability.Target;
288 } else if (Runtime.queryParam("v8only")) {
289 capabilities = WebInspector.Target.Capability.JS;
290 }
291
292 var target = WebInspector.targetManager.createTarget(WebInspector.UIStri ng("Main"), capabilities, this._createMainConnection.bind(this), null);
293 target.registerInspectorDispatcher(new WebInspector.Main.InspectorDomain Dispatcher(target));
294 target.runtimeAgent().runIfWaitingForDebugger();
295 if (target.hasBrowserCapability())
296 target.inspectorAgent().enable();
297
298 console.timeEnd("Main._connectAndCreateTarget");
299 },
300
301 /**
302 * @param {function(string)} onMessage
303 * @return {!Promise<!InspectorBackendClass.Connection>}
304 */
305 _interceptMainConnection: function(onMessage)
306 {
307 var params = {
308 onMessage: onMessage,
309 onDisconnect: this._connectAndCreateTarget.bind(this)
310 };
311 return this._connection.disconnect().then(this._createMainConnection.bin d(this, params));
312 },
313
314 /**
315 * @param {!InspectorBackendClass.Connection.Params} params
316 * @return {!InspectorBackendClass.Connection}
317 */
318 _createMainConnection: function(params)
319 {
320 if (Runtime.queryParam("ws")) {
321 var ws = "ws://" + Runtime.queryParam("ws");
322 params.onDisconnect = onDisconnect.bind(null, params.onDisconnect);
323 this._connection = new WebInspector.WebSocketConnection(ws, params);
324 } else if (InspectorFrontendHost.isHostedMode()) {
325 this._connection = new WebInspector.StubConnection(params);
326 } else {
327 this._connection = new WebInspector.MainConnection(params);
328 }
329 return this._connection;
330
331 /**
332 * @param {function(string)} callback
333 * @param {string} reason
334 */
335 function onDisconnect(callback, reason)
336 { 279 {
337 if (!WebInspector._disconnectedScreenWithReasonWasShown) 280 if (!WebInspector._disconnectedScreenWithReasonWasShown)
338 WebInspector.RemoteDebuggingTerminatedScreen.show(reason); 281 WebInspector.RemoteDebuggingTerminatedScreen.show("WebSocket dis connected");
339 callback(reason);
340 } 282 }
341 }, 283 },
342 284
343 _lateInitialization: function() 285 _lateInitialization: function()
344 { 286 {
345 console.timeStamp("Main._lateInitialization"); 287 console.timeStamp("Main._lateInitialization");
346 this._registerShortcuts(); 288 this._registerShortcuts();
347 WebInspector.extensionServer.initializeExtensions(); 289 WebInspector.extensionServer.initializeExtensions();
348 }, 290 },
349 291
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 490
549 _onSuspendStateChanged: function() 491 _onSuspendStateChanged: function()
550 { 492 {
551 var suspended = WebInspector.targetManager.allTargetsSuspended(); 493 var suspended = WebInspector.targetManager.allTargetsSuspended();
552 WebInspector.inspectorView.onSuspendStateChanged(suspended); 494 WebInspector.inspectorView.onSuspendStateChanged(suspended);
553 } 495 }
554 }; 496 };
555 497
556 /** 498 /**
557 * @constructor 499 * @constructor
500 * @implements {WebInspector.TargetManager.Observer}
501 */
502 WebInspector.Main.InspectorDomainObserver = function()
503 {
504 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili ty.Browser);
505 };
506
507 WebInspector.Main.InspectorDomainObserver.prototype = {
508 /**
509 * @override
510 * @param {!WebInspector.Target} target
511 */
512 targetAdded: function(target)
513 {
514 target.registerInspectorDispatcher(new WebInspector.Main.InspectorDomain Dispatcher(target));
515 target.inspectorAgent().enable();
516 },
517
518 /**
519 * @override
520 * @param {!WebInspector.Target} target
521 */
522 targetRemoved: function(target)
523 {
524 },
525 };
526
527 /**
528 * @constructor
558 * @implements {InspectorAgent.Dispatcher} 529 * @implements {InspectorAgent.Dispatcher}
559 * @param {!WebInspector.Target} target 530 * @param {!WebInspector.Target} target
560 */ 531 */
561 WebInspector.Main.InspectorDomainDispatcher = function(target) 532 WebInspector.Main.InspectorDomainDispatcher = function(target)
562 { 533 {
563 this._target = target; 534 this._target = target;
564 }; 535 };
565 536
566 WebInspector.Main.InspectorDomainDispatcher.prototype = { 537 WebInspector.Main.InspectorDomainDispatcher.prototype = {
567 /** 538 /**
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 * @override 1083 * @override
1113 * @return {?Element} 1084 * @return {?Element}
1114 */ 1085 */
1115 settingElement: function() 1086 settingElement: function()
1116 { 1087 {
1117 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIStri ng("Show rulers"), WebInspector.moduleSetting("showMetricsRulers")); 1088 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIStri ng("Show rulers"), WebInspector.moduleSetting("showMetricsRulers"));
1118 } 1089 }
1119 }; 1090 };
1120 1091
1121 new WebInspector.Main(); 1092 new WebInspector.Main();
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/sdk/Connections.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698