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

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

Issue 611633002: mojom: Add associative arrays to the mojom language. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved test classes to their own shared file. Created 6 years, 2 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
« no previous file with comments | « mojo/public/cpp/bindings/array.h ('k') | mojo/public/cpp/bindings/lib/array_serialization.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/array_internal.h
diff --git a/mojo/public/cpp/bindings/lib/array_internal.h b/mojo/public/cpp/bindings/lib/array_internal.h
index ded07b9e1c3939a3a36574a9f75abd77c48a7a8e..eb25e35210a5d49cc5d41ff2caab9664db479630 100644
--- a/mojo/public/cpp/bindings/lib/array_internal.h
+++ b/mojo/public/cpp/bindings/lib/array_internal.h
@@ -13,7 +13,9 @@
#include "mojo/public/cpp/bindings/lib/bindings_serialization.h"
#include "mojo/public/cpp/bindings/lib/bounds_checker.h"
#include "mojo/public/cpp/bindings/lib/buffer.h"
+#include "mojo/public/cpp/bindings/lib/map_data_internal.h"
#include "mojo/public/cpp/bindings/lib/template_util.h"
+#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/environment/logging.h"
@@ -141,26 +143,6 @@ struct ArrayDataTraits<bool> {
}
};
-// Array type information needed for valdiation.
-template <uint32_t in_expected_num_elements,
- bool in_element_is_nullable,
- typename InElementValidateParams>
-class ArrayValidateParams {
- public:
- // Validation information for elements. It is either another specialization of
- // ArrayValidateParams (if elements are arrays) or NoValidateParams.
- typedef InElementValidateParams ElementValidateParams;
-
- // If |expected_num_elements| is not 0, the array is expected to have exactly
- // that number of elements.
- static const uint32_t expected_num_elements = in_expected_num_elements;
- // Whether the elements are nullable.
- static const bool element_is_nullable = in_element_is_nullable;
-};
-
-// NoValidateParams is used to indicate the end of an ArrayValidateParams chain.
-class NoValidateParams {};
-
// What follows is code to support the serialization of Array_Data<T>. There
// are two interesting cases: arrays of primitives and arrays of objects.
// Arrays of objects are represented as arrays of pointers to objects.
@@ -313,6 +295,14 @@ struct ArraySerializationHelper<P*, false> {
}
};
+ template <typename Key, typename Value, typename Params>
+ struct ValidateCaller<Map_Data<Key, Value>, Params> {
+ static bool Run(const void* data, BoundsChecker* bounds_checker) {
+ return Map_Data<Key, Value>::template Validate<Params>(data,
+ bounds_checker);
+ }
+ };
+
template <typename T, typename Params>
struct ValidateCaller<Array_Data<T>, Params> {
static bool Run(const void* data, BoundsChecker* bounds_checker) {
@@ -416,7 +406,7 @@ class Array_Data {
header_.num_bytes = num_bytes;
header_.num_elements = num_elements;
}
- ~Array_Data() {}
+ ~Array_Data() = delete;
internal::ArrayHeader header_;
« no previous file with comments | « mojo/public/cpp/bindings/array.h ('k') | mojo/public/cpp/bindings/lib/array_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698