| 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..b6fb2ad08d6b3454cc2c1b25a25b021defc7a55a
|
| --- /dev/null
|
| +++ b/Source/core/streams/ReadableStream2.cpp
|
| @@ -0,0 +1,58 @@
|
| +// 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"
|
| +
|
| +namespace blink {
|
| +
|
| +ReadableStream2::ReadableStream2(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);
|
| +
|
| + m_stream = ScriptValue(scriptState, jsStream);
|
| +}
|
| +
|
| +bool ReadableStream2::isLocked() const
|
| +{
|
| + ScriptState::Scope scope(m_stream.scriptState());
|
| + auto func = m_stream.scriptState()->getFromExtrasExports("IsReadableStreamLocked").v8Value().As<v8::Function>();
|
| +
|
| + auto undefined = v8::Undefined(m_stream.isolate());
|
| + v8::Local<v8::Value> args[] = { m_stream.v8Value() };
|
| + return func->Call(undefined, arraysize(args), args).As<v8::Boolean>()->Value();
|
| +}
|
| +
|
| +ScriptValue ReadableStream2::createCountQueuingStrategy(ScriptState* scriptState, double 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);
|
| +}
|
| +
|
| +}
|
|
|