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

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

Issue 1535943002: Convert Pass()→std::move() in //mojo/public/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Regenerate correctly Created 4 years, 12 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 <stddef.h> 8 #include <stddef.h>
9 #include <utility>
9 10
10 #include "mojo/public/cpp/bindings/lib/array_internal.h" 11 #include "mojo/public/cpp/bindings/lib/array_internal.h"
11 #include "mojo/public/cpp/bindings/lib/map_data_internal.h" 12 #include "mojo/public/cpp/bindings/lib/map_data_internal.h"
12 #include "mojo/public/cpp/bindings/lib/map_internal.h" 13 #include "mojo/public/cpp/bindings/lib/map_internal.h"
13 #include "mojo/public/cpp/bindings/lib/string_serialization.h" 14 #include "mojo/public/cpp/bindings/lib/string_serialization.h"
14 #include "mojo/public/cpp/bindings/map.h" 15 #include "mojo/public/cpp/bindings/map.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 18
18 template <typename Key, typename Value> 19 template <typename Key, typename Value>
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const internal::ArrayValidateParams* value_validate_params) { 144 const internal::ArrayValidateParams* value_validate_params) {
144 if (input) { 145 if (input) {
145 internal::Map_Data<DataKey, DataValue>* result = 146 internal::Map_Data<DataKey, DataValue>* result =
146 internal::Map_Data<DataKey, DataValue>::New(buf); 147 internal::Map_Data<DataKey, DataValue>::New(buf);
147 if (result) { 148 if (result) {
148 Array<MapKey> keys; 149 Array<MapKey> keys;
149 Array<MapValue> values; 150 Array<MapValue> values;
150 input.DecomposeMapTo(&keys, &values); 151 input.DecomposeMapTo(&keys, &values);
151 const internal::ArrayValidateParams* key_validate_params = 152 const internal::ArrayValidateParams* key_validate_params =
152 internal::MapKeyValidateParamsFactory<DataKey>::Get(); 153 internal::MapKeyValidateParamsFactory<DataKey>::Get();
153 SerializeArray_(keys.Pass(), buf, &result->keys.ptr, key_validate_params); 154 SerializeArray_(std::move(keys), buf, &result->keys.ptr,
154 SerializeArray_(values.Pass(), buf, &result->values.ptr, 155 key_validate_params);
156 SerializeArray_(std::move(values), buf, &result->values.ptr,
155 value_validate_params); 157 value_validate_params);
156 } 158 }
157 *output = result; 159 *output = result;
158 } else { 160 } else {
159 *output = nullptr; 161 *output = nullptr;
160 } 162 }
161 } 163 }
162 164
163 template <typename MapKey, 165 template <typename MapKey,
164 typename MapValue, 166 typename MapValue,
165 typename DataKey, 167 typename DataKey,
166 typename DataValue> 168 typename DataValue>
167 inline bool Deserialize_(internal::Map_Data<DataKey, DataValue>* input, 169 inline bool Deserialize_(internal::Map_Data<DataKey, DataValue>* input,
168 Map<MapKey, MapValue>* output, 170 Map<MapKey, MapValue>* output,
169 internal::SerializationContext* context) { 171 internal::SerializationContext* context) {
170 bool success = true; 172 bool success = true;
171 if (input) { 173 if (input) {
172 Array<MapKey> keys; 174 Array<MapKey> keys;
173 Array<MapValue> values; 175 Array<MapValue> values;
174 176
175 // Note that we rely on complete deserialization taking place in order to 177 // Note that we rely on complete deserialization taking place in order to
176 // transfer ownership of all encoded handles. Therefore we don't 178 // transfer ownership of all encoded handles. Therefore we don't
177 // short-circuit on failure here. 179 // short-circuit on failure here.
178 if (!Deserialize_(input->keys.ptr, &keys, context)) 180 if (!Deserialize_(input->keys.ptr, &keys, context))
179 success = false; 181 success = false;
180 if (!Deserialize_(input->values.ptr, &values, context)) 182 if (!Deserialize_(input->values.ptr, &values, context))
181 success = false; 183 success = false;
182 184
183 *output = Map<MapKey, MapValue>(keys.Pass(), values.Pass()); 185 *output = Map<MapKey, MapValue>(std::move(keys), std::move(values));
184 } else { 186 } else {
185 output->reset(); 187 output->reset();
186 } 188 }
187 return success; 189 return success;
188 } 190 }
189 191
190 } // namespace mojo 192 } // namespace mojo
191 193
192 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ 194 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/map_internal.h ('k') | mojo/public/cpp/bindings/lib/multiplex_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698