diff options
author | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-10 15:44:49 +0000 |
---|---|---|
committer | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-10 15:44:49 +0000 |
commit | e69b8584b153c5db5793f84d86da7c8949b8dfd1 (patch) | |
tree | 00d6181e91d61c3846cf72da45613b75bbe0fd73 /webkit | |
parent | f873d0f49aa098cea3f737d25d8c1adae5365c1c (diff) | |
download | chromium_src-e69b8584b153c5db5793f84d86da7c8949b8dfd1.zip chromium_src-e69b8584b153c5db5793f84d86da7c8949b8dfd1.tar.gz chromium_src-e69b8584b153c5db5793f84d86da7c8949b8dfd1.tar.bz2 |
DevTools: always send reponse to resource content request, otherwise client may break issuing request for same resource several times(e.g. when resource tracking is getting turned on).
ToolsAgentNativeDelegateImpl is recreated to clear request cache each time front-end is reset.
Review URL: http://codereview.chromium.org/118495
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18060 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/devtools/js/devtools.js | 1 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsagent_impl.cc | 16 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsclient_impl.cc | 29 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsclient_impl.h | 1 |
4 files changed, 37 insertions, 10 deletions
diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js index 30ae6ec..e3a8d98 100644 --- a/webkit/glue/devtools/js/devtools.js +++ b/webkit/glue/devtools/js/devtools.js @@ -60,6 +60,7 @@ devtools.ToolsAgent = function() { * Resets tools agent to its initial state. */ devtools.ToolsAgent.prototype.reset = function() { + DevToolsHost.reset(); this.domAgent_.reset(); this.debuggerAgent_.reset(); diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc index ae781e0..592db96 100644 --- a/webkit/glue/webdevtoolsagent_impl.cc +++ b/webkit/glue/webdevtoolsagent_impl.cc @@ -224,16 +224,16 @@ void WebDevToolsAgentImpl::ClearConsoleMessages() { void WebDevToolsAgentImpl::GetResourceContent( int call_id, int identifier) { + String content; Page* page = web_view_impl_->page(); - if (!page) { - return; - } - RefPtr<InspectorResource> resource = - page->inspectorController()->resources().get(identifier); - if (resource.get()) { - tools_agent_native_delegate_stub_->DidGetResourceContent(call_id, - resource->sourceString()); + if (page) { + RefPtr<InspectorResource> resource = + page->inspectorController()->resources().get(identifier); + if (resource.get()) { + content = resource->sourceString(); + } } + tools_agent_native_delegate_stub_->DidGetResourceContent(call_id, content); } void WebDevToolsAgentImpl::SetResourceTrackingEnabled( diff --git a/webkit/glue/webdevtoolsclient_impl.cc b/webkit/glue/webdevtoolsclient_impl.cc index 8eb7ef8..a91cea6 100644 --- a/webkit/glue/webdevtoolsclient_impl.cc +++ b/webkit/glue/webdevtoolsclient_impl.cc @@ -71,6 +71,15 @@ class ToolsAgentNativeDelegateImpl : public ToolsAgentNativeDelegate { ic->addSourceToFrame(request.mime_type, content, request.frame.get()); } + bool WaitingForResponse(int resource_id, Node* frame) { + if (resource_content_requests_.contains(resource_id)) { + DCHECK(resource_content_requests_.get(resource_id).frame.get() == frame) + << "Only one frame is expected to display given resource"; + return true; + } + return false; + } + void RequestSent(int resource_id, String mime_type, Node* frame) { ResourceContentRequestData data; data.mime_type = mime_type; @@ -137,13 +146,14 @@ WebDevToolsClientImpl::WebDevToolsClientImpl( dom_agent_obj_.set(new JsDomAgentBoundObj(this, frame, L"RemoteDomAgent")); tools_agent_obj_.set( new JsToolsAgentBoundObj(this, frame, L"RemoteToolsAgent")); - tools_agent_native_delegate_impl_.set( - new ToolsAgentNativeDelegateImpl(frame)); v8::HandleScope scope; v8::Handle<v8::Context> frame_context = V8Proxy::GetContext(frame->frame()); dev_tools_host_.set(new BoundObject(frame_context, this, "DevToolsHost")); dev_tools_host_->AddProtoFunction( + "reset", + WebDevToolsClientImpl::JsReset); + dev_tools_host_->AddProtoFunction( "addSourceToFrame", WebDevToolsClientImpl::JsAddSourceToFrame); dev_tools_host_->AddProtoFunction( @@ -191,6 +201,10 @@ void WebDevToolsClientImpl::DispatchMessageFromAgent( void WebDevToolsClientImpl::AddResourceSourceToFrame(int resource_id, String mime_type, Node* frame) { + if (tools_agent_native_delegate_impl_->WaitingForResponse(resource_id, + frame)) { + return; + } tools_agent_obj_->GetResourceContent(resource_id, resource_id); tools_agent_native_delegate_impl_->RequestSent(resource_id, mime_type, frame); } @@ -208,6 +222,17 @@ void WebDevToolsClientImpl::SendRpcMessage(const std::string& class_name, } // static +v8::Handle<v8::Value> WebDevToolsClientImpl::JsReset( + const v8::Arguments& args) { + WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( + v8::External::Cast(*args.Data())->Value()); + WebFrameImpl* frame = client->web_view_impl_->main_frame(); + client->tools_agent_native_delegate_impl_.set( + new ToolsAgentNativeDelegateImpl(frame)); + return v8::Undefined(); +} + +// static v8::Handle<v8::Value> WebDevToolsClientImpl::JsAddSourceToFrame( const v8::Arguments& args) { if (args.Length() < 2) { diff --git a/webkit/glue/webdevtoolsclient_impl.h b/webkit/glue/webdevtoolsclient_impl.h index 922d51f..e71cbad 100644 --- a/webkit/glue/webdevtoolsclient_impl.h +++ b/webkit/glue/webdevtoolsclient_impl.h @@ -56,6 +56,7 @@ class WebDevToolsClientImpl : public WebDevToolsClient, WebCore::Node* frame); void ExecuteScript(const std::string& expr); + static v8::Handle<v8::Value> JsReset(const v8::Arguments& args); static v8::Handle<v8::Value> JsAddSourceToFrame(const v8::Arguments& args); static v8::Handle<v8::Value> JsAddResourceSourceToFrame( const v8::Arguments& args); |