OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ipc/ipc_mojo_param_traits.h" | 5 #include "ipc/ipc_mojo_param_traits.h" |
6 | 6 |
7 #include "ipc/ipc_message_utils.h" | 7 #include "ipc/ipc_message_utils.h" |
8 #include "ipc/ipc_mojo_message_helper.h" | 8 #include "ipc/ipc_mojo_message_helper.h" |
9 | 9 |
10 namespace IPC { | 10 namespace IPC { |
11 | 11 |
12 void ParamTraits<mojo::MessagePipeHandle>::Write(Message* m, | 12 void ParamTraits<mojo::MessagePipeHandle>::GetSize(base::PickleSizer* sizer, |
| 13 const param_type& p) { |
| 14 GetParamSize(sizer, p.is_valid()); |
| 15 if (p.is_valid()) |
| 16 sizer->AddAttachment(); |
| 17 } |
| 18 |
| 19 void ParamTraits<mojo::MessagePipeHandle>::Write(base::Pickle* m, |
13 const param_type& p) { | 20 const param_type& p) { |
14 WriteParam(m, p.is_valid()); | 21 WriteParam(m, p.is_valid()); |
15 if (p.is_valid()) | 22 if (p.is_valid()) |
16 MojoMessageHelper::WriteMessagePipeTo(m, mojo::ScopedMessagePipeHandle(p)); | 23 MojoMessageHelper::WriteMessagePipeTo(m, mojo::ScopedMessagePipeHandle(p)); |
17 } | 24 } |
18 | 25 |
19 bool ParamTraits<mojo::MessagePipeHandle>::Read(const Message* m, | 26 bool ParamTraits<mojo::MessagePipeHandle>::Read(const base::Pickle* m, |
20 base::PickleIterator* iter, | 27 base::PickleIterator* iter, |
21 param_type* r) { | 28 param_type* r) { |
22 bool is_valid; | 29 bool is_valid; |
23 if (!ReadParam(m, iter, &is_valid)) | 30 if (!ReadParam(m, iter, &is_valid)) |
24 return false; | 31 return false; |
25 if (!is_valid) | 32 if (!is_valid) |
26 return true; | 33 return true; |
27 | 34 |
28 mojo::ScopedMessagePipeHandle handle; | 35 mojo::ScopedMessagePipeHandle handle; |
29 if (!MojoMessageHelper::ReadMessagePipeFrom(m, iter, &handle)) | 36 if (!MojoMessageHelper::ReadMessagePipeFrom(m, iter, &handle)) |
30 return false; | 37 return false; |
31 DCHECK(handle.is_valid()); | 38 DCHECK(handle.is_valid()); |
32 *r = handle.release(); | 39 *r = handle.release(); |
33 return true; | 40 return true; |
34 } | 41 } |
35 | 42 |
36 void ParamTraits<mojo::MessagePipeHandle>::Log(const param_type& p, | 43 void ParamTraits<mojo::MessagePipeHandle>::Log(const param_type& p, |
37 std::string* l) { | 44 std::string* l) { |
38 l->append("mojo::MessagePipeHandle("); | 45 l->append("mojo::MessagePipeHandle("); |
39 LogParam(p.value(), l); | 46 LogParam(p.value(), l); |
40 l->append(")"); | 47 l->append(")"); |
41 } | 48 } |
42 | 49 |
43 } // namespace IPC | 50 } // namespace IPC |
OLD | NEW |