Chromium Code Reviews| Index: mojo/public/cpp/bindings/lib/map_serialization.h |
| diff --git a/mojo/public/cpp/bindings/lib/map_serialization.h b/mojo/public/cpp/bindings/lib/map_serialization.h |
| index 8ef83b3a3a554947606e20eb0aa01beaa53d06a5..d5101f42fd1acfd58566796187627211f5df9c6d 100644 |
| --- a/mojo/public/cpp/bindings/lib/map_serialization.h |
| +++ b/mojo/public/cpp/bindings/lib/map_serialization.h |
| @@ -128,7 +128,7 @@ template <typename MapKey, |
| typename MapValue, |
| typename DataKey, |
| typename DataValue> |
| -inline void SerializeMap_( |
| +inline internal::ValidationError SerializeMap_( |
| Map<MapKey, MapValue>* input, |
| internal::Buffer* buf, |
| internal::Map_Data<DataKey, DataValue>** output, |
| @@ -148,9 +148,14 @@ inline void SerializeMap_( |
| const internal::ArrayValidateParams* key_validate_params = |
| internal::MapKeyValidateParamsFactory<DataKey>::Get(); |
| - internal::ArraySerializer<MapKey, DataKey>::SerializeElements( |
| - key_iter.begin(), input->size(), buf, result->keys.ptr, |
| - key_validate_params); |
| + { |
| + auto retval = |
| + internal::ArraySerializer<MapKey, DataKey>::SerializeElements( |
| + key_iter.begin(), input->size(), buf, result->keys.ptr, |
| + key_validate_params); |
| + if (retval != internal::ValidationError::VALIDATION_ERROR_NONE) |
| + return retval; |
|
viettrungluu
2015/10/06 16:40:06
Are you supposed to set *output in this case? (Dit
vardhan
2015/10/06 22:57:14
No, not in this case -- setting "*output = nullptr
|
| + } |
| // Now we try allocate an Array_Data for the values |
| internal::Array_Data<DataValue>* values_data = |
| @@ -158,15 +163,21 @@ inline void SerializeMap_( |
| if (values_data) { |
| result->values.ptr = values_data; |
| internal::MapValueIterator<MapKey, MapValue> value_iter(input); |
| - internal::ArraySerializer<MapValue, DataValue>::SerializeElements( |
| - value_iter.begin(), input->size(), buf, result->values.ptr, |
| - value_validate_params); |
| + { |
|
viettrungluu
2015/10/06 16:40:06
These braces seem redundant.
But more generally,
vardhan
2015/10/06 22:57:14
This way, I could reuse 'retval' as the name for t
|
| + auto retval = |
| + internal::ArraySerializer<MapValue, DataValue>::SerializeElements( |
| + value_iter.begin(), input->size(), buf, result->values.ptr, |
| + value_validate_params); |
| + if (retval != internal::ValidationError::VALIDATION_ERROR_NONE) |
| + return retval; |
| + } |
| } |
| } |
| *output = result; |
| } else { |
| *output = nullptr; |
| } |
| + return internal::ValidationError::VALIDATION_ERROR_NONE; |
| } |
| template <typename MapKey, |