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

Unified Diff: src/value-serializer.h

Issue 2768923002: WIP: Allow ValueSerializer clients to transfer long strings out of band.
Patch Set: Created 3 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
« 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 ef424698d0e59d10323d4f5a136ffcabb5710881..393fe2b73bbf190a58c283f93b443427f922c86c 100644
--- a/src/value-serializer.h
+++ b/src/value-serializer.h
@@ -94,6 +94,16 @@ class ValueSerializer {
*/
void SetTreatArrayBufferViewsAsHostObjects(bool mode);
+ /*
+ * If a positive values is assigned, strings of at least that length will be
+ * passed to the delegate instead of serialized inline into the buffer.
+ * This option is recommended only if the delegate has a more efficient means
+ * of delivering those strings. By default, this feature is disabled.
+ */
+ void SetMinimumLongStringLength(int length) {
+ long_string_threshold_ = length;
+ }
+
private:
// Managing allocations of the internal buffer.
Maybe<bool> ExpandBuffer(size_t required_capacity);
@@ -112,7 +122,7 @@ class ValueSerializer {
void WriteOddball(Oddball* oddball);
void WriteSmi(Smi* smi);
void WriteHeapNumber(HeapNumber* number);
- void WriteString(Handle<String> string);
+ Maybe<bool> WriteString(Handle<String> string);
Maybe<bool> WriteJSReceiver(Handle<JSReceiver> receiver) WARN_UNUSED_RESULT;
Maybe<bool> WriteJSObject(Handle<JSObject> object) WARN_UNUSED_RESULT;
Maybe<bool> WriteJSObjectSlow(Handle<JSObject> object) WARN_UNUSED_RESULT;
@@ -164,6 +174,10 @@ class ValueSerializer {
// A similar map, for transferred array buffers.
IdentityMap<uint32_t, ZoneAllocationPolicy> array_buffer_transfer_map_;
+ // Used for tracking long strings.
+ int long_string_threshold_ = -1;
+ IdentityMap<uint32_t, ZoneAllocationPolicy> long_string_map_;
+
DISALLOW_COPY_AND_ASSIGN(ValueSerializer);
};
@@ -212,6 +226,12 @@ class ValueDeserializer {
Handle<JSArrayBuffer> array_buffer);
/*
+ * Accepts a long string corresponding to one passed previously to
+ * ValueSerializer::Delegate::GetLongStringId.
+ */
+ void TransferLongString(uint32_t transfer_id, Handle<String> string);
+
+ /*
* Publicly exposed wire format writing methods.
* These are intended for use within the delegate's WriteHostObject method.
*/
@@ -254,6 +274,7 @@ class ValueDeserializer {
MaybeHandle<String> ReadUtf8String() WARN_UNUSED_RESULT;
MaybeHandle<String> ReadOneByteString() WARN_UNUSED_RESULT;
MaybeHandle<String> ReadTwoByteString() WARN_UNUSED_RESULT;
+ MaybeHandle<String> ReadLongString() WARN_UNUSED_RESULT;
MaybeHandle<JSObject> ReadJSObject() WARN_UNUSED_RESULT;
MaybeHandle<JSArray> ReadSparseJSArray() WARN_UNUSED_RESULT;
MaybeHandle<JSArray> ReadDenseJSArray() WARN_UNUSED_RESULT;
@@ -296,6 +317,7 @@ class ValueDeserializer {
// Always global handles.
Handle<FixedArray> id_map_;
MaybeHandle<SeededNumberDictionary> array_buffer_transfer_map_;
+ MaybeHandle<SeededNumberDictionary> long_string_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