OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/core/v8/ReadableStreamOperations.h" | 5 #include "bindings/core/v8/ReadableStreamOperations.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "bindings/core/v8/ToV8.h" |
9 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
| 11 #include "bindings/core/v8/V8RecursionScope.h" |
| 12 #include "core/streams/UnderlyingSourceBase.h" |
10 | 13 |
11 namespace blink { | 14 namespace blink { |
12 | 15 |
| 16 ScriptValue ReadableStreamOperations::createReadableStream(ScriptState* scriptSt
ate, UnderlyingSourceBase* underlyingSource, ScriptValue strategy) |
| 17 { |
| 18 ScriptState::Scope scope(scriptState); |
| 19 |
| 20 v8::Local<v8::Value> jsUnderlyingSource = toV8(underlyingSource, scriptState
); |
| 21 v8::Local<v8::Value> jsStrategy = strategy.v8Value(); |
| 22 |
| 23 V8RecursionScope::MicrotaskSuppression mtsScope(scriptState->isolate()); |
| 24 v8::Local<v8::Value> args[] = { jsUnderlyingSource, jsStrategy }; |
| 25 v8::Local<v8::Value> jsStream = v8CallExtraOrCrash(scriptState, "createReada
bleStreamWithExternalController", args); |
| 26 |
| 27 return ScriptValue(scriptState, jsStream); |
| 28 } |
| 29 |
| 30 ScriptValue ReadableStreamOperations::createCountQueuingStrategy(ScriptState* sc
riptState, size_t highWaterMark) |
| 31 { |
| 32 ScriptState::Scope scope(scriptState); |
| 33 v8::Isolate* isolate = scriptState->isolate(); |
| 34 |
| 35 v8::Local<v8::Value> args[] = { v8::Number::New(isolate, highWaterMark) }; |
| 36 v8::Local<v8::Value> jsStrategy = v8CallExtraOrCrash(scriptState, "createBui
ltInCountQueuingStrategy", args); |
| 37 |
| 38 return ScriptValue(scriptState, jsStrategy); |
| 39 } |
| 40 |
13 ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState, Script
Value stream, ExceptionState& es) | 41 ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState, Script
Value stream, ExceptionState& es) |
14 { | 42 { |
15 ASSERT(isReadableStream(scriptState, stream)); | 43 ASSERT(isReadableStream(scriptState, stream)); |
16 | 44 |
17 v8::TryCatch block(scriptState->isolate()); | 45 v8::TryCatch block(scriptState->isolate()); |
18 v8::Local<v8::Value> args[] = { stream.v8Value() }; | 46 v8::Local<v8::Value> args[] = { stream.v8Value() }; |
19 ScriptValue result(scriptState, v8CallExtra(scriptState, "AcquireReadableStr
eamReader", args)); | 47 ScriptValue result(scriptState, v8CallExtra(scriptState, "AcquireReadableStr
eamReader", args)); |
20 if (block.HasCaught()) | 48 if (block.HasCaught()) |
21 es.rethrowV8Exception(block.Exception()); | 49 es.rethrowV8Exception(block.Exception()); |
22 return result; | 50 return result; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 ScriptPromise ReadableStreamOperations::read(ScriptState* scriptState, ScriptVal
ue reader) | 91 ScriptPromise ReadableStreamOperations::read(ScriptState* scriptState, ScriptVal
ue reader) |
64 { | 92 { |
65 ASSERT(isReadableStreamReader(scriptState, reader)); | 93 ASSERT(isReadableStreamReader(scriptState, reader)); |
66 | 94 |
67 v8::Local<v8::Value> args[] = { reader.v8Value() }; | 95 v8::Local<v8::Value> args[] = { reader.v8Value() }; |
68 return ScriptPromise::cast(scriptState, v8CallExtraOrCrash(scriptState, "Rea
dFromReadableStreamReader", args)); | 96 return ScriptPromise::cast(scriptState, v8CallExtraOrCrash(scriptState, "Rea
dFromReadableStreamReader", args)); |
69 } | 97 } |
70 | 98 |
71 } // namespace blink | 99 } // namespace blink |
72 | 100 |
OLD | NEW |