summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 08:37:06 +0000
committeryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 08:37:06 +0000
commit37f39f0516108d8ecc308b5c5f3c06f0753b0038 (patch)
tree99702d3f3536a0ff9c933a996aa31ecec27a4201
parente13372e4cf728c46c9a08ad300b633f9b975108c (diff)
downloadchromium_src-37f39f0516108d8ecc308b5c5f3c06f0753b0038.zip
chromium_src-37f39f0516108d8ecc308b5c5f3c06f0753b0038.tar.gz
chromium_src-37f39f0516108d8ecc308b5c5f3c06f0753b0038.tar.bz2
DevTools: decouple class and method names from RPC message arguments. That would allow to select dispatcher wothout parsing the message argument.
Review URL: http://codereview.chromium.org/115862 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17176 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/debugger/inspectable_tab_proxy.cc12
-rw-r--r--chrome/browser/debugger/inspectable_tab_proxy.h4
-rw-r--r--chrome/common/devtools_messages_internal.h12
-rw-r--r--chrome/renderer/devtools_agent.cc12
-rw-r--r--chrome/renderer/devtools_agent.h8
-rw-r--r--chrome/renderer/devtools_client.cc12
-rw-r--r--chrome/renderer/devtools_client.h8
-rw-r--r--webkit/glue/devtools/devtools_mock_rpc.h44
-rw-r--r--webkit/glue/devtools/devtools_rpc.cc6
-rw-r--r--webkit/glue/devtools/devtools_rpc.h72
-rw-r--r--webkit/glue/devtools/devtools_rpc_unittest.cc29
-rw-r--r--webkit/glue/devtools/js/devtools.js10
-rw-r--r--webkit/glue/webdevtoolsagent.h4
-rw-r--r--webkit/glue/webdevtoolsagent_delegate.h4
-rw-r--r--webkit/glue/webdevtoolsagent_impl.cc17
-rw-r--r--webkit/glue/webdevtoolsagent_impl.h8
-rw-r--r--webkit/glue/webdevtoolsclient.h4
-rw-r--r--webkit/glue/webdevtoolsclient_delegate.h4
-rw-r--r--webkit/glue/webdevtoolsclient_impl.cc25
-rw-r--r--webkit/glue/webdevtoolsclient_impl.h9
20 files changed, 203 insertions, 101 deletions
diff --git a/chrome/browser/debugger/inspectable_tab_proxy.cc b/chrome/browser/debugger/inspectable_tab_proxy.cc
index 0479716..064ee8f 100644
--- a/chrome/browser/debugger/inspectable_tab_proxy.cc
+++ b/chrome/browser/debugger/inspectable_tab_proxy.cc
@@ -36,7 +36,9 @@ void DevToolsClientHostImpl::SendMessageToClient(
IPC_END_MESSAGE_MAP()
}
-void DevToolsClientHostImpl::OnRpcMessage(const std::string& msg) {
+void DevToolsClientHostImpl::OnRpcMessage(const std::string& class_name,
+ const std::string& message_name,
+ const std::string& msg) {
static const std::string kDebuggerAgentDelegate = "DebuggerAgentDelegate";
static const std::string kToolsAgentDelegate = "ToolsAgentDelegate";
static const std::string kDebuggerOutput = "DebuggerOutput";
@@ -48,18 +50,14 @@ void DevToolsClientHostImpl::OnRpcMessage(const std::string& msg) {
return;
}
ListValue* list_msg = static_cast<ListValue*>(message.get());
- std::string class_name;
- list_msg->GetString(0, &class_name);
- std::string message_name;
- list_msg->GetString(1, &message_name);
if (class_name == kDebuggerAgentDelegate && message_name == kDebuggerOutput) {
std::string str;
- list_msg->GetString(2, &str);
+ list_msg->GetString(0, &str);
DebuggerOutput(str);
} else if (class_name == kToolsAgentDelegate &&
message_name == kFrameNavigate) {
std::string url;
- list_msg->GetString(2, &url);
+ list_msg->GetString(0, &url);
FrameNavigate(url);
}
}
diff --git a/chrome/browser/debugger/inspectable_tab_proxy.h b/chrome/browser/debugger/inspectable_tab_proxy.h
index 88913d7..454d248 100644
--- a/chrome/browser/debugger/inspectable_tab_proxy.h
+++ b/chrome/browser/debugger/inspectable_tab_proxy.h
@@ -81,7 +81,9 @@ class DevToolsClientHostImpl : public DevToolsClientHost {
private:
// Message handling routines
- void OnRpcMessage(const std::string& msg);
+ void OnRpcMessage(const std::string& class_name,
+ const std::string& message_name,
+ const std::string& msg);
void DebuggerOutput(const std::string& msg);
void FrameNavigate(const std::string& url);
void TabClosed();
diff --git a/chrome/common/devtools_messages_internal.h b/chrome/common/devtools_messages_internal.h
index b0e0a8a..3778497 100644
--- a/chrome/common/devtools_messages_internal.h
+++ b/chrome/common/devtools_messages_internal.h
@@ -49,8 +49,10 @@
IPC_BEGIN_MESSAGES(DevToolsClient)
// Sends glue-level Rpc message to the client.
- IPC_MESSAGE_CONTROL1(DevToolsClientMsg_RpcMessage,
- std::string /* raw_msg */)
+ IPC_MESSAGE_CONTROL3(DevToolsClientMsg_RpcMessage,
+ std::string /* class_name */,
+ std::string /* method_name */,
+ std::string /* raw_msg */)
IPC_END_MESSAGES(DevToolsClient)
@@ -67,8 +69,10 @@ IPC_BEGIN_MESSAGES(DevToolsAgent)
IPC_MESSAGE_CONTROL0(DevToolsAgentMsg_Detach)
// Sends glue-level Rpc message to the agent.
- IPC_MESSAGE_CONTROL1(DevToolsAgentMsg_RpcMessage,
- std::string /* raw_msg */)
+ IPC_MESSAGE_CONTROL3(DevToolsAgentMsg_RpcMessage,
+ std::string /* class_name */,
+ std::string /* method_name */,
+ std::string /* raw_msg */)
// Send debugger command to the debugger agent. Debugger commands should
// be handled on IO thread(while all other devtools messages are handled in
diff --git a/chrome/renderer/devtools_agent.cc b/chrome/renderer/devtools_agent.cc
index 88528b2..00bb750 100644
--- a/chrome/renderer/devtools_agent.cc
+++ b/chrome/renderer/devtools_agent.cc
@@ -35,10 +35,12 @@ bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) {
return handled;
}
-void DevToolsAgent::SendMessageToClient(const std::string& raw_msg) {
+void DevToolsAgent::SendMessageToClient(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg) {
IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient(
routing_id_,
- DevToolsClientMsg_RpcMessage(raw_msg));
+ DevToolsClientMsg_RpcMessage(class_name, method_name, raw_msg));
view_->Send(m);
}
@@ -74,10 +76,12 @@ void DevToolsAgent::OnDetach() {
}
}
-void DevToolsAgent::OnRpcMessage(const std::string& raw_msg) {
+void DevToolsAgent::OnRpcMessage(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg) {
WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent) {
- web_agent->DispatchMessageFromClient(raw_msg);
+ web_agent->DispatchMessageFromClient(class_name, method_name, raw_msg);
}
}
diff --git a/chrome/renderer/devtools_agent.h b/chrome/renderer/devtools_agent.h
index 2c2702c..f7e59d9e 100644
--- a/chrome/renderer/devtools_agent.h
+++ b/chrome/renderer/devtools_agent.h
@@ -30,7 +30,9 @@ class DevToolsAgent : public WebDevToolsAgentDelegate {
virtual bool OnMessageReceived(const IPC::Message& message);
// WebDevToolsAgentDelegate implementation
- virtual void SendMessageToClient(const std::string& raw_msg);
+ virtual void SendMessageToClient(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg);
virtual int GetHostId();
virtual void ForceRepaint();
@@ -46,7 +48,9 @@ class DevToolsAgent : public WebDevToolsAgentDelegate {
void OnAttach();
void OnDetach();
- void OnRpcMessage(const std::string& raw_msg);
+ void OnRpcMessage(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg);
void OnInspectElement(int x, int y);
static std::map<int, DevToolsAgent*> agent_for_routing_id_;
diff --git a/chrome/renderer/devtools_client.cc b/chrome/renderer/devtools_client.cc
index 27e3954..b0f9a8f 100644
--- a/chrome/renderer/devtools_client.cc
+++ b/chrome/renderer/devtools_client.cc
@@ -37,8 +37,10 @@ bool DevToolsClient::OnMessageReceived(const IPC::Message& message) {
return handled;
}
-void DevToolsClient::SendMessageToAgent(const std::string& raw_msg) {
- Send(DevToolsAgentMsg_RpcMessage(raw_msg));
+void DevToolsClient::SendMessageToAgent(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg) {
+ Send(DevToolsAgentMsg_RpcMessage(class_name, method_name, raw_msg));
}
void DevToolsClient::SendDebuggerCommandToAgent(const std::string& command) {
@@ -49,6 +51,8 @@ void DevToolsClient::ActivateWindow() {
render_view_->TakeFocus(render_view_->webview(), false);
}
-void DevToolsClient::OnRpcMessage(const std::string& raw_msg) {
- web_tools_client_->DispatchMessageFromAgent(raw_msg);
+void DevToolsClient::OnRpcMessage(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg) {
+ web_tools_client_->DispatchMessageFromAgent(class_name, method_name, raw_msg);
}
diff --git a/chrome/renderer/devtools_client.h b/chrome/renderer/devtools_client.h
index 1964968..744232a 100644
--- a/chrome/renderer/devtools_client.h
+++ b/chrome/renderer/devtools_client.h
@@ -33,12 +33,16 @@ class DevToolsClient : public WebDevToolsClientDelegate {
bool OnMessageReceived(const IPC::Message& message);
// WebDevToolsClient::Delegate implementation
- virtual void SendMessageToAgent(const std::string& raw_msg);
+ virtual void SendMessageToAgent(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg);
virtual void SendDebuggerCommandToAgent(const std::string& command);
virtual void ActivateWindow();
private:
- void OnRpcMessage(const std::string& raw_msg);
+ void OnRpcMessage(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg);
// Sends message to DevToolsAgent.
void Send(const IPC::Message& tools_agent_message);
diff --git a/webkit/glue/devtools/devtools_mock_rpc.h b/webkit/glue/devtools/devtools_mock_rpc.h
index c424306..44d7b59d 100644
--- a/webkit/glue/devtools/devtools_mock_rpc.h
+++ b/webkit/glue/devtools/devtools_mock_rpc.h
@@ -22,31 +22,67 @@ class DevToolsMockRpc : public DevToolsRpc::Delegate {
DevToolsMockRpc() {}
~DevToolsMockRpc() {}
- virtual void SendRpcMessage(const std::string& msg) {
+ virtual void SendRpcMessage(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& msg) {
+ last_class_name_ = class_name;
+ last_method_name_ = method_name;
+ last_msg_ = msg;
+
if (!log_.length()) {
- log_ = msg;
+ log_ = StringPrintf("%s %s %s", class_name.c_str(),
+ method_name.c_str(), msg.c_str());;
} else {
- log_ = StringPrintf("%s\n%s", log_.c_str(), msg.c_str());
+ log_ = StringPrintf("%s\n%s %s %s", log_.c_str(), class_name.c_str(),
+ method_name.c_str(), msg.c_str());
}
}
void Replay() {
+ ref_last_class_name_ = last_class_name_;
+ last_class_name_ = "";
+ ref_last_method_name_ = last_method_name_;
+ last_method_name_ = "";
+ ref_last_msg_ = last_msg_;
+ last_msg_ = "";
+
ref_log_ = log_;
log_ = "";
}
void Verify() {
+ ASSERT_EQ(ref_last_class_name_, last_class_name_);
+ ASSERT_EQ(ref_last_method_name_, last_method_name_);
+ ASSERT_EQ(ref_last_msg_, last_msg_);
ASSERT_EQ(ref_log_, log_);
}
void Reset() {
+ last_class_name_ = "";
+ last_method_name_ = "";
+ last_msg_ = "";
+
+ ref_last_class_name_ = "";
+ ref_last_method_name_ = "";
+ ref_last_msg_ = "";
+
ref_log_ = "";
log_ = "";
}
- const std::string &get_log() { return log_; }
+ const std::string& last_class_name() { return last_class_name_; }
+ const std::string& last_method_name() { return last_method_name_; }
+ const std::string& last_msg() { return last_msg_; }
private:
+ std::string last_class_name_;
+ std::string last_method_name_;
+ std::string last_msg_;
+
+ std::string ref_last_class_name_;
+ std::string ref_last_method_name_;
+ std::string ref_last_msg_;
+
std::string log_;
std::string ref_log_;
DISALLOW_COPY_AND_ASSIGN(DevToolsMockRpc);
diff --git a/webkit/glue/devtools/devtools_rpc.cc b/webkit/glue/devtools/devtools_rpc.cc
index 458fcb4..3d5667d 100644
--- a/webkit/glue/devtools/devtools_rpc.cc
+++ b/webkit/glue/devtools/devtools_rpc.cc
@@ -20,8 +20,10 @@ DevToolsRpc::DevToolsRpc(Delegate* delegate) : delegate_(delegate) {
DevToolsRpc::~DevToolsRpc() {
}
-void DevToolsRpc::SendValueMessage(const Value& value) {
- delegate_->SendRpcMessage(Serialize(value));
+void DevToolsRpc::SendValueMessage(const std::string& class_name,
+ const std::string& method_name,
+ const Value& value) {
+ delegate_->SendRpcMessage(class_name, method_name, Serialize(value));
}
// static
diff --git a/webkit/glue/devtools/devtools_rpc.h b/webkit/glue/devtools/devtools_rpc.h
index 8a28d0b..54a7a81 100644
--- a/webkit/glue/devtools/devtools_rpc.h
+++ b/webkit/glue/devtools/devtools_rpc.h
@@ -174,7 +174,7 @@ if (method_name == #Method) { \
#define TOOLS_RPC_DISPATCH1(Method, T1) \
if (method_name == #Method) { \
RpcTypeTrait<T1>::DispatchType t1; \
- DevToolsRpc::GetListValue(message, 2, &t1); \
+ DevToolsRpc::GetListValue(message, 0, &t1); \
delegate->Method( \
RpcTypeTrait<T1>::Pass(t1)); \
return true; \
@@ -184,8 +184,8 @@ if (method_name == #Method) { \
if (method_name == #Method) { \
RpcTypeTrait<T1>::DispatchType t1; \
RpcTypeTrait<T2>::DispatchType t2; \
- DevToolsRpc::GetListValue(message, 2, &t1); \
- DevToolsRpc::GetListValue(message, 3, &t2); \
+ DevToolsRpc::GetListValue(message, 0, &t1); \
+ DevToolsRpc::GetListValue(message, 1, &t2); \
delegate->Method( \
RpcTypeTrait<T1>::Pass(t1), \
RpcTypeTrait<T2>::Pass(t2) \
@@ -198,9 +198,9 @@ if (method_name == #Method) { \
RpcTypeTrait<T1>::DispatchType t1; \
RpcTypeTrait<T2>::DispatchType t2; \
RpcTypeTrait<T3>::DispatchType t3; \
- DevToolsRpc::GetListValue(message, 2, &t1); \
- DevToolsRpc::GetListValue(message, 3, &t2); \
- DevToolsRpc::GetListValue(message, 4, &t3); \
+ DevToolsRpc::GetListValue(message, 0, &t1); \
+ DevToolsRpc::GetListValue(message, 1, &t2); \
+ DevToolsRpc::GetListValue(message, 2, &t3); \
delegate->Method( \
RpcTypeTrait<T1>::Pass(t1), \
RpcTypeTrait<T2>::Pass(t2), \
@@ -215,10 +215,10 @@ if (method_name == #Method) { \
RpcTypeTrait<T2>::DispatchType t2; \
RpcTypeTrait<T3>::DispatchType t3; \
RpcTypeTrait<T4>::DispatchType t4; \
- DevToolsRpc::GetListValue(message, 2, &t1); \
- DevToolsRpc::GetListValue(message, 3, &t2); \
- DevToolsRpc::GetListValue(message, 4, &t3); \
- DevToolsRpc::GetListValue(message, 5, &t4); \
+ DevToolsRpc::GetListValue(message, 0, &t1); \
+ DevToolsRpc::GetListValue(message, 1, &t2); \
+ DevToolsRpc::GetListValue(message, 2, &t3); \
+ DevToolsRpc::GetListValue(message, 3, &t4); \
delegate->Method( \
RpcTypeTrait<T1>::Pass(t1), \
RpcTypeTrait<T2>::Pass(t2), \
@@ -272,21 +272,23 @@ class Class##Dispatch { \
public: \
Class##Dispatch() {} \
virtual ~Class##Dispatch() {} \
+ \
+ static bool Dispatch(Class* delegate, \
+ const std::string& class_name, \
+ const std::string& method_name, \
+ const std::string& raw_msg) { \
+ OwnPtr<ListValue> message( \
+ static_cast<ListValue*>(DevToolsRpc::ParseMessage(raw_msg))); \
+ return Dispatch(delegate, class_name, method_name, *message.get()); \
+ } \
\
- 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) { \
- std::string class_name; \
- message.GetString(0, &class_name); \
+ static bool Dispatch(Class* delegate, \
+ const std::string& class_name, \
+ const std::string& method_name, \
+ const ListValue& message) { \
if (class_name != #Class) { \
return false; \
} \
- std::string method_name; \
- message.GetString(1, &method_name); \
typedef Class CLASS; \
STRUCT( \
TOOLS_RPC_DISPATCH0, \
@@ -308,7 +310,9 @@ class DevToolsRpc {
public:
Delegate() {}
virtual ~Delegate() {}
- virtual void SendRpcMessage(const std::string& msg) = 0;
+ virtual void SendRpcMessage(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(Delegate);
};
@@ -320,9 +324,7 @@ class DevToolsRpc {
const std::string& class_name,
const std::string& method_name) {
ListValue message;
- message.Append(CreateValue(&class_name));
- message.Append(CreateValue(&method_name));
- SendValueMessage(message);
+ SendValueMessage(class_name, method_name, message);
}
template<typename T1>
@@ -331,10 +333,8 @@ class DevToolsRpc {
const std::string& method_name,
T1 t1) {
ListValue message;
- message.Append(CreateValue(&class_name));
- message.Append(CreateValue(&method_name));
message.Append(CreateValue(t1));
- SendValueMessage(message);
+ SendValueMessage(class_name, method_name, message);
}
template<typename T1, typename T2>
@@ -343,11 +343,9 @@ class DevToolsRpc {
const std::string& method_name,
T1 t1, T2 t2) {
ListValue message;
- message.Append(CreateValue(&class_name));
- message.Append(CreateValue(&method_name));
message.Append(CreateValue(t1));
message.Append(CreateValue(t2));
- SendValueMessage(message);
+ SendValueMessage(class_name, method_name, message);
}
template<typename T1, typename T2, typename T3>
@@ -356,12 +354,10 @@ class DevToolsRpc {
const std::string& method_name,
T1 t1, T2 t2, T3 t3) {
ListValue message;
- message.Append(CreateValue(&class_name));
- message.Append(CreateValue(&method_name));
message.Append(CreateValue(t1));
message.Append(CreateValue(t2));
message.Append(CreateValue(t3));
- SendValueMessage(message);
+ SendValueMessage(class_name, method_name, message);
}
template<typename T1, typename T2, typename T3, typename T4>
@@ -370,13 +366,11 @@ class DevToolsRpc {
const std::string& method_name,
T1 t1, T2 t2, T3 t3, T4 t4) {
ListValue message;
- message.Append(CreateValue(&class_name));
- message.Append(CreateValue(&method_name));
message.Append(CreateValue(t1));
message.Append(CreateValue(t2));
message.Append(CreateValue(t3));
message.Append(CreateValue(t4));
- SendValueMessage(message);
+ SendValueMessage(class_name, method_name, message);
}
static Value* ParseMessage(const std::string& raw_msg);
@@ -405,7 +399,9 @@ class DevToolsRpc {
static Value* CreateValue(bool* value);
static Value* CreateValue(const Value* value);
- void SendValueMessage(const Value& value);
+ void SendValueMessage(const std::string& class_name,
+ const std::string& method_name,
+ const Value& value);
Delegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(DevToolsRpc);
diff --git a/webkit/glue/devtools/devtools_rpc_unittest.cc b/webkit/glue/devtools/devtools_rpc_unittest.cc
index d900fb8..9f9b1a6 100644
--- a/webkit/glue/devtools/devtools_rpc_unittest.cc
+++ b/webkit/glue/devtools/devtools_rpc_unittest.cc
@@ -52,21 +52,28 @@ class DevToolsRpcTests : public testing::Test {
TEST_F(DevToolsRpcTests, TestSerialize) {
MockTestRpcClass mock;
mock.Method0();
- EXPECT_EQ("[\"TestRpcClass\",\"Method0\"]", mock.get_log());
+ EXPECT_EQ("TestRpcClass", mock.last_class_name());
+ EXPECT_EQ("Method0", mock.last_method_name());
+ EXPECT_EQ("[]", mock.last_msg());
mock.Reset();
mock.Method1(10);
- EXPECT_EQ("[\"TestRpcClass\",\"Method1\",10]", mock.get_log());
+ EXPECT_EQ("TestRpcClass", mock.last_class_name());
+ EXPECT_EQ("Method1", mock.last_method_name());
+ EXPECT_EQ("[10]", mock.last_msg());
mock.Reset();
mock.Method2(20, "foo");
- EXPECT_EQ("[\"TestRpcClass\",\"Method2\",20,\"foo\"]", mock.get_log());
+ EXPECT_EQ("TestRpcClass", mock.last_class_name());
+ EXPECT_EQ("Method2", mock.last_method_name());
+ EXPECT_EQ("[20,\"foo\"]", mock.last_msg());
mock.Reset();
StringValue value("bar");
mock.Method3(30, "foo", value);
- EXPECT_EQ("[\"TestRpcClass\",\"Method3\",30,\"foo\",\"bar\"]",
- mock.get_log());
+ EXPECT_EQ("TestRpcClass", mock.last_class_name());
+ EXPECT_EQ("Method3", mock.last_method_name());
+ EXPECT_EQ("[30,\"foo\",\"bar\"]", mock.last_msg());
mock.Reset();
}
@@ -82,7 +89,8 @@ TEST_F(DevToolsRpcTests, TestDispatch) {
remote.Method0();
remote.Replay();
- TestRpcClassDispatch::Dispatch(&remote, local.get_log());
+ TestRpcClassDispatch::Dispatch(&remote, local.last_class_name(),
+ local.last_method_name(), local.last_msg());
remote.Verify();
// Call 2.
@@ -91,7 +99,8 @@ TEST_F(DevToolsRpcTests, TestDispatch) {
remote.Reset();
remote.Method1(10);
remote.Replay();
- TestRpcClassDispatch::Dispatch(&remote, local.get_log());
+ TestRpcClassDispatch::Dispatch(&remote, local.last_class_name(),
+ local.last_method_name(), local.last_msg());
remote.Verify();
// Call 3.
@@ -101,7 +110,8 @@ TEST_F(DevToolsRpcTests, TestDispatch) {
remote.Method2(20, "foo");
remote.Replay();
- TestRpcClassDispatch::Dispatch(&remote, local.get_log());
+ TestRpcClassDispatch::Dispatch(&remote, local.last_class_name(),
+ local.last_method_name(), local.last_msg());
remote.Verify();
// Call 4.
@@ -112,7 +122,8 @@ TEST_F(DevToolsRpcTests, TestDispatch) {
remote.Method3(30, "foo", value);
remote.Replay();
- TestRpcClassDispatch::Dispatch(&remote, local.get_log());
+ TestRpcClassDispatch::Dispatch(&remote, local.last_class_name(),
+ local.last_method_name(), local.last_msg());
remote.Verify();
}
diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js
index e4096d9..c301e80 100644
--- a/webkit/glue/devtools/js/devtools.js
+++ b/webkit/glue/devtools/js/devtools.js
@@ -15,12 +15,12 @@ goog.require('devtools.DomAgent');
/**
* Dispatches raw message from the host.
+ * @param {string} remoteName
+ * @prama {string} methodName
* @param {Object} msg Message to dispatch.
*/
-devtools.dispatch = function(msg) {
- var delegate = msg[0];
- var methodName = msg[1];
- var remoteName = 'Remote' + delegate.substring(0, delegate.length - 8);
+devtools.dispatch = function(remoteName, methodName, msg) {
+ remoteName = 'Remote' + remoteName.substring(0, remoteName.length - 8);
var agent = window[remoteName];
if (!agent) {
debugPrint('No remote agent "' + remoteName + '" found.');
@@ -31,7 +31,7 @@ devtools.dispatch = function(msg) {
debugPrint('No method "' + remoteName + '.' + methodName + '" found.');
return;
}
- method.apply(this, msg.slice(2));
+ method.apply(this, msg);
};
diff --git a/webkit/glue/webdevtoolsagent.h b/webkit/glue/webdevtoolsagent.h
index 9680e84..177ec2f 100644
--- a/webkit/glue/webdevtoolsagent.h
+++ b/webkit/glue/webdevtoolsagent.h
@@ -28,7 +28,9 @@ class WebDevToolsAgent {
virtual void Detach() = 0;
- virtual void DispatchMessageFromClient(const std::string& raw_msg) = 0;
+ virtual void DispatchMessageFromClient(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg) = 0;
virtual void InspectElement(int x, int y) = 0;
diff --git a/webkit/glue/webdevtoolsagent_delegate.h b/webkit/glue/webdevtoolsagent_delegate.h
index 5c596ff..0e06714 100644
--- a/webkit/glue/webdevtoolsagent_delegate.h
+++ b/webkit/glue/webdevtoolsagent_delegate.h
@@ -13,7 +13,9 @@ class WebDevToolsAgentDelegate {
WebDevToolsAgentDelegate() {}
virtual ~WebDevToolsAgentDelegate() {}
- virtual void SendMessageToClient(const std::string& raw_msg) = 0;
+ virtual void SendMessageToClient(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg) = 0;
// Invalidates widget which leads to the repaint.
virtual void ForceRepaint() = 0;
diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc
index 50c676f..e77908c 100644
--- a/webkit/glue/webdevtoolsagent_impl.cc
+++ b/webkit/glue/webdevtoolsagent_impl.cc
@@ -231,10 +231,13 @@ void WebDevToolsAgentImpl::GetResourceContent(
}
void WebDevToolsAgentImpl::DispatchMessageFromClient(
+ const std::string& class_name,
+ const std::string& method_name,
const std::string& raw_msg) {
OwnPtr<ListValue> message(
static_cast<ListValue*>(DevToolsRpc::ParseMessage(raw_msg)));
- if (ToolsAgentDispatch::Dispatch(this, *message.get())) {
+ if (ToolsAgentDispatch::Dispatch(
+ this, class_name, method_name, *message.get())) {
return;
}
@@ -244,12 +247,13 @@ void WebDevToolsAgentImpl::DispatchMessageFromClient(
if (debugger_agent_impl_.get() &&
DebuggerAgentDispatch::Dispatch(
- debugger_agent_impl_.get(),
+ debugger_agent_impl_.get(), class_name, method_name,
*message.get())) {
return;
}
- if (DomAgentDispatch::Dispatch(dom_agent_impl_.get(), *message.get())) {
+ if (DomAgentDispatch::Dispatch(
+ dom_agent_impl_.get(), class_name, method_name, *message.get())) {
return;
}
}
@@ -264,8 +268,11 @@ void WebDevToolsAgentImpl::InspectElement(int x, int y) {
tools_agent_delegate_stub_->UpdateFocusedNode(node_id);
}
-void WebDevToolsAgentImpl::SendRpcMessage(const std::string& raw_msg) {
- delegate_->SendMessageToClient(raw_msg);
+void WebDevToolsAgentImpl::SendRpcMessage(
+ const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg) {
+ delegate_->SendMessageToClient(class_name, method_name, raw_msg);
}
// static
diff --git a/webkit/glue/webdevtoolsagent_impl.h b/webkit/glue/webdevtoolsagent_impl.h
index 9b89514..d87b442 100644
--- a/webkit/glue/webdevtoolsagent_impl.h
+++ b/webkit/glue/webdevtoolsagent_impl.h
@@ -58,11 +58,15 @@ class WebDevToolsAgentImpl
// WebDevToolsAgent implementation.
virtual void Attach();
virtual void Detach();
- virtual void DispatchMessageFromClient(const std::string& raw_msg);
+ virtual void DispatchMessageFromClient(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg);
virtual void InspectElement(int x, int y);
// DevToolsRpc::Delegate implementation.
- void SendRpcMessage(const std::string& raw_msg);
+ void SendRpcMessage(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg);
// Methods called by the glue.
void SetMainFrameDocumentReady(bool ready);
diff --git a/webkit/glue/webdevtoolsclient.h b/webkit/glue/webdevtoolsclient.h
index 23529c6..1e9d3c0 100644
--- a/webkit/glue/webdevtoolsclient.h
+++ b/webkit/glue/webdevtoolsclient.h
@@ -22,7 +22,9 @@ class WebDevToolsClient {
WebDevToolsClient() {}
virtual ~WebDevToolsClient() {}
- virtual void DispatchMessageFromAgent(const std::string& raw_msg) = 0;
+ virtual void DispatchMessageFromAgent(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(WebDevToolsClient);
diff --git a/webkit/glue/webdevtoolsclient_delegate.h b/webkit/glue/webdevtoolsclient_delegate.h
index 720bff2..2be3656 100644
--- a/webkit/glue/webdevtoolsclient_delegate.h
+++ b/webkit/glue/webdevtoolsclient_delegate.h
@@ -13,7 +13,9 @@ class WebDevToolsClientDelegate {
WebDevToolsClientDelegate() {}
virtual ~WebDevToolsClientDelegate() {}
- virtual void SendMessageToAgent(const std::string& raw_msg) = 0;
+ virtual void SendMessageToAgent(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg) = 0;
virtual void SendDebuggerCommandToAgent(const std::string& command) = 0;
virtual void ActivateWindow() = 0;
diff --git a/webkit/glue/webdevtoolsclient_impl.cc b/webkit/glue/webdevtoolsclient_impl.cc
index 182bc58..07c5444 100644
--- a/webkit/glue/webdevtoolsclient_impl.cc
+++ b/webkit/glue/webdevtoolsclient_impl.cc
@@ -122,18 +122,31 @@ WebDevToolsClientImpl::~WebDevToolsClientImpl() {
}
void WebDevToolsClientImpl::DispatchMessageFromAgent(
- const std::string& raw_msg) {
+ const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg) {
+ std::string expr = StringPrintf(
+ "devtools.dispatch('%s','%s',%s)",
+ class_name.c_str(),
+ method_name.c_str(),
+ raw_msg.c_str());
if (!loaded_) {
- pending_incoming_messages_.append(raw_msg);
+ pending_incoming_messages_.append(expr);
return;
}
- std::string expr = StringPrintf("devtools.dispatch(%s)", raw_msg.c_str());
+ ExecuteScript(expr);
+}
+
+void WebDevToolsClientImpl::ExecuteScript(const std::string& expr) {
web_view_impl_->GetMainFrame()->ExecuteScript(
WebScriptSource(WebString::fromUTF8(expr)));
}
-void WebDevToolsClientImpl::SendRpcMessage(const std::string& raw_msg) {
- delegate_->SendMessageToAgent(raw_msg);
+
+void WebDevToolsClientImpl::SendRpcMessage(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg) {
+ delegate_->SendMessageToAgent(class_name, method_name, raw_msg);
}
// static
@@ -180,7 +193,7 @@ v8::Handle<v8::Value> WebDevToolsClientImpl::JsLoaded(
client->pending_incoming_messages_.begin();
it != client->pending_incoming_messages_.end();
++it) {
- client->DispatchMessageFromAgent(*it);
+ client->ExecuteScript(*it);
}
client->pending_incoming_messages_.clear();
return v8::Undefined();
diff --git a/webkit/glue/webdevtoolsclient_impl.h b/webkit/glue/webdevtoolsclient_impl.h
index a7ae71f5..07df265 100644
--- a/webkit/glue/webdevtoolsclient_impl.h
+++ b/webkit/glue/webdevtoolsclient_impl.h
@@ -38,12 +38,17 @@ class WebDevToolsClientImpl : public WebDevToolsClient,
virtual ~WebDevToolsClientImpl();
// DevToolsRpc::Delegate implementation.
- virtual void SendRpcMessage(const std::string& raw_msg);
+ virtual void SendRpcMessage(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg);
// WebDevToolsClient implementation.
- virtual void DispatchMessageFromAgent(const std::string& raw_msg);
+ virtual void DispatchMessageFromAgent(const std::string& class_name,
+ const std::string& method_name,
+ const std::string& raw_msg);
private:
+ void ExecuteScript(const std::string& expr);
static v8::Handle<v8::Value> JsAddSourceToFrame(const v8::Arguments& args);
static v8::Handle<v8::Value> JsLoaded(const v8::Arguments& args);
static v8::Handle<v8::Value> JsActivateWindow(const v8::Arguments& args);