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_types_chromium.h" 6 7 #include "base/pickle.h" 8 9 namespace mojo { 10 namespace test { 11 12 PickledStructChromium::PickledStructChromium() {} 13 14 PickledStructChromium::PickledStructChromium(int foo, int bar) 15 : foo_(foo), bar_(bar) {} 16 17 PickledStructChromium::~PickledStructChromium() {} 18 19 bool operator==(const PickledStructChromium& a, 20 const PickledStructChromium& b) { 21 return a.foo() == b.foo() && a.bar() == b.bar() && a.baz() == b.baz(); 22 } 23 24 } // namespace test 25 } // namespace mojo 26 27 namespace IPC { 28 29 void ParamTraits<mojo::test::PickledStructChromium>::GetSize( 30 base::PickleSizer* sizer, 31 const param_type& p) { 32 sizer->AddInt(); 33 sizer->AddInt(); 34 } 35 36 void ParamTraits<mojo::test::PickledStructChromium>::Write( 37 base::Pickle* m, 38 const param_type& p) { 39 m->WriteInt(p.foo()); 40 m->WriteInt(p.bar()); 41 } 42 43 bool ParamTraits<mojo::test::PickledStructChromium>::Read( 44 const base::Pickle* m, 45 base::PickleIterator* iter, 46 param_type* p) { 47 int foo, bar; 48 if (!iter->ReadInt(&foo) || !iter->ReadInt(&bar)) 49 return false; 50 51 p->set_foo(foo); 52 p->set_bar(bar); 53 return true; 54 } 55 56 #include "ipc/param_traits_size_macros.h" 57 IPC_ENUM_TRAITS_MAX_VALUE(mojo::test::PickledEnumChromium, 58 mojo::test::PickledEnumChromium::VALUE_2) 59 #include "ipc/param_traits_write_macros.h" 60 IPC_ENUM_TRAITS_MAX_VALUE(mojo::test::PickledEnumChromium, 61 mojo::test::PickledEnumChromium::VALUE_2) 62 #include "ipc/param_traits_read_macros.h" 63 IPC_ENUM_TRAITS_MAX_VALUE(mojo::test::PickledEnumChromium, 64 mojo::test::PickledEnumChromium::VALUE_2) 65 #include "ipc/param_traits_log_macros.h" 66 IPC_ENUM_TRAITS_MAX_VALUE(mojo::test::PickledEnumChromium, 67 mojo::test::PickledEnumChromium::VALUE_2) 68 69 } // namespace IPC 70