diff options
author | dimich@google.com <dimich@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-17 18:35:16 +0000 |
---|---|---|
committer | dimich@google.com <dimich@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-17 18:35:16 +0000 |
commit | a021b2e246b164ef6a4911d79d38df0fd14fd38b (patch) | |
tree | f4fd62c0b53caa886de5d2c94c75b7a5abd55e44 | |
parent | ff9b3fd329d6660386ea34be83441e477e682ca9 (diff) | |
download | chromium_src-a021b2e246b164ef6a4911d79d38df0fd14fd38b.zip chromium_src-a021b2e246b164ef6a4911d79d38df0fd14fd38b.tar.gz chromium_src-a021b2e246b164ef6a4911d79d38df0fd14fd38b.tar.bz2 |
Remove 6- and 7-parameter IPC message macros. Replace with a struct that packs parameters.
BUG=16685
TEST=none
Review URL: http://codereview.chromium.org/149775
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20980 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/common/ipc_message_macros.h | 45 | ||||
-rw-r--r-- | chrome/common/ipc_message_utils.h | 74 | ||||
-rw-r--r-- | chrome/common/worker_messages.h | 60 | ||||
-rw-r--r-- | chrome/common/worker_messages_internal.h | 10 | ||||
-rw-r--r-- | chrome/renderer/webworker_proxy.cc | 13 | ||||
-rw-r--r-- | chrome/renderer/webworker_proxy.h | 4 | ||||
-rw-r--r-- | chrome/worker/webworkerclient_proxy.cc | 12 |
7 files changed, 85 insertions, 133 deletions
diff --git a/chrome/common/ipc_message_macros.h b/chrome/common/ipc_message_macros.h index 4839ecd..f3c9278 100644 --- a/chrome/common/ipc_message_macros.h +++ b/chrome/common/ipc_message_macros.h @@ -95,8 +95,6 @@ #undef IPC_MESSAGE_ROUTED3 #undef IPC_MESSAGE_ROUTED4 #undef IPC_MESSAGE_ROUTED5 -#undef IPC_MESSAGE_ROUTED6 -#undef IPC_MESSAGE_ROUTED7 #undef IPC_SYNC_MESSAGE_CONTROL0_0 #undef IPC_SYNC_MESSAGE_CONTROL0_1 #undef IPC_SYNC_MESSAGE_CONTROL0_2 @@ -190,12 +188,6 @@ #define IPC_MESSAGE_ROUTED5(msg_class, type1, type2, type3, type4, type5) \ msg_class##__ID, -#define IPC_MESSAGE_ROUTED6(msg_class, type1, type2, type3, type4, type5, type6) \ - msg_class##__ID, - -#define IPC_MESSAGE_ROUTED7(msg_class, type1, type2, type3, type4, type5, type6, type7) \ - msg_class##__ID, - #define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class) \ msg_class##__ID, @@ -466,12 +458,6 @@ LogFunction g_log_function_mapping[LastMsgIndex]; #define IPC_MESSAGE_ROUTED5(msg_class, type1, type2, type3, type4, type5) \ IPC_MESSAGE_LOG(msg_class) -#define IPC_MESSAGE_ROUTED6(msg_class, type1, type2, type3, type4, type5, type6) \ - IPC_MESSAGE_LOG(msg_class) - -#define IPC_MESSAGE_ROUTED7(msg_class, type1, type2, type3, type4, type5, type6, type7) \ - IPC_MESSAGE_LOG(msg_class) - #define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class) \ IPC_MESSAGE_LOG(msg_class) @@ -720,37 +706,6 @@ LogFunction g_log_function_mapping[LastMsgIndex]; routing_id, ID, MakeRefTuple(arg1, arg2, arg3, arg4, arg5)) {} \ }; -#define IPC_MESSAGE_ROUTED6(msg_class, type1, type2, type3, type4, type5, \ - type6) \ - class msg_class : \ - public IPC::MessageWithTuple< Tuple6<type1, type2, type3, type4, type5, \ - type6> > { \ - public: \ - enum { ID = msg_class##__ID }; \ - msg_class(int32 routing_id, const type1& arg1, const type2& arg2, \ - const type3& arg3, const type4& arg4, const type5& arg5, \ - const type6& arg6) \ - : IPC::MessageWithTuple< Tuple6<type1, type2, type3, type4, type5, \ - type6> >( \ - routing_id, ID, MakeRefTuple(arg1, arg2, arg3, arg4, arg5, arg6)) {} \ - }; - -#define IPC_MESSAGE_ROUTED7(msg_class, type1, type2, type3, type4, type5, \ - type6, type7) \ - class msg_class : \ - public IPC::MessageWithTuple< Tuple7<type1, type2, type3, type4, type5, \ - type6, type7> > { \ - public: \ - enum { ID = msg_class##__ID }; \ - msg_class(int32 routing_id, const type1& arg1, const type2& arg2, \ - const type3& arg3, const type4& arg4, const type5& arg5, \ - const type6& arg6, const type7& arg7) \ - : IPC::MessageWithTuple< Tuple7<type1, type2, type3, type4, type5, \ - type6, type7> >( \ - routing_id, ID, MakeRefTuple(arg1, arg2, arg3, arg4, arg5, \ - arg6, arg7)) {} \ - }; - #define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class) \ class msg_class : public IPC::MessageWithReply<Tuple0, Tuple0 > { \ public: \ diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h index 807fd9f..c6222e8 100644 --- a/chrome/common/ipc_message_utils.h +++ b/chrome/common/ipc_message_utils.h @@ -1142,80 +1142,6 @@ struct ParamTraits< Tuple5<A, B, C, D, E> > { } }; -template <class A, class B, class C, class D, class E, class F> -struct ParamTraits< Tuple6<A, B, C, D, E, F> > { - typedef Tuple6<A, B, C, D, E, F> param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.a); - WriteParam(m, p.b); - WriteParam(m, p.c); - WriteParam(m, p.d); - WriteParam(m, p.e); - WriteParam(m, p.f); - } - static bool Read(const Message* m, void** iter, param_type* r) { - return (ReadParam(m, iter, &r->a) && - ReadParam(m, iter, &r->b) && - ReadParam(m, iter, &r->c) && - ReadParam(m, iter, &r->d) && - ReadParam(m, iter, &r->e) && - ReadParam(m, iter, &r->f)); - } - static void Log(const param_type& p, std::wstring* l) { - LogParam(p.a, l); - l->append(L", "); - LogParam(p.b, l); - l->append(L", "); - LogParam(p.c, l); - l->append(L", "); - LogParam(p.d, l); - l->append(L", "); - LogParam(p.e, l); - l->append(L", "); - LogParam(p.f, l); - } -}; - -template <class A, class B, class C, class D, class E, class F, class G> -struct ParamTraits< Tuple7<A, B, C, D, E, F, G> > { - typedef Tuple7<A, B, C, D, E, F, G> param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.a); - WriteParam(m, p.b); - WriteParam(m, p.c); - WriteParam(m, p.d); - WriteParam(m, p.e); - WriteParam(m, p.f); - WriteParam(m, p.g); - } - static bool Read(const Message* m, void** iter, param_type* r) { - return (ReadParam(m, iter, &r->a) && - ReadParam(m, iter, &r->b) && - ReadParam(m, iter, &r->c) && - ReadParam(m, iter, &r->d) && - ReadParam(m, iter, &r->e) && - ReadParam(m, iter, &r->f) && - ReadParam(m, iter, &r->g)); - } - static void Log(const param_type& p, std::wstring* l) { - LogParam(p.a, l); - l->append(L", "); - LogParam(p.b, l); - l->append(L", "); - LogParam(p.c, l); - l->append(L", "); - LogParam(p.d, l); - l->append(L", "); - LogParam(p.e, l); - l->append(L", "); - LogParam(p.f, l); - l->append(L", "); - LogParam(p.g, l); - } -}; - - - //----------------------------------------------------------------------------- // Generic message subclasses diff --git a/chrome/common/worker_messages.h b/chrome/common/worker_messages.h index c1fde97..f7a7c9cc 100644 --- a/chrome/common/worker_messages.h +++ b/chrome/common/worker_messages.h @@ -13,6 +13,66 @@ #include "base/basictypes.h" #include "chrome/common/ipc_message_utils.h" +// Parameters structure for WorkerHostMsg_PostConsoleMessageToWorkerObject, +// which has too many data parameters to be reasonably put in a predefined +// IPC message. The data members directly correspond to parameters of +// WebWorkerClient::postConsoleMessageToWorkerObject() +struct WorkerHostMsg_PostConsoleMessageToWorkerObject_Params { + int destination_identifier; + int source_identifier; + int message_type; + int message_level; + string16 message; + int line_number; + string16 source_url; +}; + +namespace IPC { + +// Traits for WorkerHostMsg_PostConsoleMessageToWorkerObject_Params structure +// to pack/unpack. +template <> +struct ParamTraits<WorkerHostMsg_PostConsoleMessageToWorkerObject_Params> { + typedef WorkerHostMsg_PostConsoleMessageToWorkerObject_Params param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.destination_identifier); + WriteParam(m, p.source_identifier); + WriteParam(m, p.message_type); + WriteParam(m, p.message_level); + WriteParam(m, p.message); + WriteParam(m, p.line_number); + WriteParam(m, p.source_url); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->destination_identifier) && + ReadParam(m, iter, &p->source_identifier) && + ReadParam(m, iter, &p->message_type) && + ReadParam(m, iter, &p->message_level) && + ReadParam(m, iter, &p->message) && + ReadParam(m, iter, &p->line_number) && + ReadParam(m, iter, &p->source_url); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.destination_identifier, l); + l->append(L", "); + LogParam(p.source_identifier, l); + l->append(L", "); + LogParam(p.message_type, l); + l->append(L", "); + LogParam(p.message_level, l); + l->append(L", "); + LogParam(p.message, l); + l->append(L", "); + LogParam(p.line_number, l); + l->append(L", "); + LogParam(p.source_url, l); + l->append(L")"); + } +}; + +} // namespace IPC #define MESSAGES_INTERNAL_FILE "chrome/common/worker_messages_internal.h" #include "chrome/common/ipc_message_macros.h" diff --git a/chrome/common/worker_messages_internal.h b/chrome/common/worker_messages_internal.h index 41707fd..74063c1 100644 --- a/chrome/common/worker_messages_internal.h +++ b/chrome/common/worker_messages_internal.h @@ -55,14 +55,8 @@ IPC_BEGIN_MESSAGES(WorkerHost) int /* line_number */, string16 /* source_url*/) - IPC_MESSAGE_ROUTED7(WorkerHostMsg_PostConsoleMessageToWorkerObject, - int /* destination */, - int /* source */, - int /* type */, - int /* level */, - string16 /* message */, - int /* line_number */, - string16 /* source_url */) + IPC_MESSAGE_ROUTED1(WorkerHostMsg_PostConsoleMessageToWorkerObject, + WorkerHostMsg_PostConsoleMessageToWorkerObject_Params) IPC_MESSAGE_ROUTED1(WorkerHostMsg_ConfirmMessageFromWorkerObject, bool /* bool has_pending_activity */) diff --git a/chrome/renderer/webworker_proxy.cc b/chrome/renderer/webworker_proxy.cc index b013aa9..54fcd47 100644 --- a/chrome/renderer/webworker_proxy.cc +++ b/chrome/renderer/webworker_proxy.cc @@ -113,9 +113,8 @@ void WebWorkerProxy::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_FORWARD(WorkerHostMsg_PostExceptionToWorkerObject, client_, WebWorkerClient::postExceptionToWorkerObject) - IPC_MESSAGE_FORWARD(WorkerHostMsg_PostConsoleMessageToWorkerObject, - client_, - WebWorkerClient::postConsoleMessageToWorkerObject) + IPC_MESSAGE_HANDLER(WorkerHostMsg_PostConsoleMessageToWorkerObject, + OnPostConsoleMessageToWorkerObject) IPC_MESSAGE_FORWARD(WorkerHostMsg_ConfirmMessageFromWorkerObject, client_, WebWorkerClient::confirmMessageFromWorkerObject) @@ -137,3 +136,11 @@ void WebWorkerProxy::OnDedicatedWorkerCreated() { Send(queued_messages[i]); } } + +void WebWorkerProxy::OnPostConsoleMessageToWorkerObject( + const WorkerHostMsg_PostConsoleMessageToWorkerObject_Params& params) { + client_->postConsoleMessageToWorkerObject(params.destination_identifier, + params.source_identifier, params.message_type, params.message_level, + params.message, params.line_number, params.source_url); +} + diff --git a/chrome/renderer/webworker_proxy.h b/chrome/renderer/webworker_proxy.h index dac97aa..b56cf8e 100644 --- a/chrome/renderer/webworker_proxy.h +++ b/chrome/renderer/webworker_proxy.h @@ -14,6 +14,7 @@ class ChildThread; class GURL; class RenderView; +struct WorkerHostMsg_PostConsoleMessageToWorkerObject_Params; // This class provides an implementation of WebWorker that the renderer provides // to the glue. This class converts function calls to IPC messages that are @@ -43,6 +44,9 @@ class WebWorkerProxy : public WebKit::WebWorker, bool Send(IPC::Message* message); void OnDedicatedWorkerCreated(); + void OnPostConsoleMessageToWorkerObject( + const WorkerHostMsg_PostConsoleMessageToWorkerObject_Params& params); + void Disconnect(); // The routing id used to reach WebWorkerClientProxy in the worker process. diff --git a/chrome/worker/webworkerclient_proxy.cc b/chrome/worker/webworkerclient_proxy.cc index 84cf05f..b22428c 100644 --- a/chrome/worker/webworkerclient_proxy.cc +++ b/chrome/worker/webworkerclient_proxy.cc @@ -98,9 +98,15 @@ void WebWorkerClientProxy::postConsoleMessageToWorkerObject( const WebString& message, int line_number, const WebString& source_url) { - Send(new WorkerHostMsg_PostConsoleMessageToWorkerObject( - route_id_, destination, source, type, level, - message, line_number, source_url)); + WorkerHostMsg_PostConsoleMessageToWorkerObject_Params params; + params.destination_identifier = destination; + params.source_identifier = source; + params.message_type = type; + params.message_level = level; + params.message = message; + params.line_number = line_number; + params.source_url = source_url; + Send(new WorkerHostMsg_PostConsoleMessageToWorkerObject(route_id_, params)); } void WebWorkerClientProxy::confirmMessageFromWorkerObject( |