Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 12 matching lines...) Expand all Loading... | |
| 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @implements {WebInspector.TargetManager.MainChannelInterceptor} | |
| 33 * @suppressGlobalPropertiesCheck | 34 * @suppressGlobalPropertiesCheck |
| 34 */ | 35 */ |
| 35 WebInspector.Main = function() | 36 WebInspector.Main = function() |
| 36 { | 37 { |
| 37 WebInspector.Main._instanceForTest = this; | 38 WebInspector.Main._instanceForTest = this; |
| 38 runOnWindowLoad(this._loaded.bind(this)); | 39 runOnWindowLoad(this._loaded.bind(this)); |
| 39 } | 40 } |
| 40 | 41 |
| 41 WebInspector.Main.prototype = { | 42 WebInspector.Main.prototype = { |
| 42 _loaded: function() | 43 _loaded: function() |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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._connectAndCreateTarget(); | 265 this._connectAndCreateTarget(); |
| 265 }, | 266 }, |
| 266 | 267 |
| 267 _connectAndCreateTarget: function() | 268 _connectAndCreateTarget: function() |
| 268 { | 269 { |
| 269 console.time("Main._connectAndCreateTarget"); | 270 console.time("Main._connectAndCreateTarget"); |
| 270 this._createConnection().then(connection => { | 271 this._createChannel().then(channel => { |
| 271 this._createMainTarget(connection); | 272 this._mainChannel = channel; |
| 273 this._createMainTarget(channel); | |
| 272 InspectorFrontendHost.readyForTest(); | 274 InspectorFrontendHost.readyForTest(); |
| 273 WebInspector.targetManager.setMainTargetFactory(this._recreateMainTa rget.bind(this)); | 275 WebInspector.targetManager.setMainChannelInterceptor(this); |
|
pfeldman
2016/10/21 21:04:34
design: awkward API
| |
| 274 // Asynchronously run the extensions. | 276 // Asynchronously run the extensions. |
| 275 console.timeEnd("Main._connectAndCreateTarget"); | 277 console.timeEnd("Main._connectAndCreateTarget"); |
| 276 setTimeout(this._lateInitialization.bind(this), 100); | 278 setTimeout(this._lateInitialization.bind(this), 100); |
| 277 }); | 279 }); |
| 278 }, | 280 }, |
| 279 | 281 |
| 280 _recreateMainTarget: function() | 282 /** |
| 283 * @override | |
| 284 * @return {!Promise<!InspectorBackendClass.Channel>} | |
| 285 */ | |
| 286 takeMainChannel: function() | |
| 281 { | 287 { |
| 282 this._createConnection().then(this._createMainTarget.bind(this)); | 288 var fulfill; |
| 289 var promise = new Promise(resolve => fulfill = resolve); | |
| 290 this._mainChannel.reconnect(() => fulfill(this._mainChannel)); | |
|
pfeldman
2016/10/21 21:04:34
return this._mainChannel.reconnect().then(() => th
| |
| 291 return promise; | |
| 283 }, | 292 }, |
| 284 | 293 |
| 285 /** | 294 /** |
| 286 * @return {!Promise<!InspectorBackendClass.Connection>} | 295 * @override |
| 287 */ | 296 */ |
| 288 _createConnection: function() | 297 yieldMainChannel: function() |
| 298 { | |
| 299 this._mainChannel.reconnect(() => this._createMainTarget(this._mainChann el)); | |
| 300 }, | |
| 301 | |
| 302 /** | |
| 303 * @return {!Promise<!InspectorBackendClass.Channel>} | |
| 304 */ | |
| 305 _createChannel: function() | |
| 289 { | 306 { |
| 290 if (Runtime.queryParam("ws")) { | 307 if (Runtime.queryParam("ws")) { |
| 291 var ws = "ws://" + Runtime.queryParam("ws"); | 308 var ws = "ws://" + Runtime.queryParam("ws"); |
| 292 return WebInspector.WebSocketConnection.Create(ws).then(connection = > { | 309 return WebInspector.WebSocketChannel.Create(ws).then(channel => { |
|
pfeldman
2016/10/21 21:04:34
You are just renaming connection to channel, while
| |
| 293 connection.addEventListener(InspectorBackendClass.Connection.Eve nts.Disconnected, onDisconnected); | 310 channel.addEventListener(InspectorBackendClass.Channel.Events.Ch annelClosed, onChannelClosed); |
| 294 return connection; | 311 return channel; |
| 295 }); | 312 }); |
| 296 } | 313 } |
| 297 | 314 |
| 298 return /** @type {!Promise<!InspectorBackendClass.Connection>} */ (Promi se.resolve(InspectorFrontendHost.isHostedMode() ? | 315 return /** @type {!Promise<!InspectorBackendClass.Channel>} */ (Promise. resolve(InspectorFrontendHost.isHostedMode() ? |
| 299 new WebInspector.StubConnection() : new WebInspector.MainConnection( ))); | 316 new WebInspector.StubChannel() : new WebInspector.MainChannel())); |
| 300 | 317 |
| 301 /** | 318 /** |
| 302 * @param {!WebInspector.Event} event | 319 * @param {!WebInspector.Event} event |
| 303 */ | 320 */ |
| 304 function onDisconnected(event) | 321 function onChannelClosed(event) |
| 305 { | 322 { |
| 306 if (WebInspector._disconnectedScreenWithReasonWasShown) | 323 if (WebInspector._disconnectedScreenWithReasonWasShown) |
| 307 return; | 324 return; |
| 308 WebInspector.RemoteDebuggingTerminatedScreen.show(event.data.reason) ; | 325 WebInspector.RemoteDebuggingTerminatedScreen.show(event.data.reason) ; |
| 309 } | 326 } |
| 310 }, | 327 }, |
| 311 | 328 |
| 312 /** | 329 /** |
| 313 * @param {!InspectorBackendClass.Connection} connection | 330 * @param {!InspectorBackendClass.Channel} channel |
| 314 */ | 331 */ |
| 315 _createMainTarget: function(connection) | 332 _createMainTarget: function(channel) |
| 316 { | 333 { |
| 317 console.time("Main._createMainTarget"); | 334 console.time("Main._createMainTarget"); |
| 318 var capabilities = | 335 var capabilities = |
| 319 WebInspector.Target.Capability.Browser | WebInspector.Target.Capabil ity.DOM | | 336 WebInspector.Target.Capability.Browser | WebInspector.Target.Capabil ity.DOM | |
| 320 WebInspector.Target.Capability.JS | WebInspector.Target.Capability.L og | | 337 WebInspector.Target.Capability.JS | WebInspector.Target.Capability.L og | |
| 321 WebInspector.Target.Capability.Network | WebInspector.Target.Capabil ity.Worker; | 338 WebInspector.Target.Capability.Network | WebInspector.Target.Capabil ity.Worker; |
| 322 if (Runtime.queryParam("isSharedWorker")) { | 339 if (Runtime.queryParam("isSharedWorker")) { |
| 323 capabilities = | 340 capabilities = |
| 324 WebInspector.Target.Capability.Browser | WebInspector.Target.Cap ability.Log | | 341 WebInspector.Target.Capability.Browser | WebInspector.Target.Cap ability.Log | |
| 325 WebInspector.Target.Capability.Network | WebInspector.Target.Cap ability.Worker; | 342 WebInspector.Target.Capability.Network | WebInspector.Target.Cap ability.Worker; |
| 326 } else if (Runtime.queryParam("v8only")) { | 343 } else if (Runtime.queryParam("v8only")) { |
| 327 capabilities = WebInspector.Target.Capability.JS; | 344 capabilities = WebInspector.Target.Capability.JS; |
| 328 } | 345 } |
| 329 | 346 |
| 330 var target = WebInspector.targetManager.createTarget(WebInspector.UIStri ng("Main"), capabilities, connection, null); | 347 var target = WebInspector.targetManager.createTarget(WebInspector.UIStri ng("Main"), capabilities, channel, null); |
| 331 target.registerInspectorDispatcher(new WebInspector.Main.InspectorDomain Dispatcher(target)); | 348 target.registerInspectorDispatcher(new WebInspector.Main.InspectorDomain Dispatcher(target)); |
| 332 target.runtimeAgent().runIfWaitingForDebugger(); | 349 target.runtimeAgent().runIfWaitingForDebugger(); |
| 333 if (target.hasBrowserCapability()) | 350 if (target.hasBrowserCapability()) |
| 334 target.inspectorAgent().enable(); | 351 target.inspectorAgent().enable(); |
| 335 console.timeEnd("Main._createMainTarget"); | 352 console.timeEnd("Main._createMainTarget"); |
| 336 }, | 353 }, |
| 337 | 354 |
| 338 _lateInitialization: function() | 355 _lateInitialization: function() |
| 339 { | 356 { |
| 340 console.timeStamp("Main._lateInitialization"); | 357 console.timeStamp("Main._lateInitialization"); |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 940 * @param {!WebInspector.Event} event | 957 * @param {!WebInspector.Event} event |
| 941 */ | 958 */ |
| 942 _inspectNode: function(event) | 959 _inspectNode: function(event) |
| 943 { | 960 { |
| 944 var deferredNode = /** @type {!WebInspector.DeferredDOMNode} */ (event.d ata); | 961 var deferredNode = /** @type {!WebInspector.DeferredDOMNode} */ (event.d ata); |
| 945 WebInspector.Revealer.reveal(deferredNode); | 962 WebInspector.Revealer.reveal(deferredNode); |
| 946 } | 963 } |
| 947 } | 964 } |
| 948 | 965 |
| 949 /** | 966 /** |
| 950 * @param {string} method | |
| 951 * @param {?Object} params | |
| 952 * @return {!Promise} | |
| 953 */ | |
| 954 WebInspector.sendOverProtocol = function(method, params) | |
| 955 { | |
| 956 var connection = WebInspector.targetManager.mainTarget().connection(); | |
| 957 return new Promise((resolve, reject) => { | |
| 958 connection.sendRawMessageForTesting(method, params, (err, result) => { | |
| 959 if (err) | |
| 960 return reject(err); | |
| 961 return resolve(result); | |
| 962 }); | |
| 963 }); | |
| 964 } | |
| 965 | |
| 966 /** | |
| 967 * @constructor | 967 * @constructor |
| 968 * @extends {WebInspector.VBox} | 968 * @extends {WebInspector.VBox} |
| 969 * @param {string} reason | 969 * @param {string} reason |
| 970 */ | 970 */ |
| 971 WebInspector.RemoteDebuggingTerminatedScreen = function(reason) | 971 WebInspector.RemoteDebuggingTerminatedScreen = function(reason) |
| 972 { | 972 { |
| 973 WebInspector.VBox.call(this, true); | 973 WebInspector.VBox.call(this, true); |
| 974 this.registerRequiredCSS("main/remoteDebuggingTerminatedScreen.css"); | 974 this.registerRequiredCSS("main/remoteDebuggingTerminatedScreen.css"); |
| 975 var message = this.contentElement.createChild("div", "message"); | 975 var message = this.contentElement.createChild("div", "message"); |
| 976 message.createChild("span").textContent = WebInspector.UIString("Debugging c onnection was closed. Reason: "); | 976 message.createChild("span").textContent = WebInspector.UIString("Debugging c onnection was closed. Reason: "); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1108 * @override | 1108 * @override |
| 1109 * @return {?Element} | 1109 * @return {?Element} |
| 1110 */ | 1110 */ |
| 1111 settingElement: function() | 1111 settingElement: function() |
| 1112 { | 1112 { |
| 1113 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIStri ng("Show rulers"), WebInspector.moduleSetting("showMetricsRulers")); | 1113 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIStri ng("Show rulers"), WebInspector.moduleSetting("showMetricsRulers")); |
| 1114 } | 1114 } |
| 1115 } | 1115 } |
| 1116 | 1116 |
| 1117 new WebInspector.Main(); | 1117 new WebInspector.Main(); |
| OLD | NEW |