| 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 #include "core/streams/UnderlyingSourceBase.h" |
| 11 #include <v8.h> |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 namespace JSStreams { |
| 16 |
| 17 ScriptValue createReadableStream(ScriptState* scriptState, UnderlyingSourceBase*
underlyingSource, ScriptValue strategy) |
| 18 { |
| 19 ScriptState::Scope scope(scriptState); |
| 20 auto global = scriptState->context()->Global(); |
| 21 auto isolate = scriptState->isolate(); |
| 22 |
| 23 auto jsUnderlyingSource = toV8(underlyingSource, global, isolate); |
| 24 auto jsStrategy = strategy.v8Value(); |
| 25 |
| 26 auto sentinel = scriptState->getFromExtrasExports("createWithExternalControl
lerSentinel").v8Value(); |
| 27 auto constructor = scriptState->getFromExtrasExports("ReadableStream").v8Val
ue().As<v8::Function>(); |
| 28 |
| 29 v8::Local<v8::Value> args[] = { jsUnderlyingSource, jsStrategy, sentinel }; |
| 30 |
| 31 V8RecursionScope::MicrotaskSuppression mtsScope(isolate); |
| 32 auto jsStream = constructor->NewInstance(arraysize(args), args); |
| 33 |
| 34 return ScriptValue(scriptState, jsStream); |
| 35 } |
| 36 |
| 37 ScriptValue createCountQueuingStrategy(ScriptState* scriptState, size_t highWate
rMark) |
| 38 { |
| 39 ScriptState::Scope scope(scriptState); |
| 40 auto isolate = scriptState->isolate(); |
| 41 |
| 42 auto constructor = scriptState->getFromExtrasExports("BuiltInCountQueuingStr
ategy").v8Value().As<v8::Function>(); |
| 43 |
| 44 v8::Local<v8::Value> args[] = { v8::Number::New(isolate, highWaterMark) }; |
| 45 |
| 46 V8RecursionScope::MicrotaskSuppression mtsScope(isolate); |
| 47 auto jsStrategy = constructor->NewInstance(arraysize(args), args); |
| 48 |
| 49 return ScriptValue(scriptState, jsStrategy); |
| 50 } |
| 51 |
| 52 } // namespace JSStreams |
| 53 |
| 54 } // namespace blink |
| OLD | NEW |