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

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

Issue 1800753005: C++ bindings: A struct's Deserialize() now does validation before deserializing. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Address comments. DeserializeWithoutValidation returns void, doesn't take in buf_size. Created 4 years, 9 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/fixed_buffer.h
diff --git a/mojo/public/cpp/bindings/lib/fixed_buffer.h b/mojo/public/cpp/bindings/lib/fixed_buffer.h
index 83eaf97067b37c38118488166fd566e862d01178..45d0411feff009f63e72495e41534b6bb6cf4eb0 100644
--- a/mojo/public/cpp/bindings/lib/fixed_buffer.h
+++ b/mojo/public/cpp/bindings/lib/fixed_buffer.h
@@ -44,9 +44,17 @@ class FixedBuffer : public Buffer {
size_t size() const { return size_; }
+ // Returns the number of bytes used so far.
+ // TODO(vardhan): Introduce this method in |Buffer|? Doesn't seem necessary.
+ size_t BytesUsed() const { return cursor_; }
+
// Grows the buffer by |num_bytes| and returns a pointer to the start of the
// addition. The resulting address is 8-byte aligned, and the content of the
// memory is zero-filled.
+ // TODO(vardhan): Allocate() should safely fail if we run out of buffer space.
+ // This will allow us to, e.g, fail when trying to consume a buffer to
+ // serialize into, and return an insufficient space error. Currently, there
+ // are consumers of FixedBuffer that rely on it CHECK-failing.
void* Allocate(size_t num_bytes) override;
protected:

Powered by Google App Engine
This is Rietveld 408576698