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

Side by Side Diff: mojo/public/cpp/bindings/lib/native_struct_serialization.cc

Issue 1955123003: Mojo C++ bindings: switch the remaining callsites of the old serialization interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@24_union_and_others
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/lib/native_struct_serialization.h" 5 #include "mojo/public/cpp/bindings/lib/native_struct_serialization.h"
6 6
7 #include "mojo/public/cpp/bindings/lib/serialization.h" 7 #include "mojo/public/cpp/bindings/lib/serialization.h"
8 8
9 namespace mojo { 9 namespace mojo {
10 namespace internal {
10 11
11 size_t GetSerializedSize_(const NativeStructPtr& input, 12 // static
12 internal::SerializationContext* context) { 13 size_t UnmappedNativeStructSerializerImpl::PrepareToSerialize(
13 return internal::PrepareToSerialize<NativeStructPtr>(input, context); 14 const NativeStructPtr& input,
15 SerializationContext* context) {
16 if (!input)
17 return 0;
18 return internal::PrepareToSerialize<Array<uint8_t>>(input->data, context);
14 } 19 }
15 20
16 void Serialize_(NativeStructPtr input, 21 // static
17 internal::Buffer* buffer, 22 void UnmappedNativeStructSerializerImpl::Serialize(
18 internal::NativeStruct_Data** output, 23 const NativeStructPtr& input,
19 internal::SerializationContext* context) { 24 Buffer* buffer,
20 internal::Serialize<NativeStructPtr>(input, buffer, output, context); 25 NativeStruct_Data** output,
26 SerializationContext* context) {
27 if (!input) {
28 *output = nullptr;
29 return;
30 }
31
32 Array_Data<uint8_t>* data = nullptr;
33 const ArrayValidateParams params(0, false, nullptr);
34 internal::Serialize<Array<uint8_t>>(input->data, buffer, &data, &params,
35 context);
36 *output = reinterpret_cast<NativeStruct_Data*>(data);
21 } 37 }
22 38
23 bool Deserialize_(internal::NativeStruct_Data* input, 39 // static
24 NativeStructPtr* output, 40 bool UnmappedNativeStructSerializerImpl::Deserialize(
25 internal::SerializationContext* context) { 41 NativeStruct_Data* input,
26 return internal::Deserialize<NativeStructPtr>(input, output, context); 42 NativeStructPtr* output,
43 SerializationContext* context) {
44 Array_Data<uint8_t>* data = reinterpret_cast<Array_Data<uint8_t>*>(input);
45
46 NativeStructPtr result(NativeStruct::New());
47 if (!internal::Deserialize<Array<uint8_t>>(data, &result->data, context)) {
48 output = nullptr;
49 return false;
50 }
51 if (!result->data)
52 *output = nullptr;
53 else
54 result.Swap(output);
55 return true;
27 } 56 }
28 57
58 } // namespace internal
29 } // namespace mojo 59 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698