Index: mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl |
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl |
index 339f94f1bd3827271dd583aca50bca1e67d93495..0efc9c89dbf2c641380a63d1ebae53ebd51efb65 100644 |
--- a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl |
+++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl |
@@ -35,28 +35,27 @@ class {{struct.name}} { |
// Returns the number of bytes it would take to serialize this struct's data. |
size_t GetSerializedSize() const; |
- // Returns true on successful serialization. On failure, part of the data may |
+ // Returns true on successful serialization. On failure, part of the data may |
// be serialized, until the point of failure. This API does not support |
- // serializing handles. |
+ // serializing handles. If not null, |bytes_written| is set to the number of |
+ // bytes written to |buf|, even if this function return false. |
// |
// TODO(vardhan): For now, we return true for success. Should we define a |
- // public error type for serialization? (we shouldn't reuse |
- // internal::ValidationError). |
- bool Serialize(void* buf, size_t buf_size); |
+ // public error type for serialization? Should we open up |
+ // internal::ValidationError? |
+ bool Serialize(void* buf, size_t buf_size, size_t* bytes_written = nullptr); |
- // Deserializes the given |buf| representing a serialized version of this |
- // struct. Assumes that the serialized |buf| is valid. |
+ // Deserializes the given |buf| of size |buf_size| representing a serialized |
+ // version of this struct. The buffer is validated before it is deserialized. |
+ // Returns true on successful deserialization. |
// |
- // TODO(vardhan): |
- // - Should we pass in how big |buf| is and validate that it is |
- // <= GetSerializedSize()? If so, should this validation happen all the |
- // time? |
- // - Deserialize() will CHECK-fail if you try to deserialize something with |
- // a bad offset, etc. For IPC, we |Validate()| before running |
- // deserialization if we want safety, but we probably want a recoverable |
- // error for this API. |
- // - What's the validation story? |
- void Deserialize(void* buf); |
+ // TODO(vardhan): Recover the validation error if there is one? |
+ bool Deserialize(void* buf, size_t buf_size); |
+ |
+ // Deserializes the given |buf| of size |buf_size| representing a serialized |
+ // version of this struct. The buffer is NOT validated before it is |
+ // deserialized. Returns true on successful deserialization. |
+ bool DeserializeWithoutValidation(void* buf, size_t buf_size); |
{% if struct|is_cloneable_kind %} |
{{struct.name}}Ptr Clone() const; |