diff options
-rw-r--r-- | chrome/renderer/devtools_agent.cc | 24 | ||||
-rw-r--r-- | chrome/renderer/devtools_agent.h | 7 | ||||
-rw-r--r-- | webkit/glue/devtools/debugger_agent_manager.cc | 5 |
3 files changed, 13 insertions, 23 deletions
diff --git a/chrome/renderer/devtools_agent.cc b/chrome/renderer/devtools_agent.cc index 7497cc6..2fe4ef6 100644 --- a/chrome/renderer/devtools_agent.cc +++ b/chrome/renderer/devtools_agent.cc @@ -32,7 +32,6 @@ DevToolsAgent::DevToolsAgent(int routing_id, : routing_id_(routing_id), view_(view), view_loop_(view_loop), - channel_(NULL), io_loop_(NULL) { } @@ -46,30 +45,20 @@ void DevToolsAgent::RenderViewDestroyed() { } void DevToolsAgent::Send(const IPC::Message& tools_client_message) { - // It's possible that this will get cleared out from under us. - MessageLoop* io_loop = io_loop_; - if (!io_loop) + DCHECK(MessageLoop::current() == view_loop_); + if (!view_) { return; + } IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient( routing_id_, tools_client_message); - io_loop->PostTask(FROM_HERE, NewRunnableMethod( - this, &DevToolsAgent::SendFromIOThread, m)); -} - -void DevToolsAgent::SendFromIOThread(IPC::Message* message) { - if (channel_) { - channel_->Send(message); - } else { - delete message; - } + view_->Send(m); } // Called on the IO thread. void DevToolsAgent::OnFilterAdded(IPC::Channel* channel) { io_loop_ = MessageLoop::current(); - channel_ = channel; } // Called on the IO thread. @@ -79,6 +68,10 @@ bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { if (message.routing_id() != routing_id_) return false; + // TODO(yurys): only DebuggerCommand message is handled on the IO thread + // all other messages could be handled in RenderView::OnMessageReceived. With + // that approach we wouldn't have to call view_loop_->PostTask for each of the + // messages. bool handled = true; IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message) IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) @@ -95,7 +88,6 @@ bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { // Called on the IO thread. void DevToolsAgent::OnFilterRemoved() { io_loop_ = NULL; - channel_ = NULL; } void DevToolsAgent::EvaluateScript(const std::wstring& script) { diff --git a/chrome/renderer/devtools_agent.h b/chrome/renderer/devtools_agent.h index 24bba31..9059542 100644 --- a/chrome/renderer/devtools_agent.h +++ b/chrome/renderer/devtools_agent.h @@ -38,13 +38,9 @@ class DevToolsAgent : public IPC::ChannelProxy::MessageFilter, void RenderViewDestroyed(); private: - // Sends message to DevToolsClient. May be called on any thread. + // Sends message to DevToolsClient. Should be called on the render thread. void Send(const IPC::Message& tools_client_message); - // Sends message to DevToolsClient. Must be called on IO thread. Takes - // ownership of the message. - void SendFromIOThread(IPC::Message* message); - // IPC::ChannelProxy::MessageFilter overrides. Called on IO thread. virtual void OnFilterAdded(IPC::Channel* channel); virtual bool OnMessageReceived(const IPC::Message& message); @@ -71,7 +67,6 @@ class DevToolsAgent : public IPC::ChannelProxy::MessageFilter, RenderView* view_; MessageLoop* view_loop_; - IPC::Channel* channel_; MessageLoop* io_loop_; DISALLOW_COPY_AND_ASSIGN(DevToolsAgent); diff --git a/webkit/glue/devtools/debugger_agent_manager.cc b/webkit/glue/devtools/debugger_agent_manager.cc index 3af22e6..d37c8d3 100644 --- a/webkit/glue/devtools/debugger_agent_manager.cc +++ b/webkit/glue/devtools/debugger_agent_manager.cc @@ -35,7 +35,10 @@ void DebuggerAgentManager::DebugAttach(DebuggerAgentImpl* debugger_agent) { #if USE(V8) if (!attached_agents_) { attached_agents_ = new AttachedAgentsSet(); - v8::Debug::SetMessageHandler(&DebuggerAgentManager::V8DebugMessageHandler); + v8::Debug::SetMessageHandler( + &DebuggerAgentManager::V8DebugMessageHandler, + NULL, /* no additional data */ + false /* don't create separate thread for sending debugger output */); } attached_agents_->add(debugger_agent); #endif |