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, QueuingStrategyBase* strategy) |
| 14 { |
| 15 ScriptState::Scope scope(scriptState); |
| 16 |
| 17 auto global = scriptState->context()->Global(); |
| 18 auto isolate = scriptState->isolate(); |
| 19 |
| 20 auto jsUnderlyingSource = toV8(underlyingSource, global, isolate); |
| 21 auto jsStrategy = toV8(strategy, global, isolate); |
| 22 |
| 23 auto sentinel = scriptState->getFromExtrasExports("createWithExternalControl
lerSentinel").v8Value(); |
| 24 auto constructor = scriptState->getFromExtrasExports("ReadableStream").v8Val
ue().As<v8::Function>(); |
| 25 |
| 26 v8::Local<v8::Value> args[] = { jsUnderlyingSource, jsStrategy, sentinel }; |
| 27 |
| 28 V8RecursionScope::MicrotaskSuppression mtsScope(isolate); |
| 29 auto jsStream = constructor->NewInstance(arraysize(args), args); |
| 30 |
| 31 m_stream = ScriptValue(scriptState, jsStream); |
| 32 } |
| 33 |
| 34 bool ReadableStream2::isLocked() const |
| 35 { |
| 36 ScriptState::Scope scope(m_stream.scriptState()); |
| 37 auto func = m_stream.scriptState()->getFromExtrasExports("IsReadableStreamLo
cked").v8Value().As<v8::Function>(); |
| 38 |
| 39 auto undefined = v8::Undefined(m_stream.isolate()); |
| 40 v8::Local<v8::Value> args[] = { m_stream.v8Value() }; |
| 41 return func->Call(undefined, arraysize(args), args).As<v8::Boolean>()->Value
(); |
| 42 } |
| 43 |
| 44 } |
OLD | NEW |