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

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

Issue 1655333002: Add message sizing to basic IPC traits and struct macros. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@with-pickles
Patch Set: include ArrayHeader in size (oops!) and ensure the buffer doesn't relocate Created 4 years, 10 months 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
« no previous file with comments | « mojo/public/cpp/bindings/tests/pickled_struct_chromium.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_chromium.h" 5 #include "mojo/public/cpp/bindings/tests/pickled_struct_chromium.h"
6 6
7 #include "base/pickle.h" 7 #include "base/pickle.h"
8 8
9 namespace mojo { 9 namespace mojo {
10 namespace test { 10 namespace test {
11 11
12 PickledStructChromium::PickledStructChromium() {} 12 PickledStructChromium::PickledStructChromium() {}
13 13
14 PickledStructChromium::PickledStructChromium(int foo, int bar) 14 PickledStructChromium::PickledStructChromium(int foo, int bar)
15 : foo_(foo), bar_(bar) { 15 : foo_(foo), bar_(bar) {
16 } 16 }
17 17
18 PickledStructChromium::~PickledStructChromium() {} 18 PickledStructChromium::~PickledStructChromium() {}
19 19
20 } // namespace test 20 } // namespace test
21 } // namespace mojo 21 } // namespace mojo
22 22
23 namespace IPC { 23 namespace IPC {
24 24
25 void ParamTraits<mojo::test::PickledStructChromium>::GetSize(
26 base::PickleSizer* sizer,
27 const param_type& p) {
28 sizer->AddInt();
29 sizer->AddInt();
30 }
31
25 void ParamTraits<mojo::test::PickledStructChromium>::Write( 32 void ParamTraits<mojo::test::PickledStructChromium>::Write(
26 base::Pickle* m, 33 base::Pickle* m,
27 const param_type& p) { 34 const param_type& p) {
28 m->WriteInt(p.foo()); 35 m->WriteInt(p.foo());
29 m->WriteInt(p.bar()); 36 m->WriteInt(p.bar());
30 } 37 }
31 38
32 bool ParamTraits<mojo::test::PickledStructChromium>::Read( 39 bool ParamTraits<mojo::test::PickledStructChromium>::Read(
33 const base::Pickle* m, 40 const base::Pickle* m,
34 base::PickleIterator* iter, 41 base::PickleIterator* iter,
35 param_type* p) { 42 param_type* p) {
36 int foo, bar; 43 int foo, bar;
37 if (!iter->ReadInt(&foo) || !iter->ReadInt(&bar)) 44 if (!iter->ReadInt(&foo) || !iter->ReadInt(&bar))
38 return false; 45 return false;
39 46
40 p->set_foo(foo); 47 p->set_foo(foo);
41 p->set_bar(bar); 48 p->set_bar(bar);
42 return true; 49 return true;
43 } 50 }
44 51
45 } // namespace IPC 52 } // namespace IPC
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/pickled_struct_chromium.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698