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

Unified Diff: include/v8.h

Issue 2492943002: ValueSerializer: Replace use of std::vector with a delegate-allocated buffer. (Closed)
Patch Set: correct comment Created 4 years, 1 month 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 | « no previous file | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 3e61950b1e2a6fcf7cd263795e8c14fdb83a2bac..835324622dbb9ec7bb2c5cae490a33fa5afcae16 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -1711,6 +1711,19 @@ class V8_EXPORT ValueSerializer {
* Nothing<bool>() returned.
*/
virtual Maybe<bool> WriteHostObject(Isolate* isolate, Local<Object> object);
+
+ /*
+ * Allocates memory for the buffer of at least the size provided. The actual
+ * size (which may be greater or equal) is written to |actual_size|. If no
+ * buffer has been allocated yet, nullptr will be provided.
+ */
+ virtual void* ReallocateBufferMemory(void* old_buffer, size_t size,
+ size_t* actual_size);
+
+ /*
+ * Frees a buffer allocated with |ReallocateBufferMemory|.
+ */
+ virtual void FreeBufferMemory(void* buffer);
};
explicit ValueSerializer(Isolate* isolate);
@@ -1732,7 +1745,15 @@ class V8_EXPORT ValueSerializer {
* Returns the stored data. This serializer should not be used once the buffer
* is released. The contents are undefined if a previous write has failed.
*/
- std::vector<uint8_t> ReleaseBuffer();
+ V8_DEPRECATE_SOON("Use Release()", std::vector<uint8_t> ReleaseBuffer());
+
+ /*
+ * Returns the stored data (allocated using the delegate's
+ * AllocateBufferMemory) and its size. This serializer should not be used once
+ * the buffer is released. The contents are undefined if a previous write has
+ * failed.
+ */
+ V8_WARN_UNUSED_RESULT std::pair<uint8_t*, size_t> Release();
/*
* Marks an ArrayBuffer as havings its contents transferred out of band.
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698