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

Unified Diff: mojo/public/c/bindings/struct.h

Issue 2163793002: C bindings: Implement _Validate(), and some pre-requisites (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address comments Created 4 years, 5 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/c/bindings/message.h ('k') | mojo/public/c/bindings/tests/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/c/bindings/struct.h
diff --git a/mojo/public/c/bindings/struct.h b/mojo/public/c/bindings/struct.h
index 4438e1b7aaac00dc61674e8e9fcfebc10f8bc410..67798c3c3daaa3abe27c7a81d740de2fe1bfbc80 100644
--- a/mojo/public/c/bindings/struct.h
+++ b/mojo/public/c/bindings/struct.h
@@ -10,6 +10,7 @@
#include "mojo/public/c/bindings/buffer.h"
#include "mojo/public/c/bindings/lib/type_descriptor.h"
+#include "mojo/public/c/bindings/lib/util.h"
#include "mojo/public/c/system/macros.h"
MOJO_BEGIN_EXTERN_C
@@ -56,9 +57,8 @@ void MojomStruct_EncodePointersAndHandles(
// array.
// |in_type_desc|: Describes the pointer and handle fields of the mojom struct.
// |inout_struct|: Contains the struct, and any other references outside of the
-// struct.
-// |in_struct_size|: Contains the struct, and any other references outside of
-// the struct.
+// struct.
+// |in_struct_size|: Size of the buffer backed by |inout_struct| in bytes.
// |inout_handles|: Mojo handles are in this array, and are referenced by index
// in |inout_buf|.
// |in_num_handles|: Size in # of number elements available in |inout_handles|.
@@ -69,6 +69,25 @@ void MojomStruct_DecodePointersAndHandles(
MojoHandle* inout_handles,
uint32_t in_num_handles);
+// Validates the mojom struct described by the |in_struct| buffer. Any
+// references from the struct are also recursively validated, and are expected
+// to be in the same buffer backing |in_struct|.
+// |in_type_desc|: Describes the pointer and handle fields of the mojom struct.
+// |inout_struct|: Buffer containing the struct, and any other references
+// outside of the struct.
+// |in_struct_size|: Size of the buffer backed by |inout_struct| in bytes.
+// |in_num_handles|: Number of valid handles expected to be referenced from
+// |in_struct|.
+// |inout_context|: An initialized context that contains the expected location
+// of the next pointer and next offset. This is used to
+// validate that no two pointers or handles are shared.
+MojomValidationResult MojomStruct_Validate(
+ const struct MojomTypeDescriptorStruct* in_type_desc,
+ const struct MojomStructHeader* in_struct,
+ uint32_t in_struct_size,
+ uint32_t in_num_handles,
+ struct MojomValidationContext* inout_context);
+
MOJO_END_EXTERN_C
#endif // MOJO_PUBLIC_C_BINDINGS_STRUCT_H_
« no previous file with comments | « mojo/public/c/bindings/message.h ('k') | mojo/public/c/bindings/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698