Commit c09a47ce authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

DevTools: Push context id to the client on 'window object cleared' event.

Review URL: http://codereview.chromium.org/155217

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20146 0039d316-1c4b-4281-b951-d872f2087c98
parent 3641da6c
...@@ -35,8 +35,8 @@ DEFINE_RPC_CLASS(DebuggerAgent, DEBUGGER_AGENT_STRUCT) ...@@ -35,8 +35,8 @@ DEFINE_RPC_CLASS(DebuggerAgent, DEBUGGER_AGENT_STRUCT)
METHOD4) \ METHOD4) \
METHOD1(DebuggerOutput, std::string /* output text */) \ METHOD1(DebuggerOutput, std::string /* output text */) \
\ \
/* Response to GetContextId. */ \ /* Pushes debugger context id into the client. */ \
METHOD1(DidGetContextId, int /* context id */) \ METHOD1(SetContextId, int /* context id */) \
\ \
/* Response to IsProfilingStarted. */ \ /* Response to IsProfilingStarted. */ \
METHOD1(DidIsProfilingStarted, bool /* is_started */) \ METHOD1(DidIsProfilingStarted, bool /* is_started */) \
......
...@@ -55,7 +55,7 @@ void DebuggerAgentImpl::DebugBreak() { ...@@ -55,7 +55,7 @@ void DebuggerAgentImpl::DebugBreak() {
} }
void DebuggerAgentImpl::GetContextId() { void DebuggerAgentImpl::GetContextId() {
delegate_->DidGetContextId(webdevtools_agent_->host_id()); delegate_->SetContextId(webdevtools_agent_->host_id());
} }
void DebuggerAgentImpl::StartProfiling() { void DebuggerAgentImpl::StartProfiling() {
......
...@@ -15,8 +15,8 @@ goog.provide('devtools.DebuggerAgent'); ...@@ -15,8 +15,8 @@ goog.provide('devtools.DebuggerAgent');
devtools.DebuggerAgent = function() { devtools.DebuggerAgent = function() {
RemoteDebuggerAgent.DebuggerOutput = RemoteDebuggerAgent.DebuggerOutput =
goog.bind(this.handleDebuggerOutput_, this); goog.bind(this.handleDebuggerOutput_, this);
RemoteDebuggerAgent.DidGetContextId = RemoteDebuggerAgent.SetContextId =
goog.bind(this.didGetContextId_, this); goog.bind(this.setContextId_, this);
RemoteDebuggerAgent.DidIsProfilingStarted = RemoteDebuggerAgent.DidIsProfilingStarted =
goog.bind(this.didIsProfilingStarted_, this); goog.bind(this.didIsProfilingStarted_, this);
RemoteDebuggerAgent.DidGetNextLogLines = RemoteDebuggerAgent.DidGetNextLogLines =
...@@ -118,27 +118,19 @@ devtools.DebuggerAgent.prototype.reset = function() { ...@@ -118,27 +118,19 @@ devtools.DebuggerAgent.prototype.reset = function() {
}; };
/**
* Requests scripts list if it has not been requested yet.
*/
devtools.DebuggerAgent.prototype.initializeScriptsCache = function() {
if (!this.scriptsCacheInitialized_) {
this.scriptsCacheInitialized_ = true;
this.requestScripts();
}
};
/** /**
* Asynchronously requests for all parsed script sources. Response will be * Asynchronously requests for all parsed script sources. Response will be
* processed in handleScriptsResponse_. * processed in handleScriptsResponse_.
*/ */
devtools.DebuggerAgent.prototype.requestScripts = function() { devtools.DebuggerAgent.prototype.requestScripts = function() {
if (this.contextId_ === null) { if (this.contextId_) {
// Update context id first to filter the scripts. // We already have context id. This means that we are here from the
RemoteDebuggerAgent.GetContextId(); // very beginning of the page load cycle and hence will get all scripts
// via after-compile events. No need to request scripts for this session.
return; return;
} }
RemoteDebuggerAgent.GetContextId();
var cmd = new devtools.DebugCommand('scripts', { var cmd = new devtools.DebugCommand('scripts', {
'includeSource': false 'includeSource': false
}); });
...@@ -545,13 +537,11 @@ devtools.DebuggerAgent.prototype.requestLookup_ = function(handles, callback) { ...@@ -545,13 +537,11 @@ devtools.DebuggerAgent.prototype.requestLookup_ = function(handles, callback) {
/** /**
* Handles GetContextId response. * Sets debugger context id for scripts filtering.
* @param {number} contextId Id of the inspected page global context. * @param {number} contextId Id of the inspected page global context.
*/ */
devtools.DebuggerAgent.prototype.didGetContextId_ = function(contextId) { devtools.DebuggerAgent.prototype.setContextId_ = function(contextId) {
this.contextId_ = contextId; this.contextId_ = contextId;
// Update scripts.
this.requestScripts();
}; };
...@@ -719,7 +709,7 @@ devtools.DebuggerAgent.prototype.handleSetBreakpointResponse_ = function(msg) { ...@@ -719,7 +709,7 @@ devtools.DebuggerAgent.prototype.handleSetBreakpointResponse_ = function(msg) {
* @param {devtools.DebuggerMessage} msg * @param {devtools.DebuggerMessage} msg
*/ */
devtools.DebuggerAgent.prototype.handleAfterCompileEvent_ = function(msg) { devtools.DebuggerAgent.prototype.handleAfterCompileEvent_ = function(msg) {
if (!this.scriptsCacheInitialized_) { if (!this.contextId_) {
// Ignore scripts delta if main request has not been issued yet. // Ignore scripts delta if main request has not been issued yet.
return; return;
} }
......
...@@ -906,7 +906,7 @@ WebInspector.ScriptsPanel.prototype.doEvalInCallFrame = ...@@ -906,7 +906,7 @@ WebInspector.ScriptsPanel.prototype.doEvalInCallFrame =
(function() { (function() {
var oldShow = WebInspector.ScriptsPanel.prototype.show; var oldShow = WebInspector.ScriptsPanel.prototype.show;
WebInspector.ScriptsPanel.prototype.show = function() { WebInspector.ScriptsPanel.prototype.show = function() {
devtools.tools.getDebuggerAgent().initializeScriptsCache(); devtools.tools.getDebuggerAgent().requestScripts();
this.enableToggleButton.addStyleClass('hidden'); this.enableToggleButton.addStyleClass('hidden');
oldShow.call(this); oldShow.call(this);
}; };
......
...@@ -167,6 +167,10 @@ void WebDevToolsAgentImpl::DidCommitLoadForFrame( ...@@ -167,6 +167,10 @@ void WebDevToolsAgentImpl::DidCommitLoadForFrame(
void WebDevToolsAgentImpl::WindowObjectCleared(WebFrameImpl* webframe) { void WebDevToolsAgentImpl::WindowObjectCleared(WebFrameImpl* webframe) {
DebuggerAgentManager::SetHostId(webframe, host_id_); DebuggerAgentManager::SetHostId(webframe, host_id_);
if (attached_) {
// Push context id into the client if it is already attached.
debugger_agent_delegate_stub_->SetContextId(host_id_);
}
} }
void WebDevToolsAgentImpl::ForceRepaint() { void WebDevToolsAgentImpl::ForceRepaint() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment