blob: 0931e30216b969c65325217e94bffe78f3b10779 [file] [log] [blame]
[email protected]ce208f872012-03-07 20:42:561// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]7a4de7a62010-08-17 18:38:242// 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,
[email protected]8a8c9c72011-03-01 20:35:477// notably a few IPC unit tests.
[email protected]7a4de7a62010-08-17 18:38:248
9#ifndef IPC_IPC_MESSAGE_UTILS_IMPL_H_
10#define IPC_IPC_MESSAGE_UTILS_IMPL_H_
11
12namespace IPC {
13
14template <class ParamType>
[email protected]1d4ecf42011-08-26 21:27:3015void MessageSchema<ParamType>::Write(Message* msg, const RefParam& p) {
16 WriteParam(msg, p);
[email protected]7a4de7a62010-08-17 18:38:2417}
18
19template <class ParamType>
[email protected]1d4ecf42011-08-26 21:27:3020bool MessageSchema<ParamType>::Read(const Message* msg, Param* p) {
[email protected]ce208f872012-03-07 20:42:5621 PickleIterator iter(*msg);
[email protected]7a4de7a62010-08-17 18:38:2422 if (ReadParam(msg, &iter, p))
23 return true;
24 NOTREACHED() << "Error deserializing message " << msg->type();
25 return false;
26}
27
[email protected]7a4de7a62010-08-17 18:38:2428template <class SendParamType, class ReplyParamType>
[email protected]1d4ecf42011-08-26 21:27:3029void SyncMessageSchema<SendParamType, ReplyParamType>::Write(
30 Message* msg,
31 const RefSendParam& send) {
32 WriteParam(msg, send);
[email protected]7a4de7a62010-08-17 18:38:2433}
34
35template <class SendParamType, class ReplyParamType>
[email protected]1d4ecf42011-08-26 21:27:3036bool SyncMessageSchema<SendParamType, ReplyParamType>::ReadSendParam(
[email protected]7a4de7a62010-08-17 18:38:2437 const Message* msg, SendParam* p) {
[email protected]ce208f872012-03-07 20:42:5638 PickleIterator iter = SyncMessage::GetDataIterator(msg);
[email protected]7a4de7a62010-08-17 18:38:2439 return ReadParam(msg, &iter, p);
40}
41
42template <class SendParamType, class ReplyParamType>
[email protected]1d4ecf42011-08-26 21:27:3043bool SyncMessageSchema<SendParamType, ReplyParamType>::ReadReplyParam(
[email protected]7a4de7a62010-08-17 18:38:2444 const Message* msg, typename TupleTypes<ReplyParam>::ValueTuple* p) {
[email protected]ce208f872012-03-07 20:42:5645 PickleIterator iter = SyncMessage::GetDataIterator(msg);
[email protected]7a4de7a62010-08-17 18:38:2446 return ReadParam(msg, &iter, p);
47}
48
49} // namespace IPC
50
51#endif // IPC_IPC_MESSAGE_UTILS_IMPL_H_