blob: 0931e30216b969c65325217e94bffe78f3b10779 [file] [log] [blame]
jbates@chromium.org0fc87362012-03-08 05:42:56 +09001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
erg@google.come6ffcb52010-08-18 03:38:24 +09002// 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.orgd65bab52011-03-02 05:35:47 +09007// notably a few IPC unit tests.
erg@google.come6ffcb52010-08-18 03:38:24 +09008
9#ifndef IPC_IPC_MESSAGE_UTILS_IMPL_H_
10#define IPC_IPC_MESSAGE_UTILS_IMPL_H_
11
12namespace IPC {
13
14template <class ParamType>
darin@chromium.orgb4587d52011-08-27 06:27:30 +090015void MessageSchema<ParamType>::Write(Message* msg, const RefParam& p) {
16 WriteParam(msg, p);
erg@google.come6ffcb52010-08-18 03:38:24 +090017}
18
19template <class ParamType>
darin@chromium.orgb4587d52011-08-27 06:27:30 +090020bool MessageSchema<ParamType>::Read(const Message* msg, Param* p) {
jbates@chromium.org0fc87362012-03-08 05:42:56 +090021 PickleIterator iter(*msg);
erg@google.come6ffcb52010-08-18 03:38:24 +090022 if (ReadParam(msg, &iter, p))
23 return true;
24 NOTREACHED() << "Error deserializing message " << msg->type();
25 return false;
26}
27
erg@google.come6ffcb52010-08-18 03:38:24 +090028template <class SendParamType, class ReplyParamType>
darin@chromium.orgb4587d52011-08-27 06:27:30 +090029void SyncMessageSchema<SendParamType, ReplyParamType>::Write(
30 Message* msg,
31 const RefSendParam& send) {
32 WriteParam(msg, send);
erg@google.come6ffcb52010-08-18 03:38:24 +090033}
34
35template <class SendParamType, class ReplyParamType>
darin@chromium.orgb4587d52011-08-27 06:27:30 +090036bool SyncMessageSchema<SendParamType, ReplyParamType>::ReadSendParam(
erg@google.come6ffcb52010-08-18 03:38:24 +090037 const Message* msg, SendParam* p) {
jbates@chromium.org0fc87362012-03-08 05:42:56 +090038 PickleIterator iter = SyncMessage::GetDataIterator(msg);
erg@google.come6ffcb52010-08-18 03:38:24 +090039 return ReadParam(msg, &iter, p);
40}
41
42template <class SendParamType, class ReplyParamType>
darin@chromium.orgb4587d52011-08-27 06:27:30 +090043bool SyncMessageSchema<SendParamType, ReplyParamType>::ReadReplyParam(
erg@google.come6ffcb52010-08-18 03:38:24 +090044 const Message* msg, typename TupleTypes<ReplyParam>::ValueTuple* p) {
jbates@chromium.org0fc87362012-03-08 05:42:56 +090045 PickleIterator iter = SyncMessage::GetDataIterator(msg);
erg@google.come6ffcb52010-08-18 03:38:24 +090046 return ReadParam(msg, &iter, p);
47}
48
49} // namespace IPC
50
51#endif // IPC_IPC_MESSAGE_UTILS_IMPL_H_