summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/streams/writable_stream.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/streams/writable_stream.cc')
-rw-r--r--chromium/third_party/blink/renderer/core/streams/writable_stream.cc35
1 files changed, 28 insertions, 7 deletions
diff --git a/chromium/third_party/blink/renderer/core/streams/writable_stream.cc b/chromium/third_party/blink/renderer/core/streams/writable_stream.cc
index 8c3dcfd537b..eda57163385 100644
--- a/chromium/third_party/blink/renderer/core/streams/writable_stream.cc
+++ b/chromium/third_party/blink/renderer/core/streams/writable_stream.cc
@@ -11,11 +11,13 @@
#include "third_party/blink/renderer/core/streams/miscellaneous_operations.h"
#include "third_party/blink/renderer/core/streams/promise_handler.h"
#include "third_party/blink/renderer/core/streams/readable_stream.h"
+#include "third_party/blink/renderer/core/streams/readable_stream_transferring_optimizer.h"
#include "third_party/blink/renderer/core/streams/stream_promise_resolver.h"
#include "third_party/blink/renderer/core/streams/transferable_streams.h"
#include "third_party/blink/renderer/core/streams/underlying_sink_base.h"
#include "third_party/blink/renderer/core/streams/writable_stream_default_controller.h"
#include "third_party/blink/renderer/core/streams/writable_stream_default_writer.h"
+#include "third_party/blink/renderer/core/streams/writable_stream_transferring_optimizer.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/to_v8.h"
@@ -199,6 +201,16 @@ WritableStream* WritableStream::CreateWithCountQueueingStrategy(
ScriptState* script_state,
UnderlyingSinkBase* underlying_sink,
size_t high_water_mark) {
+ return CreateWithCountQueueingStrategy(script_state, underlying_sink,
+ high_water_mark,
+ /*optimizer=*/nullptr);
+}
+
+WritableStream* WritableStream::CreateWithCountQueueingStrategy(
+ ScriptState* script_state,
+ UnderlyingSinkBase* underlying_sink,
+ size_t high_water_mark,
+ std::unique_ptr<WritableStreamTransferringOptimizer> optimizer) {
// TODO(crbug.com/902633): This method of constructing a WritableStream
// introduces unnecessary trips through V8. Implement algorithms based on an
// UnderlyingSinkBase.
@@ -219,6 +231,8 @@ WritableStream* WritableStream::CreateWithCountQueueingStrategy(
exception_state);
if (exception_state.HadException())
return nullptr;
+
+ stream->transferring_optimizer_ = std::move(optimizer);
return stream;
}
@@ -240,8 +254,8 @@ void WritableStream::Serialize(ScriptState* script_state,
// 5. Let readable be a new ReadableStream in the current Realm.
// 6. Perform ! SetUpCrossRealmTransformReadable(readable, port1).
- auto* readable =
- CreateCrossRealmTransformReadable(script_state, port, exception_state);
+ auto* readable = CreateCrossRealmTransformReadable(
+ script_state, port, /*optimizer=*/nullptr, exception_state);
if (exception_state.HadException()) {
return;
}
@@ -260,9 +274,11 @@ void WritableStream::Serialize(ScriptState* script_state,
// port2 ยป).
}
-WritableStream* WritableStream::Deserialize(ScriptState* script_state,
- MessagePort* port,
- ExceptionState& exception_state) {
+WritableStream* WritableStream::Deserialize(
+ ScriptState* script_state,
+ MessagePort* port,
+ std::unique_ptr<WritableStreamTransferringOptimizer> optimizer,
+ ExceptionState& exception_state) {
// We need to execute JavaScript to call "Then" on v8::Promises. We will not
// run author code.
v8::Isolate::AllowJavascriptExecutionScope allow_js(
@@ -278,8 +294,8 @@ WritableStream* WritableStream::Deserialize(ScriptState* script_state,
// 3. Perform ! SetUpCrossRealmTransformWritable(value, port).
// In the standard |value| contains an unitialized WritableStream. In the
// implementation, we create the stream here.
- auto* writable =
- CreateCrossRealmTransformWritable(script_state, port, exception_state);
+ auto* writable = CreateCrossRealmTransformWritable(
+ script_state, port, std::move(optimizer), exception_state);
if (exception_state.HadException()) {
return nullptr;
}
@@ -816,6 +832,11 @@ void WritableStream::SetWriter(WritableStreamDefaultWriter* writer) {
writer_ = writer;
}
+std::unique_ptr<WritableStreamTransferringOptimizer>
+WritableStream::TakeTransferringOptimizer() {
+ return std::move(transferring_optimizer_);
+}
+
// static
v8::Local<v8::String> WritableStream::CreateCannotActionOnStateStreamMessage(
v8::Isolate* isolate,