OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "core/streams/ReadableStream2.h" |
| 7 |
| 8 #include "bindings/core/v8/ToV8.h" |
| 9 #include "bindings/core/v8/V8RecursionScope.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 ReadableStream2::ReadableStream2(ScriptState* scriptState, UnderlyingSourceBase*
underlyingSource, ScriptValue strategy) |
| 14 { |
| 15 ScriptState::Scope scope(scriptState); |
| 16 auto global = scriptState->context()->Global(); |
| 17 auto isolate = scriptState->isolate(); |
| 18 |
| 19 auto jsUnderlyingSource = toV8(underlyingSource, global, isolate); |
| 20 auto jsStrategy = strategy.v8Value(); |
| 21 |
| 22 auto sentinel = scriptState->getFromExtrasExports("createWithExternalControl
lerSentinel").v8Value(); |
| 23 auto constructor = scriptState->getFromExtrasExports("ReadableStream").v8Val
ue().As<v8::Function>(); |
| 24 |
| 25 v8::Local<v8::Value> args[] = { jsUnderlyingSource, jsStrategy, sentinel }; |
| 26 |
| 27 V8RecursionScope::MicrotaskSuppression mtsScope(isolate); |
| 28 auto jsStream = constructor->NewInstance(arraysize(args), args); |
| 29 |
| 30 m_stream = ScriptValue(scriptState, jsStream); |
| 31 } |
| 32 |
| 33 bool ReadableStream2::isLocked() const |
| 34 { |
| 35 ScriptState::Scope scope(m_stream.scriptState()); |
| 36 auto func = m_stream.scriptState()->getFromExtrasExports("IsReadableStreamLo
cked").v8Value().As<v8::Function>(); |
| 37 |
| 38 auto undefined = v8::Undefined(m_stream.isolate()); |
| 39 v8::Local<v8::Value> args[] = { m_stream.v8Value() }; |
| 40 return func->Call(undefined, arraysize(args), args).As<v8::Boolean>()->Value
(); |
| 41 } |
| 42 |
| 43 ScriptValue ReadableStream2::createCountQueuingStrategy(ScriptState* scriptState
, double highWaterMark) |
| 44 { |
| 45 ScriptState::Scope scope(scriptState); |
| 46 auto isolate = scriptState->isolate(); |
| 47 |
| 48 auto constructor = scriptState->getFromExtrasExports("BuiltInCountQueuingStr
ategy").v8Value().As<v8::Function>(); |
| 49 |
| 50 v8::Local<v8::Value> args[] = { v8::Number::New(isolate, highWaterMark) }; |
| 51 |
| 52 V8RecursionScope::MicrotaskSuppression mtsScope(isolate); |
| 53 auto jsStrategy = constructor->NewInstance(arraysize(args), args); |
| 54 |
| 55 return ScriptValue(scriptState, jsStrategy); |
| 56 } |
| 57 |
| 58 } |
OLD | NEW |