diff options
21 files changed, 299 insertions, 264 deletions
diff --git a/chrome/browser/debugger/inspectable_tab_proxy.cc b/chrome/browser/debugger/inspectable_tab_proxy.cc index 159be0b..29e5d32 100644 --- a/chrome/browser/debugger/inspectable_tab_proxy.cc +++ b/chrome/browser/debugger/inspectable_tab_proxy.cc @@ -34,18 +34,21 @@ void DevToolsClientHostImpl::SendMessageToClient( IPC_END_MESSAGE_MAP() } -void DevToolsClientHostImpl::OnRpcMessage(const DevToolsMessageData& data) { +void DevToolsClientHostImpl::OnRpcMessage(const std::string& class_name, + const std::string& message_name, + const std::string& param1, + const std::string& param2, + const std::string& param3) { static const std::string kDebuggerAgentDelegate = "DebuggerAgentDelegate"; static const std::string kToolsAgentDelegate = "ToolsAgentDelegate"; static const std::string kDebuggerOutput = "DebuggerOutput"; static const std::string kFrameNavigate = "FrameNavigate"; - if (data.class_name == kDebuggerAgentDelegate && - data.method_name == kDebuggerOutput) { - DebuggerOutput(data.arguments[0]); - } else if (data.class_name == kToolsAgentDelegate && - data.method_name == kFrameNavigate) { - FrameNavigate(data.arguments[0]); + if (class_name == kDebuggerAgentDelegate && message_name == kDebuggerOutput) { + DebuggerOutput(param1); + } else if (class_name == kToolsAgentDelegate && + message_name == kFrameNavigate) { + FrameNavigate(param1); } } diff --git a/chrome/browser/debugger/inspectable_tab_proxy.h b/chrome/browser/debugger/inspectable_tab_proxy.h index 67b5952..13da2ec 100644 --- a/chrome/browser/debugger/inspectable_tab_proxy.h +++ b/chrome/browser/debugger/inspectable_tab_proxy.h @@ -15,7 +15,6 @@ class DebuggerRemoteService; class DevToolsClientHost; class DevToolsClientHostImpl; class NavigationController; -struct DevToolsMessageData; // Proxies debugged tabs' NavigationControllers using their UIDs. // Keeps track of tabs being debugged so that we can detach from @@ -82,7 +81,11 @@ class DevToolsClientHostImpl : public DevToolsClientHost { private: // Message handling routines - void OnRpcMessage(const DevToolsMessageData& data); + void OnRpcMessage(const std::string& class_name, + const std::string& message_name, + const std::string& param1, + const std::string& param2, + const std::string& param3); void DebuggerOutput(const std::string& msg); void FrameNavigate(const std::string& url); void TabClosed(); diff --git a/chrome/browser/extensions/extension_devtools_bridge.cc b/chrome/browser/extensions/extension_devtools_bridge.cc index dcf6375..99f515b 100644 --- a/chrome/browser/extensions/extension_devtools_bridge.cc +++ b/chrome/browser/extensions/extension_devtools_bridge.cc @@ -80,12 +80,16 @@ void ExtensionDevToolsBridge::SendMessageToClient(const IPC::Message& msg) { static const char kApuAgentClassName[] = "ApuAgentDelegate"; static const char kApuPageEventMessageName[] = "DispatchToApu"; -void ExtensionDevToolsBridge::OnRpcMessage(const DevToolsMessageData& data) { +void ExtensionDevToolsBridge::OnRpcMessage(const std::string& class_name, + const std::string& message_name, + const std::string& param1, + const std::string& param2, + const std::string& param3) { DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); - if (data.class_name == kApuAgentClassName - && data.method_name == kApuPageEventMessageName) { - std::string json = StringPrintf("[%s]", data.arguments[0].c_str()); + if (class_name == kApuAgentClassName + && message_name == kApuPageEventMessageName) { + std::string json = StringPrintf("[%s]", param1.c_str()); profile_->GetExtensionMessageService()->DispatchEventToRenderers( on_page_event_name_, json); } diff --git a/chrome/browser/extensions/extension_devtools_bridge.h b/chrome/browser/extensions/extension_devtools_bridge.h index 5543b97..1745ef7 100644 --- a/chrome/browser/extensions/extension_devtools_bridge.h +++ b/chrome/browser/extensions/extension_devtools_bridge.h @@ -13,7 +13,6 @@ #include "chrome/browser/extensions/extension_message_service.h" class Profile; -struct DevToolsMessageData; // This class is a DevToolsClientHost that fires extension events. class ExtensionDevToolsBridge : public DevToolsClientHost { @@ -32,7 +31,11 @@ class ExtensionDevToolsBridge : public DevToolsClientHost { virtual void SendMessageToClient(const IPC::Message& msg); private: - void OnRpcMessage(const DevToolsMessageData& data); + void OnRpcMessage(const std::string& class_name, + const std::string& message_name, + const std::string& param1, + const std::string& param2, + const std::string& param3); // ID of the tab we are monitoring. int tab_id_; diff --git a/chrome/common/devtools_messages.h b/chrome/common/devtools_messages.h index 6c095f4..abb740d 100644 --- a/chrome/common/devtools_messages.h +++ b/chrome/common/devtools_messages.h @@ -5,33 +5,6 @@ #ifndef CHROME_COMMON_DEVTOOLS_MESSAGES_H_ #define CHROME_COMMON_DEVTOOLS_MESSAGES_H_ -#include "ipc/ipc_message_utils.h" -#include "webkit/glue/devtools/devtools_message_data.h" - -namespace IPC { - -// Traits for DevToolsMessageData structure to pack/unpack. -template <> -struct ParamTraits<DevToolsMessageData> { - typedef DevToolsMessageData param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.class_name); - WriteParam(m, p.method_name); - WriteParam(m, p.arguments); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->class_name) && - ReadParam(m, iter, &p->method_name) && - ReadParam(m, iter, &p->arguments); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<DevToolsMessageData>"); - } -}; - -} // namespace IPC - #define MESSAGES_INTERNAL_FILE "chrome/common/devtools_messages_internal.h" #include "ipc/ipc_message_macros.h" diff --git a/chrome/common/devtools_messages_internal.h b/chrome/common/devtools_messages_internal.h index d48ec09..d80c0ed 100644 --- a/chrome/common/devtools_messages_internal.h +++ b/chrome/common/devtools_messages_internal.h @@ -43,15 +43,18 @@ // This file describes developer tools message types. #include "ipc/ipc_message_macros.h" -#include "webkit/glue/devtools/devtools_message_data.h" // These are messages sent from DevToolsAgent to DevToolsClient through the // browser. IPC_BEGIN_MESSAGES(DevToolsClient) // Sends glue-level Rpc message to the client. - IPC_MESSAGE_CONTROL1(DevToolsClientMsg_RpcMessage, - DevToolsMessageData /* message data */) + IPC_MESSAGE_CONTROL5(DevToolsClientMsg_RpcMessage, + std::string /* class_name */, + std::string /* method_name */, + std::string /* p1 */, + std::string /* p2 */, + std::string /* p3 */) IPC_END_MESSAGES(DevToolsClient) @@ -69,8 +72,12 @@ IPC_BEGIN_MESSAGES(DevToolsAgent) IPC_MESSAGE_CONTROL0(DevToolsAgentMsg_Detach) // Sends glue-level Rpc message to the agent. - IPC_MESSAGE_CONTROL1(DevToolsAgentMsg_RpcMessage, - DevToolsMessageData /* message data */) + IPC_MESSAGE_CONTROL5(DevToolsAgentMsg_RpcMessage, + std::string /* class_name */, + std::string /* method_name */, + std::string /* p1 */, + std::string /* p2 */, + std::string /* p3 */) // 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 11211fd..d1e81e2 100644 --- a/chrome/renderer/devtools_agent.cc +++ b/chrome/renderer/devtools_agent.cc @@ -9,16 +9,13 @@ #include "chrome/renderer/devtools_agent_filter.h" #include "chrome/renderer/render_view.h" #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgent.h" -#include "third_party/WebKit/WebKit/chromium/public/WebDevToolsMessageData.h" #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" -#include "webkit/glue/devtools/devtools_message_data.h" #include "webkit/glue/glue_util.h" using WebKit::WebDevToolsAgent; using WebKit::WebPoint; using WebKit::WebString; -using WebKit::WebVector; using WebKit::WebView; // static @@ -56,11 +53,19 @@ bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { return handled; } -void DevToolsAgent::sendMessageToFrontend( - const WebKit::WebDevToolsMessageData& data) { +void DevToolsAgent::sendMessageToFrontend(const WebString& class_name, + const WebString& method_name, + const WebString& param1, + const WebString& param2, + const WebString& param3) { IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient( routing_id_, - DevToolsClientMsg_RpcMessage(DevToolsMessageData(data))); + DevToolsClientMsg_RpcMessage( + class_name.utf8(), + method_name.utf8(), + param1.utf8(), + param2.utf8(), + param3.utf8())); render_view_->Send(m); } @@ -108,10 +113,19 @@ void DevToolsAgent::OnDetach() { } } -void DevToolsAgent::OnRpcMessage(const DevToolsMessageData& data) { +void DevToolsAgent::OnRpcMessage(const std::string& class_name, + const std::string& method_name, + const std::string& param1, + const std::string& param2, + const std::string& param3) { WebDevToolsAgent* web_agent = GetWebAgent(); if (web_agent) { - web_agent->dispatchMessageFromFrontend(data.ToWebDevToolsMessageData()); + web_agent->dispatchMessageFromFrontend( + WebString::fromUTF8(class_name), + WebString::fromUTF8(method_name), + WebString::fromUTF8(param1), + WebString::fromUTF8(param2), + WebString::fromUTF8(param3)); } } @@ -141,6 +155,15 @@ WebDevToolsAgent* DevToolsAgent::GetWebAgent() { // static void WebKit::WebDevToolsAgentClient::sendMessageToFrontendOnIOThread( - const WebDevToolsMessageData& data) { - DevToolsAgentFilter::SendRpcMessage(DevToolsMessageData(data)); + const WebString& class_name, + const WebString& method_name, + const WebString& param1, + const WebString& param2, + const WebString& param3) { + DevToolsAgentFilter::SendRpcMessage( + class_name.utf8(), + method_name.utf8(), + param1.utf8(), + param2.utf8(), + param3.utf8()); } diff --git a/chrome/renderer/devtools_agent.h b/chrome/renderer/devtools_agent.h index 4d05fe0..26a6297 100644 --- a/chrome/renderer/devtools_agent.h +++ b/chrome/renderer/devtools_agent.h @@ -21,7 +21,6 @@ class WebDevToolsAgent; } class RenderView; -struct DevToolsMessageData; // DevToolsAgent belongs to the inspectable RenderView and provides Glue's // agents with the communication capabilities. All messages from/to Glue's @@ -38,9 +37,11 @@ class DevToolsAgent : public WebKit::WebDevToolsAgentClient { virtual bool OnMessageReceived(const IPC::Message& message); // WebDevToolsAgentClient implementation - virtual void sendMessageToFrontend( - const WebKit::WebDevToolsMessageData& data); - + virtual void sendMessageToFrontend(const WebKit::WebString& class_name, + const WebKit::WebString& method_name, + const WebKit::WebString& param1, + const WebKit::WebString& param2, + const WebKit::WebString& param3); virtual int hostIdentifier(); virtual void forceRepaint(); virtual void runtimeFeatureStateChanged(const WebKit::WebString& feature, @@ -58,7 +59,11 @@ class DevToolsAgent : public WebKit::WebDevToolsAgentClient { void OnAttach(const std::vector<std::string>& runtime_features); void OnDetach(); - void OnRpcMessage(const DevToolsMessageData& data); + void OnRpcMessage(const std::string& class_name, + const std::string& method_name, + const std::string& param1, + const std::string& param2, + const std::string& param3); void OnInspectElement(int x, int y); void OnSetApuAgentEnabled(bool enabled); diff --git a/chrome/renderer/devtools_agent_filter.cc b/chrome/renderer/devtools_agent_filter.cc index d3a8289..375c743 100644 --- a/chrome/renderer/devtools_agent_filter.cc +++ b/chrome/renderer/devtools_agent_filter.cc @@ -11,9 +11,7 @@ #include "chrome/renderer/plugin_channel_host.h" #include "chrome/renderer/render_view.h" #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgent.h" -#include "third_party/WebKit/WebKit/chromium/public/WebDevToolsMessageData.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" -#include "webkit/glue/devtools/devtools_message_data.h" using WebKit::WebDevToolsAgent; using WebKit::WebString; @@ -64,15 +62,32 @@ void DevToolsAgentFilter::OnDebuggerPauseScript() { WebDevToolsAgent::debuggerPauseScript(); } -void DevToolsAgentFilter::OnRpcMessage(const DevToolsMessageData& data) { +void DevToolsAgentFilter::OnRpcMessage(const std::string& class_name, + const std::string& method_name, + const std::string& param1, + const std::string& param2, + const std::string& param3) { message_handled_ = WebDevToolsAgent::dispatchMessageFromFrontendOnIOThread( - data.ToWebDevToolsMessageData()); + WebString::fromUTF8(class_name), + WebString::fromUTF8(method_name), + WebString::fromUTF8(param1), + WebString::fromUTF8(param2), + WebString::fromUTF8(param3)); } // static -void DevToolsAgentFilter::SendRpcMessage(const DevToolsMessageData& data) { +void DevToolsAgentFilter::SendRpcMessage(const std::string& class_name, + const std::string& method_name, + const std::string& param1, + const std::string& param2, + const std::string& param3) { IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient( current_routing_id_, - DevToolsClientMsg_RpcMessage(data)); + DevToolsClientMsg_RpcMessage( + class_name, + method_name, + param1, + param2, + param3)); channel_->Send(m); } diff --git a/chrome/renderer/devtools_agent_filter.h b/chrome/renderer/devtools_agent_filter.h index 8d23918..ac5fd0c 100644 --- a/chrome/renderer/devtools_agent_filter.h +++ b/chrome/renderer/devtools_agent_filter.h @@ -10,8 +10,6 @@ #include "ipc/ipc_channel_proxy.h" -struct DevToolsMessageData; - // DevToolsAgentFilter is registered as an IPC filter in order to be able to // dispatch messages while on the IO thread. The reason for that is that while // debugging, Render thread is being held by the v8 and hence no messages @@ -24,7 +22,11 @@ class DevToolsAgentFilter : public IPC::ChannelProxy::MessageFilter { DevToolsAgentFilter(); virtual ~DevToolsAgentFilter(); - static void SendRpcMessage(const DevToolsMessageData& data); + static void SendRpcMessage(const std::string& class_name, + const std::string& method_name, + const std::string& param1, + const std::string& param2, + const std::string& param3); private: // IPC::ChannelProxy::MessageFilter override. Called on IO thread. @@ -38,7 +40,11 @@ class DevToolsAgentFilter : public IPC::ChannelProxy::MessageFilter { // handle debug messages even when v8 is stopped. void OnDebuggerCommand(const std::string& command); void OnDebuggerPauseScript(); - void OnRpcMessage(const DevToolsMessageData& data); + void OnRpcMessage(const std::string& class_name, + const std::string& method_name, + const std::string& param1, + const std::string& param2, + const std::string& param3); bool message_handled_; diff --git a/chrome/renderer/devtools_client.cc b/chrome/renderer/devtools_client.cc index 2ab162e..8083288 100644 --- a/chrome/renderer/devtools_client.cc +++ b/chrome/renderer/devtools_client.cc @@ -11,7 +11,6 @@ #include "chrome/renderer/render_thread.h" #include "chrome/renderer/render_view.h" #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsFrontend.h" -#include "third_party/WebKit/WebKit/chromium/public/WebDevToolsMessageData.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" using WebKit::WebDevToolsFrontend; @@ -48,9 +47,17 @@ bool DevToolsClient::OnMessageReceived(const IPC::Message& message) { return handled; } -void DevToolsClient::sendMessageToAgent( - const WebKit::WebDevToolsMessageData& data) { - Send(DevToolsAgentMsg_RpcMessage(DevToolsMessageData(data))); +void DevToolsClient::sendMessageToAgent(const WebString& class_name, + const WebString& method_name, + const WebString& param1, + const WebString& param2, + const WebString& param3) { + Send(DevToolsAgentMsg_RpcMessage( + class_name.utf8(), + method_name.utf8(), + param1.utf8(), + param2.utf8(), + param3.utf8())); } void DevToolsClient::sendDebuggerCommandToAgent(const WebString& command) { @@ -81,7 +88,15 @@ void DevToolsClient::undockWindow() { render_view_->routing_id())); } -void DevToolsClient::OnRpcMessage(const DevToolsMessageData& data) { +void DevToolsClient::OnRpcMessage(const std::string& class_name, + const std::string& method_name, + const std::string& param1, + const std::string& param2, + const std::string& param3) { web_tools_frontend_->dispatchMessageFromAgent( - data.ToWebDevToolsMessageData()); + WebString::fromUTF8(class_name), + WebString::fromUTF8(method_name), + WebString::fromUTF8(param1), + WebString::fromUTF8(param2), + WebString::fromUTF8(param3)); } diff --git a/chrome/renderer/devtools_client.h b/chrome/renderer/devtools_client.h index c8eba9f..aad5c09 100644 --- a/chrome/renderer/devtools_client.h +++ b/chrome/renderer/devtools_client.h @@ -21,8 +21,6 @@ namespace WebKit { class WebDevToolsFrontend; } -struct DevToolsMessageData; - // Developer tools UI end of communication channel between the render process of // the page being inspected and tools UI renderer process. All messages will // go through browser process. On the side of the inspected page there's @@ -39,8 +37,11 @@ class DevToolsClient : public WebKit::WebDevToolsFrontendClient { bool OnMessageReceived(const IPC::Message& message); // WebDevToolsFrontendClient implementation - virtual void sendMessageToAgent( - const WebKit::WebDevToolsMessageData& data); + virtual void sendMessageToAgent(const WebKit::WebString& class_name, + const WebKit::WebString& method_name, + const WebKit::WebString& param1, + const WebKit::WebString& param2, + const WebKit::WebString& param3); virtual void sendDebuggerCommandToAgent(const WebKit::WebString& command); virtual void sendDebuggerPauseScript(); @@ -50,7 +51,11 @@ class DevToolsClient : public WebKit::WebDevToolsFrontendClient { virtual void undockWindow(); private: - void OnRpcMessage(const DevToolsMessageData& data); + void OnRpcMessage(const std::string& class_name, + const std::string& method_name, + const std::string& param1, + const std::string& param2, + const std::string& param3); // Sends message to DevToolsAgent. void Send(const IPC::Message& tools_agent_message); diff --git a/webkit/glue/devtools/devtools_message_data.cc b/webkit/glue/devtools/devtools_message_data.cc deleted file mode 100644 index 68280fb..0000000 --- a/webkit/glue/devtools/devtools_message_data.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "config.h" - -#undef LOG - -#include "third_party/WebKit/WebKit/chromium/public/WebDevToolsMessageData.h" -#include "webkit/glue/devtools/devtools_message_data.h" -#include "webkit/glue/glue_util.h" - -DevToolsMessageData::DevToolsMessageData( - const WebKit::WebDevToolsMessageData& data) - : class_name(webkit_glue::WebStringToStdString(data.className)), - method_name(webkit_glue::WebStringToStdString(data.methodName)) { - for (size_t i = 0; i < data.arguments.size(); i++) - arguments.push_back(webkit_glue::WebStringToStdString(data.arguments[i])); -} - -WebKit::WebDevToolsMessageData - DevToolsMessageData::ToWebDevToolsMessageData() const { - WebKit::WebDevToolsMessageData result; - result.className = webkit_glue::StdStringToWebString(class_name); - result.methodName = webkit_glue::StdStringToWebString(method_name); - WebKit::WebVector<WebKit::WebString> web_args(arguments.size()); - for (size_t i = 0; i < arguments.size(); i++) - web_args[i] = webkit_glue::StdStringToWebString(arguments[i]); - result.arguments.swap(web_args); - return result; -}
\ No newline at end of file diff --git a/webkit/glue/devtools/devtools_message_data.h b/webkit/glue/devtools/devtools_message_data.h deleted file mode 100644 index 4d28b84..0000000 --- a/webkit/glue/devtools/devtools_message_data.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_GLUE_DEVTOOLS_DEVTOOLS_MESSAGE_DATA_H_ -#define WEBKIT_GLUE_DEVTOOLS_DEVTOOLS_MESSAGE_DATA_H_ - -#include <string> -#include <vector> - -namespace WebKit { -struct WebDevToolsMessageData; -} - -struct DevToolsMessageData { - DevToolsMessageData() {} - explicit DevToolsMessageData(const WebKit::WebDevToolsMessageData&); - WebKit::WebDevToolsMessageData ToWebDevToolsMessageData() const; - - std::string class_name; - std::string method_name; - std::vector<std::string> arguments; -}; - -#endif // WEBKIT_GLUE_DEVTOOLS_DEVTOOLS_MESSAGE_DATA_H_ diff --git a/webkit/glue/devtools/devtools_rpc.h b/webkit/glue/devtools/devtools_rpc.h index c41497f..819bd79 100644 --- a/webkit/glue/devtools/devtools_rpc.h +++ b/webkit/glue/devtools/devtools_rpc.h @@ -51,19 +51,14 @@ #define WEBKIT_GLUE_DEVTOOLS_DEVTOOLS_RPC_H_ #include "PlatformString.h" -#include "Vector.h" #include <wtf/Noncopyable.h> -#include "third_party/WebKit/WebKit/chromium/public/WebDevToolsMessageData.h" -#include "webkit/glue/glue_util.h" - namespace WebCore { class String; } using WebCore::String; -using WTF::Vector; /////////////////////////////////////////////////////// // RPC dispatch macro @@ -135,35 +130,37 @@ struct RpcTypeTrait<String> { #define TOOLS_RPC_STUB_METHOD0(Method) \ virtual void Method() { \ - Vector<String> args; \ - this->SendRpcMessage(class_name, #Method, args); \ + this->delegate_->SendRpcMessage(class_name, #Method); \ } #define TOOLS_RPC_STUB_METHOD1(Method, T1) \ virtual void Method(RpcTypeTrait<T1>::ApiType t1) { \ - Vector<String> args(1); \ - args[0].swap(RpcTypeTrait<T1>::ToString(t1)); \ - this->SendRpcMessage(class_name, #Method, args); \ + this->delegate_->SendRpcMessage( \ + class_name, \ + #Method, \ + RpcTypeTrait<T1>::ToString(t1)); \ } #define TOOLS_RPC_STUB_METHOD2(Method, T1, T2) \ virtual void Method(RpcTypeTrait<T1>::ApiType t1, \ RpcTypeTrait<T2>::ApiType t2) { \ - Vector<String> args(2); \ - args[0].swap(RpcTypeTrait<T1>::ToString(t1)); \ - args[1].swap(RpcTypeTrait<T2>::ToString(t2)); \ - this->SendRpcMessage(class_name, #Method, args); \ + this->delegate_->SendRpcMessage( \ + class_name, \ + #Method, \ + RpcTypeTrait<T1>::ToString(t1), \ + RpcTypeTrait<T2>::ToString(t2)); \ } #define TOOLS_RPC_STUB_METHOD3(Method, T1, T2, T3) \ virtual void Method(RpcTypeTrait<T1>::ApiType t1, \ RpcTypeTrait<T2>::ApiType t2, \ RpcTypeTrait<T3>::ApiType t3) { \ - Vector<String> args(3); \ - args[0].swap(RpcTypeTrait<T1>::ToString(t1)); \ - args[1].swap(RpcTypeTrait<T2>::ToString(t2)); \ - args[2].swap(RpcTypeTrait<T3>::ToString(t3)); \ - this->SendRpcMessage(class_name, #Method, args); \ + this->delegate_->SendRpcMessage( \ + class_name, \ + #Method, \ + RpcTypeTrait<T1>::ToString(t1), \ + RpcTypeTrait<T2>::ToString(t2), \ + RpcTypeTrait<T3>::ToString(t3)); \ } /////////////////////////////////////////////////////// @@ -177,15 +174,15 @@ if (method_name == #Method) { \ #define TOOLS_RPC_DISPATCH1(Method, T1) \ if (method_name == #Method) { \ - delegate->Method(RpcTypeTrait<T1>::Parse(args[0])); \ + delegate->Method(RpcTypeTrait<T1>::Parse(p1)); \ return true; \ } #define TOOLS_RPC_DISPATCH2(Method, T1, T2) \ if (method_name == #Method) { \ delegate->Method( \ - RpcTypeTrait<T1>::Parse(args[0]), \ - RpcTypeTrait<T2>::Parse(args[1]) \ + RpcTypeTrait<T1>::Parse(p1), \ + RpcTypeTrait<T2>::Parse(p2) \ ); \ return true; \ } @@ -193,9 +190,9 @@ if (method_name == #Method) { \ #define TOOLS_RPC_DISPATCH3(Method, T1, T2, T3) \ if (method_name == #Method) { \ delegate->Method( \ - RpcTypeTrait<T1>::Parse(args[0]), \ - RpcTypeTrait<T2>::Parse(args[1]), \ - RpcTypeTrait<T3>::Parse(args[2]) \ + RpcTypeTrait<T1>::Parse(p1), \ + RpcTypeTrait<T2>::Parse(p2), \ + RpcTypeTrait<T3>::Parse(p3) \ ); \ return true; \ } @@ -242,16 +239,14 @@ class Class##Dispatch : public Noncopyable { \ virtual ~Class##Dispatch() {} \ \ static bool Dispatch(Class* delegate, \ - const WebKit::WebDevToolsMessageData& data) { \ - String class_name = webkit_glue::WebStringToString(data.className); \ + const WebCore::String& class_name, \ + const WebCore::String& method_name, \ + const WebCore::String& p1, \ + const WebCore::String& p2, \ + const WebCore::String& p3) { \ if (class_name != #Class) { \ return false; \ } \ - String method_name = webkit_glue::WebStringToString(data.methodName); \ - Vector<String> args; \ - for (size_t i = 0; i < data.arguments.size(); i++) { \ - args.append(webkit_glue::WebStringToString(data.arguments[i])); \ - } \ typedef Class CLASS; \ STRUCT( \ TOOLS_RPC_DISPATCH0, \ @@ -270,8 +265,11 @@ class DevToolsRpc { public: Delegate() {} virtual ~Delegate() {} - virtual void SendRpcMessage( - const WebKit::WebDevToolsMessageData& data) = 0; + virtual void SendRpcMessage(const WebCore::String& class_name, + const WebCore::String& method_name, + const WebCore::String& p1 = "", + const WebCore::String& p2 = "", + const WebCore::String& p3 = "") = 0; }; explicit DevToolsRpc(Delegate* delegate) @@ -279,20 +277,6 @@ class DevToolsRpc { virtual ~DevToolsRpc() {}; protected: - void SendRpcMessage(const String& class_name, - const String& method_name, - const Vector<String>& args) { - WebKit::WebVector<WebKit::WebString> web_args(args.size()); - for (size_t i = 0; i < args.size(); i++) { - web_args[i] = webkit_glue::StringToWebString(args[i]); - } - WebKit::WebDevToolsMessageData data; - data.className = webkit_glue::StringToWebString(class_name); - data.methodName = webkit_glue::StringToWebString(method_name); - data.arguments.swap(web_args); - this->delegate_->SendRpcMessage(data); - } - Delegate* delegate_; }; diff --git a/webkit/glue/devtools/devtools_rpc_js.h b/webkit/glue/devtools/devtools_rpc_js.h index 761f590..c4cfc47 100644 --- a/webkit/glue/devtools/devtools_rpc_js.h +++ b/webkit/glue/devtools/devtools_rpc_js.h @@ -33,25 +33,36 @@ #define TOOLS_RPC_JS_STUB_METHOD0(Method) \ static v8::Handle<v8::Value> Js##Method(const v8::Arguments& args) { \ - SendRpcMessageFromJs(#Method, args, 0); \ + SendRpcMessage(v8::External::Cast(*args.Data())->Value(), \ + #Method, "", "", ""); \ return v8::Undefined(); \ } #define TOOLS_RPC_JS_STUB_METHOD1(Method, T1) \ static v8::Handle<v8::Value> Js##Method(const v8::Arguments& args) { \ - SendRpcMessageFromJs(#Method, args, 1); \ + SendRpcMessage(v8::External::Cast(*args.Data())->Value(), \ + #Method, \ + WebCore::toWebCoreStringWithNullCheck(args[0]), "", ""); \ return v8::Undefined(); \ } #define TOOLS_RPC_JS_STUB_METHOD2(Method, T1, T2) \ static v8::Handle<v8::Value> Js##Method(const v8::Arguments& args) { \ - SendRpcMessageFromJs(#Method, args, 2); \ + SendRpcMessage(v8::External::Cast(*args.Data())->Value(), \ + #Method, \ + WebCore::toWebCoreStringWithNullCheck(args[0]), \ + WebCore::toWebCoreStringWithNullCheck(args[1]), \ + ""); \ return v8::Undefined(); \ } #define TOOLS_RPC_JS_STUB_METHOD3(Method, T1, T2, T3) \ static v8::Handle<v8::Value> Js##Method(const v8::Arguments& args) { \ - SendRpcMessageFromJs(#Method, args, 3); \ + SendRpcMessage(v8::External::Cast(*args.Data())->Value(), \ + #Method, \ + WebCore::toWebCoreStringWithNullCheck(args[0]), \ + WebCore::toWebCoreStringWithNullCheck(args[1]), \ + WebCore::toWebCoreStringWithNullCheck(args[2])); \ return v8::Undefined(); \ } @@ -81,16 +92,18 @@ class Js##Class##BoundObj : public Class##Stub { \ TOOLS_RPC_JS_STUB_METHOD2, \ TOOLS_RPC_JS_STUB_METHOD3) \ private: \ - static void SendRpcMessageFromJs(const char* method, \ - const v8::Arguments& js_arguments, \ - size_t args_count) { \ - Vector<String> args(args_count); \ - for (size_t i = 0; i < args_count; i++) { \ - args[i].swap(WebCore::toWebCoreStringWithNullCheck(js_arguments[i])); \ - } \ - void* self_ptr = v8::External::Cast(*js_arguments.Data())->Value(); \ + static void SendRpcMessage(void* self_ptr, \ + const char* method, \ + const String& param1, \ + const String& param2, \ + const String& param3) { \ Js##Class##BoundObj* self = static_cast<Js##Class##BoundObj*>(self_ptr); \ - self->SendRpcMessage(#Class, method, args); \ + self->delegate_->SendRpcMessage( \ + #Class, \ + method, \ + param1, \ + param2, \ + param3); \ } \ }; diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc index 42fcbb8..24b85bb 100644 --- a/webkit/glue/webdevtoolsagent_impl.cc +++ b/webkit/glue/webdevtoolsagent_impl.cc @@ -30,7 +30,6 @@ #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgentClient.h" -#include "third_party/WebKit/WebKit/chromium/public/WebDevToolsMessageData.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" @@ -69,7 +68,6 @@ using WebCore::V8DOMWrapper; using WebCore::V8Proxy; using WebKit::WebDataSource; using WebKit::WebDevToolsAgentClient; -using WebKit::WebDevToolsMessageData; using WebKit::WebFrame; using WebKit::WebFrameImpl; using WebKit::WebPoint; @@ -119,9 +117,17 @@ class IoRpcDelegate : public DevToolsRpc::Delegate { public: IoRpcDelegate() {} virtual ~IoRpcDelegate() {} - virtual void SendRpcMessage( - const WebKit::WebDevToolsMessageData& data) { - WebDevToolsAgentClient::sendMessageToFrontendOnIOThread(data); + virtual void SendRpcMessage(const String& class_name, + const String& method_name, + const String& p1, + const String& p2, + const String& p3) { + WebDevToolsAgentClient::sendMessageToFrontendOnIOThread( + webkit_glue::StringToWebString(class_name), + webkit_glue::StringToWebString(method_name), + webkit_glue::StringToWebString(p1), + webkit_glue::StringToWebString(p2), + webkit_glue::StringToWebString(p3)); } private: @@ -280,20 +286,19 @@ void WebDevToolsAgentImpl::GetResourceContent( tools_agent_native_delegate_stub_->DidGetResourceContent(call_id, content); } -// TODO(yurys): this method is deprecated and will go away soon, use -// overloaded method with WebDevToolsMessageData argument instead. void WebDevToolsAgentImpl::dispatchMessageFromFrontend( const WebString& class_name, const WebString& method_name, const WebString& param1, const WebString& param2, const WebString& param3) { - ASSERT_NOT_REACHED(); -} - -void WebDevToolsAgentImpl::dispatchMessageFromFrontend( - const WebDevToolsMessageData& data) { - if (ToolsAgentDispatch::Dispatch(this, data)) { + if (ToolsAgentDispatch::Dispatch( + this, + webkit_glue::WebStringToString(class_name), + webkit_glue::WebStringToString(method_name), + webkit_glue::WebStringToString(param1), + webkit_glue::WebStringToString(param2), + webkit_glue::WebStringToString(param3))) { return; } @@ -302,11 +307,22 @@ void WebDevToolsAgentImpl::dispatchMessageFromFrontend( } if (debugger_agent_impl_.get() && - DebuggerAgentDispatch::Dispatch(debugger_agent_impl_.get(), data)) { + DebuggerAgentDispatch::Dispatch( + debugger_agent_impl_.get(), + webkit_glue::WebStringToString(class_name), + webkit_glue::WebStringToString(method_name), + webkit_glue::WebStringToString(param1), + webkit_glue::WebStringToString(param2), + webkit_glue::WebStringToString(param3))) { return; } } +void WebDevToolsAgentImpl::dispatchMessageFromFrontend( + const WebKit::WebDevToolsMessageData& data) { + // Stub. +} + void WebDevToolsAgentImpl::inspectElementAt(const WebPoint& point) { web_view_impl_->inspectElementAt(point); } @@ -328,8 +344,17 @@ void WebDevToolsAgentImpl::setRuntimeFeatureEnabled(const WebString& wfeature, } void WebDevToolsAgentImpl::SendRpcMessage( - const WebKit::WebDevToolsMessageData& data) { - client_->sendMessageToFrontend(data); + const String& class_name, + const String& method_name, + const String& param1, + const String& param2, + const String& param3) { + client_->sendMessageToFrontend( + webkit_glue::StringToWebString(class_name), + webkit_glue::StringToWebString(method_name), + webkit_glue::StringToWebString(param1), + webkit_glue::StringToWebString(param2), + webkit_glue::StringToWebString(param3)); } void WebDevToolsAgentImpl::InitDevToolsAgentHost() { @@ -615,8 +640,6 @@ void WebDevToolsAgent::setMessageLoopDispatchHandler( DebuggerAgentManager::SetMessageLoopDispatchHandler(handler); } -// TODO(yurys): this method is deprecated and will go away soon, use -// overloaded method with WebDevToolsMessageData argument instead. // static bool WebDevToolsAgent::dispatchMessageFromFrontendOnIOThread( const WebString& className, @@ -624,27 +647,16 @@ bool WebDevToolsAgent::dispatchMessageFromFrontendOnIOThread( const WebString& param1, const WebString& param2, const WebString& param3) { - WebKit::WebVector<WebString> arguments(static_cast<size_t>(3)); - arguments[0] = param1; - arguments[1] = param2; - arguments[2] = param3; - - WebDevToolsMessageData data; - data.className = className; - data.methodName = methodName; - data.arguments.swap(arguments); - // Delegate to overloaded method. This method will go away soon. - return WebDevToolsAgent::dispatchMessageFromFrontendOnIOThread(data); -} - -// static -bool WebDevToolsAgent::dispatchMessageFromFrontendOnIOThread( - const WebDevToolsMessageData& data) { IoRpcDelegate transport; ProfilerAgentDelegateStub stub(&transport); ProfilerAgentImpl agent(&stub); - return ProfilerAgentDispatch::Dispatch(&agent, data); + return ProfilerAgentDispatch::Dispatch( + &agent, + webkit_glue::WebStringToString(className), + webkit_glue::WebStringToString(methodName), + webkit_glue::WebStringToString(param1), + webkit_glue::WebStringToString(param2), + webkit_glue::WebStringToString(param3)); } - } // namespace WebKit diff --git a/webkit/glue/webdevtoolsagent_impl.h b/webkit/glue/webdevtoolsagent_impl.h index 84c7483..65c7eb3 100644 --- a/webkit/glue/webdevtoolsagent_impl.h +++ b/webkit/glue/webdevtoolsagent_impl.h @@ -101,7 +101,11 @@ class WebDevToolsAgentImpl : public WebKit::WebDevToolsAgentPrivate, const WebKit::WebURLError& error); // DevToolsRpc::Delegate implementation. - virtual void SendRpcMessage(const WebKit::WebDevToolsMessageData& data); + void SendRpcMessage(const WebCore::String& class_name, + const WebCore::String& method_name, + const WebCore::String& param1, + const WebCore::String& param2, + const WebCore::String& param3); void ForceRepaint(); diff --git a/webkit/glue/webdevtoolsfrontend_impl.cc b/webkit/glue/webdevtoolsfrontend_impl.cc index 1048a41..15a50a9 100644 --- a/webkit/glue/webdevtoolsfrontend_impl.cc +++ b/webkit/glue/webdevtoolsfrontend_impl.cc @@ -36,7 +36,6 @@ #include "third_party/WebKit/WebKit/chromium/src/WebViewImpl.h" #include "webkit/glue/devtools/bound_object.h" #include "webkit/glue/devtools/debugger_agent.h" -#include "webkit/glue/devtools/devtools_message_data.h" #include "webkit/glue/devtools/devtools_rpc_js.h" #include "webkit/glue/devtools/profiler_agent.h" #include "webkit/glue/devtools/tools_agent.h" @@ -219,29 +218,28 @@ WebDevToolsFrontendImpl::~WebDevToolsFrontendImpl() { menu_selection_handler_->disconnect(); } -// TODO(yurys): this method is deprecated and will go away soon, use -// overloaded method with WebDevToolsMessageData argument instead. void WebDevToolsFrontendImpl::dispatchMessageFromAgent( const WebString& class_name, const WebString& method_name, const WebString& param1, const WebString& param2, const WebString& param3) { - ASSERT_NOT_REACHED(); -} - -void WebDevToolsFrontendImpl::dispatchMessageFromAgent( - const WebKit::WebDevToolsMessageData& data) { if (ToolsAgentNativeDelegateDispatch::Dispatch( tools_agent_native_delegate_impl_.get(), - data)) { + webkit_glue::WebStringToString(class_name), + webkit_glue::WebStringToString(method_name), + webkit_glue::WebStringToString(param1), + webkit_glue::WebStringToString(param2), + webkit_glue::WebStringToString(param3))) { return; } + Vector<String> v; - v.append(webkit_glue::WebStringToString(data.className)); - v.append(webkit_glue::WebStringToString(data.methodName)); - for (size_t i = 0; i < data.arguments.size(); i++) - v.append(webkit_glue::WebStringToString(data.arguments[i])); + v.append(webkit_glue::WebStringToString(class_name)); + v.append(webkit_glue::WebStringToString(method_name)); + v.append(webkit_glue::WebStringToString(param1)); + v.append(webkit_glue::WebStringToString(param2)); + v.append(webkit_glue::WebStringToString(param3)); if (!loaded_) { pending_incoming_messages_.append(v); return; @@ -249,6 +247,11 @@ void WebDevToolsFrontendImpl::dispatchMessageFromAgent( ExecuteScript(v); } +void WebDevToolsFrontendImpl::dispatchMessageFromAgent( + const WebKit::WebDevToolsMessageData& data) { + // Stub. +} + void WebDevToolsFrontendImpl::AddResourceSourceToFrame(int resource_id, String mime_type, Node* frame) { @@ -268,12 +271,15 @@ void WebDevToolsFrontendImpl::ExecuteScript(const Vector<String>& v) { v8::Handle<v8::Value> dispatch_function = frame_context->Global()->Get(v8::String::New("devtools$$dispatch")); ASSERT(dispatch_function->IsFunction()); - v8::Handle<v8::Function> function = - v8::Handle<v8::Function>::Cast(dispatch_function); - Vector< v8::Handle<v8::Value> > args; - for (size_t i = 0; i < v.size(); i++) - args.append(ToV8String(v.at(i))); - function->Call(frame_context->Global(), args.size(), args.data()); + v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(dispatch_function); + v8::Handle<v8::Value> args[] = { + ToV8String(v.at(0)), + ToV8String(v.at(1)), + ToV8String(v.at(2)), + ToV8String(v.at(3)), + ToV8String(v.at(4)), + }; + function->Call(frame_context->Global(), 5, args); } void WebDevToolsFrontendImpl::DispatchOnWebInspector( @@ -300,9 +306,17 @@ void WebDevToolsFrontendImpl::DispatchOnWebInspector( } -void WebDevToolsFrontendImpl::SendRpcMessage( - const WebKit::WebDevToolsMessageData& data) { - client_->sendMessageToAgent(data); +void WebDevToolsFrontendImpl::SendRpcMessage(const String& class_name, + const String& method_name, + const String& param1, + const String& param2, + const String& param3) { + client_->sendMessageToAgent( + webkit_glue::StringToWebString(class_name), + webkit_glue::StringToWebString(method_name), + webkit_glue::StringToWebString(param1), + webkit_glue::StringToWebString(param2), + webkit_glue::StringToWebString(param3)); } void WebDevToolsFrontendImpl::ContextMenuItemSelected( diff --git a/webkit/glue/webdevtoolsfrontend_impl.h b/webkit/glue/webdevtoolsfrontend_impl.h index e60e7d5..7557ea1 100644 --- a/webkit/glue/webdevtoolsfrontend_impl.h +++ b/webkit/glue/webdevtoolsfrontend_impl.h @@ -48,7 +48,11 @@ class WebDevToolsFrontendImpl : public WebKit::WebDevToolsFrontend, virtual ~WebDevToolsFrontendImpl(); // DevToolsRpc::Delegate implementation. - virtual void SendRpcMessage(const WebKit::WebDevToolsMessageData& data); + virtual void SendRpcMessage(const String& class_name, + const String& method_name, + const String& param1, + const String& param2, + const String& param3); // WebDevToolsFrontend implementation. virtual void dispatchMessageFromAgent(const WebKit::WebString& class_name, diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index adc6687..c2bb0b6 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -237,6 +237,8 @@ # those in the test subdirectory and those with unittest in in their # names. 'glue/devtools/apu_agent_delegate.h', + 'glue/devtools/devtools_rpc.h', + 'glue/devtools/devtools_rpc_js.h', 'glue/devtools/bound_object.cc', 'glue/devtools/bound_object.h', 'glue/devtools/debugger_agent.h', @@ -244,10 +246,6 @@ 'glue/devtools/debugger_agent_impl.h', 'glue/devtools/debugger_agent_manager.cc', 'glue/devtools/debugger_agent_manager.h', - 'glue/devtools/devtools_message_data.cc', - 'glue/devtools/devtools_message_data.h', - 'glue/devtools/devtools_rpc.h', - 'glue/devtools/devtools_rpc_js.h', 'glue/devtools/profiler_agent.h', 'glue/devtools/profiler_agent_impl.cc', 'glue/devtools/profiler_agent_impl.h', |