Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: mojo/public/cpp/bindings/tests/pickled_struct_blink.cc

Issue 1526533002: [mojo] Add pickling support for native-only structs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bindings-4-bool-deserialize
Patch Set: merge Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/pickled_struct_blink.h ('k') | mojo/public/cpp/bindings/tests/pickled_struct_chromium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698