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

Side by Side Diff: mojo/public/bindings/sample/generated/sample_service_serialization.cc

Issue 60803002: Simpler bindings, fewer files! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move more to the .cc file Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 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/bindings/sample/generated/sample_service_serialization.h"
6
7 namespace sample {
8 namespace internal {
9
10 // static
11 Service_Frobinate_Params* Service_Frobinate_Params::New(mojo::Buffer* buf) {
12 return new (buf->Allocate(sizeof(Service_Frobinate_Params)))
13 Service_Frobinate_Params();
14 }
15
16 Service_Frobinate_Params::Service_Frobinate_Params() {
17 _header_.num_bytes = sizeof(*this);
18 _header_.num_fields = 3;
19 }
20
21 } // namespace internal
22 } // namespace sample
23
24 namespace mojo {
25 namespace internal {
26
27 // static
28 void ObjectTraits<sample::internal::Service_Frobinate_Params>::
29 EncodePointersAndHandles(
30 sample::internal::Service_Frobinate_Params* params,
31 std::vector<mojo::Handle>* handles) {
32 Encode(&params->foo_, handles);
33 EncodeHandle(&params->port_, handles);
34 }
35
36 // static
37 bool ObjectTraits<sample::internal::Service_Frobinate_Params>::
38 DecodePointersAndHandles(
39 sample::internal::Service_Frobinate_Params* params,
40 const mojo::Message& message) {
41 if (!Decode(&params->foo_, message))
42 return false;
43 if (params->_header_.num_fields >= 3) {
44 if (!DecodeHandle(&params->port_, message.handles))
45 return false;
46 }
47
48 // TODO: validate
49 return true;
50 }
51
52 } // namespace internal
53 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698