Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 | 110 // We don't need an ContainerValidateParams instance for key validation since |
|
yzshen1
2016/06/02 19:57:03
Please remove this comment. It is outdated.
tibell
2016/06/03 00:01:30
Done.
| |
| 111 // we can deduce it from the Key type. (which can only be primitive types or | 111 // we can deduce it from the Key type. (which can only be primitive types or |
| 112 // non-nullable strings.) | 112 // non-nullable strings.) |
| 113 static void Serialize(MaybeConstUserType& input, | 113 static void Serialize(MaybeConstUserType& input, |
| 114 Buffer* buf, | 114 Buffer* buf, |
| 115 Data** output, | 115 Data** output, |
| 116 const ArrayValidateParams* validate_params, | 116 const ContainerValidateParams* validate_params, |
| 117 SerializationContext* context) { | 117 SerializationContext* context) { |
| 118 DCHECK(validate_params->key_validate_params); | 118 DCHECK(validate_params->key_validate_params); |
| 119 DCHECK(validate_params->element_validate_params); | 119 DCHECK(validate_params->element_validate_params); |
| 120 if (CallIsNullIfExists<Traits>(input)) { | 120 if (CallIsNullIfExists<Traits>(input)) { |
| 121 *output = nullptr; | 121 *output = nullptr; |
| 122 return; | 122 return; |
| 123 } | 123 } |
| 124 | 124 |
| 125 auto result = Data::New(buf); | 125 auto result = Data::New(buf); |
| 126 if (result) { | 126 if (result) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 for (size_t i = 0; i < size; ++i) | 167 for (size_t i = 0; i < size; ++i) |
| 168 Traits::Insert(*output, std::move(keys[i]), std::move(values[i])); | 168 Traits::Insert(*output, std::move(keys[i]), std::move(values[i])); |
| 169 return true; | 169 return true; |
| 170 } | 170 } |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 } // namespace internal | 173 } // namespace internal |
| 174 } // namespace mojo | 174 } // namespace mojo |
| 175 | 175 |
| 176 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ | 176 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ |
| OLD | NEW |