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

Unified Diff: mojo/public/cpp/bindings/lib/map_data_internal.h

Issue 2112093002: Mojo C++ bindings: Merge EncodePointers/DecodePointers into Serialize/Deserialize, respectively. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@61_array_fix
Patch Set: . 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/lib/map_data_internal.h
diff --git a/mojo/public/cpp/bindings/lib/map_data_internal.h b/mojo/public/cpp/bindings/lib/map_data_internal.h
index e2633331e0278f719fe2e6e308c9672fc20679da..f8e3d2918fc0b1c2a8fec30a4d95e2313391e6f1 100644
--- a/mojo/public/cpp/bindings/lib/map_data_internal.h
+++ b/mojo/public/cpp/bindings/lib/map_data_internal.h
@@ -41,45 +41,22 @@ class Map_Data {
return false;
}
- if (!ValidateEncodedPointer(&object->keys.offset)) {
- ReportValidationError(validation_context,
- VALIDATION_ERROR_ILLEGAL_POINTER);
- return false;
- }
- if (!object->keys.offset) {
- ReportValidationError(validation_context,
- VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
- "null key array in map struct");
- return false;
- }
- if (!Array_Data<Key>::Validate(DecodePointerRaw(&object->keys.offset),
- validation_context,
- validate_params->key_validate_params)) {
+ if (!ValidatePointerNonNullable(
+ object->keys, "null key array in map struct", validation_context) ||
+ !ValidateContainer(object->keys, validation_context,
+ validate_params->key_validate_params)) {
return false;
}
- if (!ValidateEncodedPointer(&object->values.offset)) {
- ReportValidationError(validation_context,
- VALIDATION_ERROR_ILLEGAL_POINTER);
- return false;
- }
- if (!object->values.offset) {
- ReportValidationError(validation_context,
- VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
- "null value array in map struct");
- return false;
- }
- if (!Array_Data<Value>::Validate(
- DecodePointerRaw(&object->values.offset),
- validation_context, validate_params->element_validate_params)) {
+ if (!ValidatePointerNonNullable(object->values,
+ "null value array in map struct",
+ validation_context) ||
+ !ValidateContainer(object->values, validation_context,
+ validate_params->element_validate_params)) {
return false;
}
- const ArrayHeader* key_header =
- static_cast<const ArrayHeader*>(DecodePointerRaw(&object->keys.offset));
- const ArrayHeader* value_header = static_cast<const ArrayHeader*>(
- DecodePointerRaw(&object->values.offset));
- if (key_header->num_elements != value_header->num_elements) {
+ if (object->keys.Get()->size() != object->values.Get()->size()) {
ReportValidationError(validation_context,
VALIDATION_ERROR_DIFFERENT_SIZED_ARRAYS_IN_MAP);
return false;
@@ -93,16 +70,6 @@ class Map_Data {
Pointer<Array_Data<Key>> keys;
Pointer<Array_Data<Value>> values;
- void EncodePointers() {
- Encode(&keys);
- Encode(&values);
- }
-
- void DecodePointers() {
- Decode(&keys);
- Decode(&values);
- }
-
private:
Map_Data() {
header_.num_bytes = sizeof(*this);
« no previous file with comments | « mojo/public/cpp/bindings/lib/control_message_proxy.cc ('k') | mojo/public/cpp/bindings/lib/map_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698