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

Unified Diff: src/value-serializer.h

Issue 2275033003: Blink-compatible serialization of ArrayBuffer transfer. (Closed)
Patch Set: Accepts Created 4 years, 4 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 | « src/api.cc ('k') | src/value-serializer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/value-serializer.h
diff --git a/src/value-serializer.h b/src/value-serializer.h
index 82cf21ef2b51e8dfaacf8f768b8f9eec22ff749c..a985aaffb8b533c6e87517824a13f09d9e7df5e8 100644
--- a/src/value-serializer.h
+++ b/src/value-serializer.h
@@ -59,6 +59,14 @@ class ValueSerializer {
*/
std::vector<uint8_t> ReleaseBuffer() { return std::move(buffer_); }
+ /*
+ * Marks an ArrayBuffer as havings its contents transferred out of band.
+ * Pass the corresponding JSArrayBuffer in the deserializing context to
+ * ValueDeserializer::TransferArrayBuffer.
+ */
+ void TransferArrayBuffer(uint32_t transfer_id,
+ Handle<JSArrayBuffer> array_buffer);
+
private:
// Writing the wire format.
void WriteTag(SerializationTag tag);
@@ -105,6 +113,9 @@ class ValueSerializer {
IdentityMap<uint32_t> id_map_;
uint32_t next_id_ = 0;
+ // A similar map, for transferred array buffers.
+ IdentityMap<uint32_t> array_buffer_transfer_map_;
+
DISALLOW_COPY_AND_ASSIGN(ValueSerializer);
};
@@ -144,6 +155,13 @@ class ValueDeserializer {
MaybeHandle<Object> ReadObjectUsingEntireBufferForLegacyFormat()
WARN_UNUSED_RESULT;
+ /*
+ * Accepts the array buffer corresponding to the one passed previously to
+ * ValueSerializer::TransferArrayBuffer.
+ */
+ void TransferArrayBuffer(uint32_t transfer_id,
+ Handle<JSArrayBuffer> array_buffer);
+
private:
// Reading the wire format.
Maybe<SerializationTag> PeekTag() const WARN_UNUSED_RESULT;
@@ -169,6 +187,7 @@ class ValueDeserializer {
MaybeHandle<JSMap> ReadJSMap() WARN_UNUSED_RESULT;
MaybeHandle<JSSet> ReadJSSet() WARN_UNUSED_RESULT;
MaybeHandle<JSArrayBuffer> ReadJSArrayBuffer() WARN_UNUSED_RESULT;
+ MaybeHandle<JSArrayBuffer> ReadTransferredJSArrayBuffer() WARN_UNUSED_RESULT;
/*
* Reads key-value pairs into the object until the specified end tag is
@@ -186,9 +205,12 @@ class ValueDeserializer {
const uint8_t* position_;
const uint8_t* const end_;
uint32_t version_ = 0;
- Handle<SeededNumberDictionary> id_map_; // Always a global handle.
uint32_t next_id_ = 0;
+ // Always global handles.
+ Handle<SeededNumberDictionary> id_map_;
+ MaybeHandle<SeededNumberDictionary> array_buffer_transfer_map_;
+
DISALLOW_COPY_AND_ASSIGN(ValueDeserializer);
};
« no previous file with comments | « src/api.cc ('k') | src/value-serializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698