Updating trunk VERSION from 780.0 to 781.0
[chromium-blink-merge.git] / ipc / ipc_message_utils_impl.h
blob98e62c8d1f1b95675be784c599e18e90c170f4d3
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // This file contains templates forward declared (but not defined) in
6 // ipc_message_utils.h so that they are only instantiated in certain files,
7 // notably a few IPC unit tests.
9 #ifndef IPC_IPC_MESSAGE_UTILS_IMPL_H_
10 #define IPC_IPC_MESSAGE_UTILS_IMPL_H_
12 namespace IPC {
14 template <class ParamType>
15 MessageWithTuple<ParamType>::MessageWithTuple(
16 int32 routing_id, uint32 type, const RefParam& p)
17 : Message(routing_id, type, PRIORITY_NORMAL) {
18 WriteParam(this, p);
21 template <class ParamType>
22 bool MessageWithTuple<ParamType>::Read(const Message* msg, Param* p) {
23 void* iter = NULL;
24 if (ReadParam(msg, &iter, p))
25 return true;
26 NOTREACHED() << "Error deserializing message " << msg->type();
27 return false;
30 // We can't migrate the template for Log() to MessageWithTuple, because each
31 // subclass needs to have Log() to call Read(), which instantiates the above
32 // template.
34 template <class SendParamType, class ReplyParamType>
35 MessageWithReply<SendParamType, ReplyParamType>::MessageWithReply(
36 int32 routing_id, uint32 type,
37 const RefSendParam& send,
38 const ReplyParam& reply)
39 : SyncMessage(routing_id, type, PRIORITY_NORMAL,
40 new ParamDeserializer<ReplyParam>(reply)) {
41 WriteParam(this, send);
44 template <class SendParamType, class ReplyParamType>
45 bool MessageWithReply<SendParamType, ReplyParamType>::ReadSendParam(
46 const Message* msg, SendParam* p) {
47 void* iter = SyncMessage::GetDataIterator(msg);
48 return ReadParam(msg, &iter, p);
51 template <class SendParamType, class ReplyParamType>
52 bool MessageWithReply<SendParamType, ReplyParamType>::ReadReplyParam(
53 const Message* msg, typename TupleTypes<ReplyParam>::ValueTuple* p) {
54 void* iter = SyncMessage::GetDataIterator(msg);
55 return ReadParam(msg, &iter, p);
58 } // namespace IPC
60 #endif // IPC_IPC_MESSAGE_UTILS_IMPL_H_