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)
METHOD4) \
METHOD1(DebuggerOutput, std::string /* output text */) \
\
/* Response to GetContextId. */ \
METHOD1(DidGetContextId, int /* context id */) \
/* Pushes debugger context id into the client. */ \
METHOD1(SetContextId, int /* context id */) \
\
/* Response to IsProfilingStarted. */ \
METHOD1(DidIsProfilingStarted, bool /* is_started */) \
......
......@@ -55,7 +55,7 @@ void DebuggerAgentImpl::DebugBreak() {
}
void DebuggerAgentImpl::GetContextId() {
delegate_->DidGetContextId(webdevtools_agent_->host_id());
delegate_->SetContextId(webdevtools_agent_->host_id());
}
void DebuggerAgentImpl::StartProfiling() {
......
......@@ -15,8 +15,8 @@ goog.provide('devtools.DebuggerAgent');
devtools.DebuggerAgent = function() {
RemoteDebuggerAgent.DebuggerOutput =
goog.bind(this.handleDebuggerOutput_, this);
RemoteDebuggerAgent.DidGetContextId =
goog.bind(this.didGetContextId_, this);
RemoteDebuggerAgent.SetContextId =
goog.bind(this.setContextId_, this);
RemoteDebuggerAgent.DidIsProfilingStarted =
goog.bind(this.didIsProfilingStarted_, this);
RemoteDebuggerAgent.DidGetNextLogLines =
......@@ -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
* processed in handleScriptsResponse_.
*/
devtools.DebuggerAgent.prototype.requestScripts = function() {
if (this.contextId_ === null) {
// Update context id first to filter the scripts.
RemoteDebuggerAgent.GetContextId();
if (this.contextId_) {
// We already have context id. This means that we are here from the
// 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;
}
RemoteDebuggerAgent.GetContextId();
var cmd = new devtools.DebugCommand('scripts', {
'includeSource': false
});
......@@ -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.
*/
devtools.DebuggerAgent.prototype.didGetContextId_ = function(contextId) {
devtools.DebuggerAgent.prototype.setContextId_ = function(contextId) {
this.contextId_ = contextId;
// Update scripts.
this.requestScripts();
};
......@@ -719,7 +709,7 @@ devtools.DebuggerAgent.prototype.handleSetBreakpointResponse_ = function(msg) {
* @param {devtools.DebuggerMessage} msg
*/
devtools.DebuggerAgent.prototype.handleAfterCompileEvent_ = function(msg) {
if (!this.scriptsCacheInitialized_) {
if (!this.contextId_) {
// Ignore scripts delta if main request has not been issued yet.
return;
}
......
......@@ -906,7 +906,7 @@ WebInspector.ScriptsPanel.prototype.doEvalInCallFrame =
(function() {
var oldShow = WebInspector.ScriptsPanel.prototype.show;
WebInspector.ScriptsPanel.prototype.show = function() {
devtools.tools.getDebuggerAgent().initializeScriptsCache();
devtools.tools.getDebuggerAgent().requestScripts();
this.enableToggleButton.addStyleClass('hidden');
oldShow.call(this);
};
......
......@@ -167,6 +167,10 @@ void WebDevToolsAgentImpl::DidCommitLoadForFrame(
void WebDevToolsAgentImpl::WindowObjectCleared(WebFrameImpl* webframe) {
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() {
......
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