Home | History | Annotate | Download | only in tests
      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_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>::GetSize(
     29     base::PickleSizer* sizer,
     30     const param_type& p) {
     31   sizer->AddInt();
     32   sizer->AddInt();
     33 }
     34 
     35 void ParamTraits<mojo::test::PickledStructBlink>::Write(base::Pickle* m,
     36                                                         const param_type& p) {
     37   m->WriteInt(p.foo());
     38   m->WriteInt(p.bar());
     39 }
     40 
     41 bool ParamTraits<mojo::test::PickledStructBlink>::Read(
     42     const base::Pickle* m,
     43     base::PickleIterator* iter,
     44     param_type* p) {
     45   int foo, bar;
     46   if (!iter->ReadInt(&foo) || !iter->ReadInt(&bar) || foo < 0 || bar < 0)
     47     return false;
     48 
     49   p->set_foo(foo);
     50   p->set_bar(bar);
     51   return true;
     52 }
     53 
     54 #include "ipc/param_traits_size_macros.h"
     55 IPC_ENUM_TRAITS_MAX_VALUE(mojo::test::PickledEnumBlink,
     56                           mojo::test::PickledEnumBlink::VALUE_1)
     57 #include "ipc/param_traits_write_macros.h"
     58 IPC_ENUM_TRAITS_MAX_VALUE(mojo::test::PickledEnumBlink,
     59                           mojo::test::PickledEnumBlink::VALUE_1)
     60 #include "ipc/param_traits_read_macros.h"
     61 IPC_ENUM_TRAITS_MAX_VALUE(mojo::test::PickledEnumBlink,
     62                           mojo::test::PickledEnumBlink::VALUE_1)
     63 #include "ipc/param_traits_log_macros.h"
     64 IPC_ENUM_TRAITS_MAX_VALUE(mojo::test::PickledEnumBlink,
     65                           mojo::test::PickledEnumBlink::VALUE_1)
     66 
     67 }  // namespace IPC
     68