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 "mojo/public/cpp/bindings/tests/pickled_struct_blink.h" | 5 #include "mojo/public/cpp/bindings/tests/pickled_struct_blink.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
11 namespace test { | 11 namespace test { |
12 | 12 |
13 PickledStructBlink::PickledStructBlink() {} | 13 PickledStructBlink::PickledStructBlink() {} |
14 | 14 |
15 PickledStructBlink::PickledStructBlink(int foo, int bar) | 15 PickledStructBlink::PickledStructBlink(int foo, int bar) |
16 : foo_(foo), bar_(bar) { | 16 : foo_(foo), bar_(bar) { |
17 DCHECK_GE(foo_, 0); | 17 DCHECK_GE(foo_, 0); |
18 DCHECK_GE(bar_, 0); | 18 DCHECK_GE(bar_, 0); |
19 } | 19 } |
20 | 20 |
21 PickledStructBlink::~PickledStructBlink() {} | 21 PickledStructBlink::~PickledStructBlink() {} |
22 | 22 |
23 } // namespace test | 23 } // namespace test |
24 } // namespace mojo | 24 } // namespace mojo |
25 | 25 |
26 namespace IPC { | 26 namespace IPC { |
27 | 27 |
| 28 void ParamTraits<mojo::test::PickledStructBlink>::GetSize( |
| 29 base::PickleSizer* sizer, |
| 30 const param_type& p) { |
| 31 sizer->AddInt(); |
| 32 sizer->AddInt(); |
| 33 } |
| 34 |
28 void ParamTraits<mojo::test::PickledStructBlink>::Write(base::Pickle* m, | 35 void ParamTraits<mojo::test::PickledStructBlink>::Write(base::Pickle* m, |
29 const param_type& p) { | 36 const param_type& p) { |
30 m->WriteInt(p.foo()); | 37 m->WriteInt(p.foo()); |
31 m->WriteInt(p.bar()); | 38 m->WriteInt(p.bar()); |
32 } | 39 } |
33 | 40 |
34 bool ParamTraits<mojo::test::PickledStructBlink>::Read( | 41 bool ParamTraits<mojo::test::PickledStructBlink>::Read( |
35 const base::Pickle* m, | 42 const base::Pickle* m, |
36 base::PickleIterator* iter, | 43 base::PickleIterator* iter, |
37 param_type* p) { | 44 param_type* p) { |
38 int foo, bar; | 45 int foo, bar; |
39 if (!iter->ReadInt(&foo) || !iter->ReadInt(&bar) || foo < 0 || bar < 0) | 46 if (!iter->ReadInt(&foo) || !iter->ReadInt(&bar) || foo < 0 || bar < 0) |
40 return false; | 47 return false; |
41 | 48 |
42 p->set_foo(foo); | 49 p->set_foo(foo); |
43 p->set_bar(bar); | 50 p->set_bar(bar); |
44 return true; | 51 return true; |
45 } | 52 } |
46 | 53 |
47 } // namespace IPC | 54 } // namespace IPC |
OLD | NEW |