diff options
author | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 11:30:27 +0000 |
---|---|---|
committer | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 11:30:27 +0000 |
commit | 4052c7343b977d7865405600d7e99b016f06dec4 (patch) | |
tree | f4f9f68dee13170014cfde6a87da8662c2a7504c | |
parent | 9f6d5c90aa6379f961c450fa6c7aab84a3b4a25f (diff) | |
download | chromium_src-4052c7343b977d7865405600d7e99b016f06dec4.zip chromium_src-4052c7343b977d7865405600d7e99b016f06dec4.tar.gz chromium_src-4052c7343b977d7865405600d7e99b016f06dec4.tar.bz2 |
DevTools: to speed up devtools start up time script sources are omitted from the 'scripts' response. They are requested on demand when user selects corresponding file in the Scripts panel.
Review URL: http://codereview.chromium.org/113521
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16272 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/glue/devtools/js/debugger_agent.js | 43 | ||||
-rw-r--r-- | webkit/glue/devtools/js/devtools.js | 42 |
2 files changed, 84 insertions, 1 deletions
diff --git a/webkit/glue/devtools/js/debugger_agent.js b/webkit/glue/devtools/js/debugger_agent.js index 8f34ca8..9f0c2a3 100644 --- a/webkit/glue/devtools/js/debugger_agent.js +++ b/webkit/glue/devtools/js/debugger_agent.js @@ -122,11 +122,45 @@ devtools.DebuggerAgent.prototype.requestScripts = function() { return; } var cmd = new devtools.DebugCommand('scripts', { + 'includeSource': false + }); + devtools.DebuggerAgent.sendCommand_(cmd); + // Force v8 execution so that it gets to processing the requested command. + devtools.tools.evaluateJavaScript('javascript:void(0)'); +}; + + +/** + * Asynchronously requests the debugger for the script source. + * @param {number} scriptId Id of the script whose source should be resolved. + * @param {function(source:?string):void} callback Function that will be called + * when the source resolution is completed. 'source' parameter will be null + * if the resolution fails. + */ +devtools.DebuggerAgent.prototype.resolveScriptSource = function( + scriptId, callback) { + var script = this.parsedScripts_[scriptId]; + if (!script) { + callback(null); + return; + } + + var cmd = new devtools.DebugCommand('scripts', { + 'ids': [scriptId], 'includeSource': true }); devtools.DebuggerAgent.sendCommand_(cmd); // Force v8 execution so that it gets to processing the requested command. devtools.tools.evaluateJavaScript('javascript:void(0)'); + + this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) { + if (msg.isSuccess()) { + var scriptJson = msg.getBody()[0]; + callback(scriptJson.source); + } else { + callback(null); + } + }; }; @@ -491,6 +525,10 @@ devtools.DebuggerAgent.prototype.handleExceptionEvent_ = function(msg) { * @param {devtools.DebuggerMessage} msg */ devtools.DebuggerAgent.prototype.handleScriptsResponse_ = function(msg) { + if (this.invokeCallbackForResponse_(msg)) { + return; + } + var scripts = msg.getBody(); for (var i = 0; i < scripts.length; i++) { var script = scripts[i]; @@ -644,15 +682,18 @@ devtools.DebuggerAgent.prototype.handleBacktraceResponse_ = function(msg) { /** * Handles response to a command by invoking its callback (if any). * @param {devtools.DebuggerMessage} msg + * @return {boolean} Whether a callback for the given message was found and + * excuted. */ devtools.DebuggerAgent.prototype.invokeCallbackForResponse_ = function(msg) { var callback = this.requestSeqToCallback_[msg.getRequestSeq()]; if (!callback) { // It may happend if reset was called. - return; + return false; } delete this.requestSeqToCallback_[msg.getRequestSeq()]; callback(msg); + return true; }; diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js index f201fb3..d7c0072 100644 --- a/webkit/glue/devtools/js/devtools.js +++ b/webkit/glue/devtools/js/devtools.js @@ -509,6 +509,48 @@ WebInspector.SourceView.prototype.setupSourceFrameIfNeeded = function() { /** + * This override is necessary for adding script source asynchronously. + * @override + */ +WebInspector.ScriptView.prototype.setupSourceFrameIfNeeded = function() { + if (!this._frameNeedsSetup) { + return; + } + + this.attach(); + + if (this.script.source) { + this.didResolveScriptSource_(); + } else { + var self = this; + devtools.tools.getDebuggerAgent().resolveScriptSource( + this.script.sourceID, + function(source) { + self.script.source = source || '<source is not available>'; + self.didResolveScriptSource_(); + }); + } +}; + + +/** + * Performs source frame setup when script source is aready resolved. + */ +WebInspector.ScriptView.prototype.didResolveScriptSource_ = function() { + if (!InspectorController.addSourceToFrame( + "text/javascript", this.script.source, this.sourceFrame.element)) { + return; + } + + delete this._frameNeedsSetup; + + this.sourceFrame.addEventListener( + "syntax highlighting complete", this._syntaxHighlightingComplete, this); + this.sourceFrame.syntaxHighlightJavascript(); +}; + + +/** * Dummy object used during properties inspection. * @see WebInspector.didGetNodePropertiesAsync_ */ |