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

Side by Side Diff: mojo/public/cpp/bindings/lib/map_serialization.h

Issue 2030873002: Mojo C++ bindings: rename ArrayValidateParams for clarity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cc-enums
Patch Set: Rebase Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_
7 7
8 #include <type_traits> 8 #include <type_traits>
9 9
10 #include "mojo/public/cpp/bindings/array.h" 10 #include "mojo/public/cpp/bindings/array.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 MapKeyReader<MaybeConstUserType> key_reader(input); 100 MapKeyReader<MaybeConstUserType> key_reader(input);
101 size_t keys_size = 101 size_t keys_size =
102 KeyArraySerializer::GetSerializedSize(&key_reader, context); 102 KeyArraySerializer::GetSerializedSize(&key_reader, context);
103 MapValueReader<MaybeConstUserType> value_reader(input); 103 MapValueReader<MaybeConstUserType> value_reader(input);
104 size_t values_size = 104 size_t values_size =
105 ValueArraySerializer::GetSerializedSize(&value_reader, context); 105 ValueArraySerializer::GetSerializedSize(&value_reader, context);
106 106
107 return struct_overhead + keys_size + values_size; 107 return struct_overhead + keys_size + values_size;
108 } 108 }
109 109
110 // We don't need an ArrayValidateParams instance for key validation since
111 // we can deduce it from the Key type. (which can only be primitive types or
112 // non-nullable strings.)
113 static void Serialize(MaybeConstUserType& input, 110 static void Serialize(MaybeConstUserType& input,
114 Buffer* buf, 111 Buffer* buf,
115 Data** output, 112 Data** output,
116 const ArrayValidateParams* validate_params, 113 const ContainerValidateParams* validate_params,
117 SerializationContext* context) { 114 SerializationContext* context) {
118 DCHECK(validate_params->key_validate_params); 115 DCHECK(validate_params->key_validate_params);
119 DCHECK(validate_params->element_validate_params); 116 DCHECK(validate_params->element_validate_params);
120 if (CallIsNullIfExists<Traits>(input)) { 117 if (CallIsNullIfExists<Traits>(input)) {
121 *output = nullptr; 118 *output = nullptr;
122 return; 119 return;
123 } 120 }
124 121
125 auto result = Data::New(buf); 122 auto result = Data::New(buf);
126 if (result) { 123 if (result) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 for (size_t i = 0; i < size; ++i) 164 for (size_t i = 0; i < size; ++i)
168 Traits::Insert(*output, std::move(keys[i]), std::move(values[i])); 165 Traits::Insert(*output, std::move(keys[i]), std::move(values[i]));
169 return true; 166 return true;
170 } 167 }
171 }; 168 };
172 169
173 } // namespace internal 170 } // namespace internal
174 } // namespace mojo 171 } // namespace mojo
175 172
176 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ 173 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/map_data_internal.h ('k') | mojo/public/cpp/bindings/lib/native_struct_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698