Index: Source/core/streams/ReadableStream2.cpp |
diff --git a/Source/core/streams/ReadableStream2.cpp b/Source/core/streams/ReadableStream2.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ec960ddeb40c031fca3139240fe037b49bdf74e2 |
--- /dev/null |
+++ b/Source/core/streams/ReadableStream2.cpp |
@@ -0,0 +1,54 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "core/streams/ReadableStream2.h" |
+ |
+#include "bindings/core/v8/ToV8.h" |
+#include "bindings/core/v8/V8RecursionScope.h" |
+#include "core/streams/UnderlyingSourceBase.h" |
+#include <v8.h> |
+ |
+namespace blink { |
+ |
+namespace JSStreams { |
+ |
+ScriptValue createReadableStream(ScriptState* scriptState, UnderlyingSourceBase* underlyingSource, ScriptValue strategy) |
+{ |
+ ScriptState::Scope scope(scriptState); |
+ auto global = scriptState->context()->Global(); |
+ auto isolate = scriptState->isolate(); |
+ |
+ auto jsUnderlyingSource = toV8(underlyingSource, global, isolate); |
+ auto jsStrategy = strategy.v8Value(); |
+ |
+ auto sentinel = scriptState->getFromExtrasExports("createWithExternalControllerSentinel").v8Value(); |
+ auto constructor = scriptState->getFromExtrasExports("ReadableStream").v8Value().As<v8::Function>(); |
+ |
+ v8::Local<v8::Value> args[] = { jsUnderlyingSource, jsStrategy, sentinel }; |
+ |
+ V8RecursionScope::MicrotaskSuppression mtsScope(isolate); |
+ auto jsStream = constructor->NewInstance(arraysize(args), args); |
+ |
+ return ScriptValue(scriptState, jsStream); |
+} |
+ |
+ScriptValue createCountQueuingStrategy(ScriptState* scriptState, size_t highWaterMark) |
+{ |
+ ScriptState::Scope scope(scriptState); |
+ auto isolate = scriptState->isolate(); |
+ |
+ auto constructor = scriptState->getFromExtrasExports("BuiltInCountQueuingStrategy").v8Value().As<v8::Function>(); |
+ |
+ v8::Local<v8::Value> args[] = { v8::Number::New(isolate, highWaterMark) }; |
+ |
+ V8RecursionScope::MicrotaskSuppression mtsScope(isolate); |
+ auto jsStrategy = constructor->NewInstance(arraysize(args), args); |
+ |
+ return ScriptValue(scriptState, jsStrategy); |
+} |
+ |
+} // namespace JSStreams |
+ |
+} // namespace blink |