| 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 "core/streams/ReadableStreamOperations.h" | 5 #include "core/streams/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/ToV8.h" |
| 10 #include "bindings/core/v8/V8ScriptRunner.h" | 10 #include "bindings/core/v8/V8ScriptRunner.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 return ScriptValue(scriptState, jsStrategy); | 34 return ScriptValue(scriptState, jsStrategy); |
| 35 } | 35 } |
| 36 | 36 |
| 37 ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState, Script
Value stream, ExceptionState& es) | 37 ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState, Script
Value stream, ExceptionState& es) |
| 38 { | 38 { |
| 39 ASSERT(isReadableStream(scriptState, stream)); | 39 ASSERT(isReadableStream(scriptState, stream)); |
| 40 | 40 |
| 41 v8::TryCatch block(scriptState->isolate()); | 41 v8::TryCatch block(scriptState->isolate()); |
| 42 v8::Local<v8::Value> args[] = { stream.v8Value() }; | 42 v8::Local<v8::Value> args[] = { stream.v8Value() }; |
| 43 ScriptValue result(scriptState, V8ScriptRunner::callExtra(scriptState, "Acqu
ireReadableStreamReader", args)); | 43 ScriptValue result(scriptState, V8ScriptRunner::callExtra(scriptState, "Acqu
ireReadableStreamDefaultReader", args)); |
| 44 if (block.HasCaught()) | 44 if (block.HasCaught()) |
| 45 es.rethrowV8Exception(block.Exception()); | 45 es.rethrowV8Exception(block.Exception()); |
| 46 return result; | 46 return result; |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool ReadableStreamOperations::isReadableStream(ScriptState* scriptState, Script
Value value) | 49 bool ReadableStreamOperations::isReadableStream(ScriptState* scriptState, Script
Value value) |
| 50 { | 50 { |
| 51 ASSERT(!value.isEmpty()); | 51 ASSERT(!value.isEmpty()); |
| 52 | 52 |
| 53 if (!value.isObject()) | 53 if (!value.isObject()) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool ReadableStreamOperations::isErrored(ScriptState* scriptState, ScriptValue s
tream) | 92 bool ReadableStreamOperations::isErrored(ScriptState* scriptState, ScriptValue s
tream) |
| 93 { | 93 { |
| 94 ASSERT(isReadableStream(scriptState, stream)); | 94 ASSERT(isReadableStream(scriptState, stream)); |
| 95 | 95 |
| 96 v8::Local<v8::Value> args[] = { stream.v8Value() }; | 96 v8::Local<v8::Value> args[] = { stream.v8Value() }; |
| 97 return V8ScriptRunner::callExtraOrCrash(scriptState, "IsReadableStreamErrore
d", args)->ToBoolean()->Value(); | 97 return V8ScriptRunner::callExtraOrCrash(scriptState, "IsReadableStreamErrore
d", args)->ToBoolean()->Value(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool ReadableStreamOperations::isReadableStreamReader(ScriptState* scriptState,
ScriptValue value) | 100 bool ReadableStreamOperations::isReadableStreamDefaultReader(ScriptState* script
State, ScriptValue value) |
| 101 { | 101 { |
| 102 ASSERT(!value.isEmpty()); | 102 ASSERT(!value.isEmpty()); |
| 103 | 103 |
| 104 if (!value.isObject()) | 104 if (!value.isObject()) |
| 105 return false; | 105 return false; |
| 106 | 106 |
| 107 v8::Local<v8::Value> args[] = { value.v8Value() }; | 107 v8::Local<v8::Value> args[] = { value.v8Value() }; |
| 108 return V8ScriptRunner::callExtraOrCrash(scriptState, "IsReadableStreamReader
", args)->ToBoolean()->Value(); | 108 return V8ScriptRunner::callExtraOrCrash(scriptState, "IsReadableStreamDefaul
tReader", args)->ToBoolean()->Value(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 ScriptPromise ReadableStreamOperations::read(ScriptState* scriptState, ScriptVal
ue reader) | 111 ScriptPromise ReadableStreamOperations::defaultReaderRead(ScriptState* scriptSta
te, ScriptValue reader) |
| 112 { | 112 { |
| 113 ASSERT(isReadableStreamReader(scriptState, reader)); | 113 ASSERT(isReadableStreamDefaultReader(scriptState, reader)); |
| 114 | 114 |
| 115 v8::Local<v8::Value> args[] = { reader.v8Value() }; | 115 v8::Local<v8::Value> args[] = { reader.v8Value() }; |
| 116 return ScriptPromise::cast(scriptState, V8ScriptRunner::callExtraOrCrash(scr
iptState, "ReadFromReadableStreamReader", args)); | 116 return ScriptPromise::cast(scriptState, V8ScriptRunner::callExtraOrCrash(scr
iptState, "ReadableStreamDefaultReaderRead", args)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace blink | 119 } // namespace blink |
| 120 | |
| OLD | NEW |