jbates@chromium.org | 0fc8736 | 2012-03-08 05:42:56 +0900 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
erg@google.com | e6ffcb5 | 2010-08-18 03:38:24 +0900 | [diff] [blame] | 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, |
tsepez@chromium.org | d65bab5 | 2011-03-02 05:35:47 +0900 | [diff] [blame] | 7 | // notably a few IPC unit tests. |
erg@google.com | e6ffcb5 | 2010-08-18 03:38:24 +0900 | [diff] [blame] | 8 | |
| 9 | #ifndef IPC_IPC_MESSAGE_UTILS_IMPL_H_ |
| 10 | #define IPC_IPC_MESSAGE_UTILS_IMPL_H_ |
| 11 | |
| 12 | namespace IPC { |
| 13 | |
| 14 | template <class ParamType> |
darin@chromium.org | b4587d5 | 2011-08-27 06:27:30 +0900 | [diff] [blame] | 15 | void MessageSchema<ParamType>::Write(Message* msg, const RefParam& p) { |
| 16 | WriteParam(msg, p); |
erg@google.com | e6ffcb5 | 2010-08-18 03:38:24 +0900 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | template <class ParamType> |
darin@chromium.org | b4587d5 | 2011-08-27 06:27:30 +0900 | [diff] [blame] | 20 | bool MessageSchema<ParamType>::Read(const Message* msg, Param* p) { |
jbates@chromium.org | 0fc8736 | 2012-03-08 05:42:56 +0900 | [diff] [blame] | 21 | PickleIterator iter(*msg); |
erg@google.com | e6ffcb5 | 2010-08-18 03:38:24 +0900 | [diff] [blame] | 22 | if (ReadParam(msg, &iter, p)) |
| 23 | return true; |
| 24 | NOTREACHED() << "Error deserializing message " << msg->type(); |
| 25 | return false; |
| 26 | } |
| 27 | |
erg@google.com | e6ffcb5 | 2010-08-18 03:38:24 +0900 | [diff] [blame] | 28 | template <class SendParamType, class ReplyParamType> |
darin@chromium.org | b4587d5 | 2011-08-27 06:27:30 +0900 | [diff] [blame] | 29 | void SyncMessageSchema<SendParamType, ReplyParamType>::Write( |
| 30 | Message* msg, |
| 31 | const RefSendParam& send) { |
| 32 | WriteParam(msg, send); |
erg@google.com | e6ffcb5 | 2010-08-18 03:38:24 +0900 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | template <class SendParamType, class ReplyParamType> |
darin@chromium.org | b4587d5 | 2011-08-27 06:27:30 +0900 | [diff] [blame] | 36 | bool SyncMessageSchema<SendParamType, ReplyParamType>::ReadSendParam( |
erg@google.com | e6ffcb5 | 2010-08-18 03:38:24 +0900 | [diff] [blame] | 37 | const Message* msg, SendParam* p) { |
jbates@chromium.org | 0fc8736 | 2012-03-08 05:42:56 +0900 | [diff] [blame] | 38 | PickleIterator iter = SyncMessage::GetDataIterator(msg); |
erg@google.com | e6ffcb5 | 2010-08-18 03:38:24 +0900 | [diff] [blame] | 39 | return ReadParam(msg, &iter, p); |
| 40 | } |
| 41 | |
| 42 | template <class SendParamType, class ReplyParamType> |
darin@chromium.org | b4587d5 | 2011-08-27 06:27:30 +0900 | [diff] [blame] | 43 | bool SyncMessageSchema<SendParamType, ReplyParamType>::ReadReplyParam( |
erg@google.com | e6ffcb5 | 2010-08-18 03:38:24 +0900 | [diff] [blame] | 44 | const Message* msg, typename TupleTypes<ReplyParam>::ValueTuple* p) { |
jbates@chromium.org | 0fc8736 | 2012-03-08 05:42:56 +0900 | [diff] [blame] | 45 | PickleIterator iter = SyncMessage::GetDataIterator(msg); |
erg@google.com | e6ffcb5 | 2010-08-18 03:38:24 +0900 | [diff] [blame] | 46 | return ReadParam(msg, &iter, p); |
| 47 | } |
| 48 | |
| 49 | } // namespace IPC |
| 50 | |
| 51 | #endif // IPC_IPC_MESSAGE_UTILS_IMPL_H_ |