diff options
-rw-r--r-- | webkit/glue/devtools/devtools_rpc.h | 26 | ||||
-rw-r--r-- | webkit/glue/devtools/devtools_rpc_unittest.cc | 9 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsagent_impl.cc | 9 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsagent_impl.h | 3 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsclient_impl.cc | 9 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsclient_impl.h | 3 |
6 files changed, 31 insertions, 28 deletions
diff --git a/webkit/glue/devtools/devtools_rpc.h b/webkit/glue/devtools/devtools_rpc.h index 97a23c5..c85b32a 100644 --- a/webkit/glue/devtools/devtools_rpc.h +++ b/webkit/glue/devtools/devtools_rpc.h @@ -44,8 +44,7 @@ // calls to the underlying MyApi methods: // // MyApi* real_object; -// MyApiDispatch dispatch; -// dispatch.Dispatch(real_object, raw_string_call_generated_by_stub); +// MyApiDispatch::Dispatch(real_object, raw_string_call_generated_by_stub); // // will make corresponding calls to the real object. @@ -158,7 +157,7 @@ case CLASS::METHOD_##Method: { \ #define TOOLS_RPC_DISPATCH1(Method, T1) \ case CLASS::METHOD_##Method: { \ RpcTypeTrait<T1>::DispatchType t1; \ - DevToolsRpc::GetListValue(*message.get(), 2, &t1); \ + DevToolsRpc::GetListValue(message, 2, &t1); \ delegate->Method( \ RpcTypeTrait<T1>::Pass(t1)); \ return true; \ @@ -168,8 +167,8 @@ case CLASS::METHOD_##Method: { \ case CLASS::METHOD_##Method: { \ RpcTypeTrait<T1>::DispatchType t1; \ RpcTypeTrait<T2>::DispatchType t2; \ - DevToolsRpc::GetListValue(*message.get(), 2, &t1); \ - DevToolsRpc::GetListValue(*message.get(), 3, &t2); \ + DevToolsRpc::GetListValue(message, 2, &t1); \ + DevToolsRpc::GetListValue(message, 3, &t2); \ delegate->Method( \ RpcTypeTrait<T1>::Pass(t1), \ RpcTypeTrait<T2>::Pass(t2) \ @@ -182,9 +181,9 @@ case CLASS::METHOD_##Method: { \ RpcTypeTrait<T1>::DispatchType t1; \ RpcTypeTrait<T2>::DispatchType t2; \ RpcTypeTrait<T3>::DispatchType t3; \ - DevToolsRpc::GetListValue(*message.get(), 2, &t1); \ - DevToolsRpc::GetListValue(*message.get(), 3, &t2); \ - DevToolsRpc::GetListValue(*message.get(), 4, &t3); \ + DevToolsRpc::GetListValue(message, 2, &t1); \ + DevToolsRpc::GetListValue(message, 3, &t2); \ + DevToolsRpc::GetListValue(message, 4, &t3); \ delegate->Method( \ RpcTypeTrait<T1>::Pass(t1), \ RpcTypeTrait<T2>::Pass(t2), \ @@ -237,16 +236,21 @@ class Class##Dispatch { \ public: \ Class##Dispatch() {} \ virtual ~Class##Dispatch() {} \ - bool Dispatch(Class* delegate, const std::string& raw_msg) { \ + \ + static bool Dispatch(Class* delegate, const std::string& raw_msg) { \ OwnPtr<ListValue> message( \ static_cast<ListValue*>(DevToolsRpc::ParseMessage(raw_msg))); \ + return Dispatch(delegate, *message.get()); \ + } \ + \ + static bool Dispatch(Class* delegate, const ListValue& message) { \ int class_id; \ - message->GetInteger(0, &class_id); \ + message.GetInteger(0, &class_id); \ if (class_id != RpcTypeToNumber<Class>::number) { \ return false; \ } \ int method; \ - message->GetInteger(1, &method); \ + message.GetInteger(1, &method); \ typedef Class CLASS; \ switch (method) { \ STRUCT( \ diff --git a/webkit/glue/devtools/devtools_rpc_unittest.cc b/webkit/glue/devtools/devtools_rpc_unittest.cc index 282d511..30e9b00 100644 --- a/webkit/glue/devtools/devtools_rpc_unittest.cc +++ b/webkit/glue/devtools/devtools_rpc_unittest.cc @@ -74,7 +74,6 @@ TEST_F(DevToolsRpcTests, TestSerialize) { TEST_F(DevToolsRpcTests, TestDispatch) { MockTestRpcClass local; MockTestRpcClass remote; - TestRpcClassDispatch dispatch; // Call 1. local.Reset(); @@ -83,7 +82,7 @@ TEST_F(DevToolsRpcTests, TestDispatch) { remote.Method0(); remote.Replay(); - dispatch.Dispatch(&remote, local.get_log()); + TestRpcClassDispatch::Dispatch(&remote, local.get_log()); remote.Verify(); // Call 2. @@ -92,7 +91,7 @@ TEST_F(DevToolsRpcTests, TestDispatch) { remote.Reset(); remote.Method1(10); remote.Replay(); - dispatch.Dispatch(&remote, local.get_log()); + TestRpcClassDispatch::Dispatch(&remote, local.get_log()); remote.Verify(); // Call 3. @@ -102,7 +101,7 @@ TEST_F(DevToolsRpcTests, TestDispatch) { remote.Method2(20, "foo"); remote.Replay(); - dispatch.Dispatch(&remote, local.get_log()); + TestRpcClassDispatch::Dispatch(&remote, local.get_log()); remote.Verify(); // Call 4. @@ -113,7 +112,7 @@ TEST_F(DevToolsRpcTests, TestDispatch) { remote.Method3(30, "foo", value); remote.Replay(); - dispatch.Dispatch(&remote, local.get_log()); + TestRpcClassDispatch::Dispatch(&remote, local.get_log()); remote.Verify(); } diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc index a548a59..bb1dd69 100644 --- a/webkit/glue/webdevtoolsagent_impl.cc +++ b/webkit/glue/webdevtoolsagent_impl.cc @@ -12,6 +12,7 @@ #include "Node.h" #include "Page.h" #include "PlatformString.h" +#include <wtf/OwnPtr.h> #undef LOG #include "base/values.h" @@ -100,13 +101,15 @@ void WebDevToolsAgentImpl::Inspect(Node* node) { void WebDevToolsAgentImpl::DispatchMessageFromClient( const std::string& raw_msg) { + OwnPtr<ListValue> message( + static_cast<ListValue*>(DevToolsRpc::ParseMessage(raw_msg))); if (dom_agent_impl_.get() && - dom_agent_dispatch_.Dispatch(dom_agent_impl_.get(), raw_msg)) + DomAgentDispatch::Dispatch(dom_agent_impl_.get(), *message.get())) return; if (net_agent_impl_.get() && - net_agent_dispatch_.Dispatch(net_agent_impl_.get(), raw_msg)) + NetAgentDispatch::Dispatch(net_agent_impl_.get(), *message.get())) return; - tools_agent_dispatch_.Dispatch(this, raw_msg); + ToolsAgentDispatch::Dispatch(this, *message.get()); } void WebDevToolsAgentImpl::SendRpcMessage(const std::string& raw_msg) { diff --git a/webkit/glue/webdevtoolsagent_impl.h b/webkit/glue/webdevtoolsagent_impl.h index 5c03856..b6ea43d 100644 --- a/webkit/glue/webdevtoolsagent_impl.h +++ b/webkit/glue/webdevtoolsagent_impl.h @@ -64,9 +64,6 @@ class WebDevToolsAgentImpl scoped_ptr<DomAgentDelegateStub> dom_agent_delegate_stub_; scoped_ptr<NetAgentDelegateStub> net_agent_delegate_stub_; scoped_ptr<ToolsAgentDelegateStub> tools_agent_delegate_stub_; - DomAgentDispatch dom_agent_dispatch_; - NetAgentDispatch net_agent_dispatch_; - ToolsAgentDispatch tools_agent_dispatch_; DISALLOW_COPY_AND_ASSIGN(WebDevToolsAgentImpl); }; diff --git a/webkit/glue/webdevtoolsclient_impl.cc b/webkit/glue/webdevtoolsclient_impl.cc index dbbe2d8..49ba41f 100644 --- a/webkit/glue/webdevtoolsclient_impl.cc +++ b/webkit/glue/webdevtoolsclient_impl.cc @@ -11,6 +11,7 @@ #include "Node.h" #include "Page.h" #include "PlatformString.h" +#include <wtf/OwnPtr.h> #undef LOG #include "base/json_reader.h" @@ -190,11 +191,13 @@ void WebDevToolsClientImpl::EvaluateJs(const std::string& expr) { void WebDevToolsClientImpl::DispatchMessageFromAgent( const std::string& raw_msg) { - if (dom_agent_delegate_dispatch_.Dispatch(this, raw_msg)) + OwnPtr<ListValue> message( + static_cast<ListValue*>(DevToolsRpc::ParseMessage(raw_msg))); + if (DomAgentDelegateDispatch::Dispatch(this, *message.get())) return; - if (net_agent_delegate_dispatch_.Dispatch(this, raw_msg)) + if (NetAgentDelegateDispatch::Dispatch(this, *message.get())) return; - if (tools_agent_delegate_dispatch_.Dispatch(this, raw_msg)) + if (ToolsAgentDelegateDispatch::Dispatch(this, *message.get())) return; } diff --git a/webkit/glue/webdevtoolsclient_impl.h b/webkit/glue/webdevtoolsclient_impl.h index b4ae53e..9714d28 100644 --- a/webkit/glue/webdevtoolsclient_impl.h +++ b/webkit/glue/webdevtoolsclient_impl.h @@ -133,9 +133,6 @@ class WebDevToolsClientImpl : public WebDevToolsClient, scoped_ptr<DomAgentStub> dom_agent_stub_; scoped_ptr<NetAgentStub> net_agent_stub_; scoped_ptr<ToolsAgentStub> tools_agent_stub_; - DomAgentDelegateDispatch dom_agent_delegate_dispatch_; - NetAgentDelegateDispatch net_agent_delegate_dispatch_; - ToolsAgentDelegateDispatch tools_agent_delegate_dispatch_; DISALLOW_COPY_AND_ASSIGN(WebDevToolsClientImpl); }; |