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