diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-11 16:52:42 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-11 16:52:42 +0000 |
commit | 13d49eaf47a59c68f952b5470d11afdd7bdce396 (patch) | |
tree | dc0a665d456b121f81113f2377f7fcd6e42eb683 /ipc/ipc_message_utils.h | |
parent | aefa99e2b6abcb3e1b347d10d2b9a0e4110c68f7 (diff) | |
download | chromium_src-13d49eaf47a59c68f952b5470d11afdd7bdce396.zip chromium_src-13d49eaf47a59c68f952b5470d11afdd7bdce396.tar.gz chromium_src-13d49eaf47a59c68f952b5470d11afdd7bdce396.tar.bz2 |
Revert "FBTF: Allow forward declaration of classes passed to sync IPC messages."
This reverts commit r55735.
BUG=none
TEST=none
TBR=mirandac
Review URL: http://codereview.chromium.org/3152007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55738 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_message_utils.h')
-rw-r--r-- | ipc/ipc_message_utils.h | 117 |
1 files changed, 54 insertions, 63 deletions
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index 4882688..cdad102 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -1164,54 +1164,8 @@ class MessageWithTuple : public Message { } }; -// defined in ipc_logging.cc -void GenerateLogData(const std::string& channel, const Message& message, - LogData* data); - - -#if defined(IPC_MESSAGE_LOG_ENABLED) -inline void AddOutputParamsToLog(const Message* msg, std::wstring* l) { - const std::wstring& output_params = msg->output_params(); - if (!l->empty() && !output_params.empty()) - l->append(L", "); - - l->append(output_params); -} - -template <class ReplyParamType> -inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, - const Message* msg) { - if (msg->received_time() != 0) { - std::wstring output_params; - LogParam(reply_params, &output_params); - msg->set_output_params(output_params); - } -} - -inline void ConnectMessageAndReply(const Message* msg, Message* reply) { - if (msg->sent_time()) { - // Don't log the sync message after dispatch, as we don't have the - // output parameters at that point. Instead, save its data and log it - // with the outgoing reply message when it's sent. - LogData* data = new LogData; - GenerateLogData("", *msg, data); - msg->set_dont_log(); - reply->set_sync_log_data(data); - } -} -#else -inline void AddOutputParamsToLog(const Message* msg, std::wstring* l) {} - -template <class ReplyParamType> -inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, - const Message* msg) {} - -inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} -#endif - // This class assumes that its template argument is a RefTuple (a Tuple with -// reference elements). This would go into ipc_message_utils_impl.h, but it is -// also used by chrome_frame. +// reference elements). template <class RefTuple> class ParamDeserializer : public MessageReplyDeserializer { public: @@ -1224,6 +1178,10 @@ class ParamDeserializer : public MessageReplyDeserializer { RefTuple out_; }; +// defined in ipc_logging.cc +void GenerateLogData(const std::string& channel, const Message& message, + LogData* data); + // Used for synchronous messages. template <class SendParamType, class ReplyParamType> class MessageWithReply : public SyncMessage { @@ -1233,33 +1191,54 @@ class MessageWithReply : public SyncMessage { typedef ReplyParamType ReplyParam; MessageWithReply(int32 routing_id, uint32 type, - const RefSendParam& send, const ReplyParam& reply); - - // TODO(erg): Migrate these ReadSendParam/ReadReplyParam() methods to - // ipc_message_utils_impl.h once I figure out how to get the linkage correct - // in the release builds. - static bool ReadSendParam(const Message* msg, SendParam* p) { - void* iter = SyncMessage::GetDataIterator(msg); - return ReadParam(msg, &iter, p); + const RefSendParam& send, const ReplyParam& reply) + : SyncMessage(routing_id, type, PRIORITY_NORMAL, + new ParamDeserializer<ReplyParam>(reply)) { + WriteParam(this, send); } - static bool ReadReplyParam(const Message* msg, - typename TupleTypes<ReplyParam>::ValueTuple* p) { - void* iter = SyncMessage::GetDataIterator(msg); - return ReadParam(msg, &iter, p); + static void Log(const Message* msg, std::wstring* l) { + if (msg->is_sync()) { + SendParam p; + void* iter = SyncMessage::GetDataIterator(msg); + if (ReadParam(msg, &iter, &p)) + LogParam(p, l); + +#if defined(IPC_MESSAGE_LOG_ENABLED) + const std::wstring& output_params = msg->output_params(); + if (!l->empty() && !output_params.empty()) + l->append(L", "); + + l->append(output_params); +#endif + } else { + // This is an outgoing reply. Now that we have the output parameters, we + // can finally log the message. + typename TupleTypes<ReplyParam>::ValueTuple p; + void* iter = SyncMessage::GetDataIterator(msg); + if (ReadParam(msg, &iter, &p)) + LogParam(p, l); + } } template<class T, class Method> static bool Dispatch(const Message* msg, T* obj, Method func) { SendParam send_params; + void* iter = GetDataIterator(msg); Message* reply = GenerateReply(msg); bool error; - if (ReadSendParam(msg, &send_params)) { + if (ReadParam(msg, &iter, &send_params)) { typename TupleTypes<ReplyParam>::ValueTuple reply_params; DispatchToMethod(obj, func, send_params, &reply_params); WriteParam(reply, reply_params); error = false; - LogReplyParamsToMessage(reply_params, msg); +#ifdef IPC_MESSAGE_LOG_ENABLED + if (msg->received_time() != 0) { + std::wstring output_params; + LogParam(reply_params, &output_params); + msg->set_output_params(output_params); + } +#endif } else { NOTREACHED() << "Error deserializing message " << msg->type(); reply->set_reply_error(); @@ -1273,11 +1252,23 @@ class MessageWithReply : public SyncMessage { template<class T, class Method> static bool DispatchDelayReply(const Message* msg, T* obj, Method func) { SendParam send_params; + void* iter = GetDataIterator(msg); Message* reply = GenerateReply(msg); bool error; - if (ReadSendParam(msg, &send_params)) { + if (ReadParam(msg, &iter, &send_params)) { Tuple1<Message&> t = MakeRefTuple(*reply); - ConnectMessageAndReply(msg, reply); + +#ifdef IPC_MESSAGE_LOG_ENABLED + if (msg->sent_time()) { + // Don't log the sync message after dispatch, as we don't have the + // output parameters at that point. Instead, save its data and log it + // with the outgoing reply message when it's sent. + LogData* data = new LogData; + GenerateLogData("", *msg, data); + msg->set_dont_log(); + reply->set_sync_log_data(data); + } +#endif DispatchToMethod(obj, func, send_params, &t); error = false; } else { |