| 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/ToV8ForCore.h" | 8 #include "bindings/core/v8/ToV8ForCore.h" |
| 9 #include "bindings/core/v8/V8ScriptRunner.h" | 9 #include "bindings/core/v8/V8ScriptRunner.h" |
| 10 #include "core/streams/UnderlyingSourceBase.h" | 10 #include "core/streams/UnderlyingSourceBase.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 script_state, | 52 script_state, |
| 53 V8ScriptRunner::CallExtra(script_state, | 53 V8ScriptRunner::CallExtra(script_state, |
| 54 "AcquireReadableStreamDefaultReader", args)); | 54 "AcquireReadableStreamDefaultReader", args)); |
| 55 if (block.HasCaught()) | 55 if (block.HasCaught()) |
| 56 es.RethrowV8Exception(block.Exception()); | 56 es.RethrowV8Exception(block.Exception()); |
| 57 return result; | 57 return result; |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool ReadableStreamOperations::IsReadableStream(ScriptState* script_state, | 60 bool ReadableStreamOperations::IsReadableStream(ScriptState* script_state, |
| 61 ScriptValue value) { | 61 ScriptValue value) { |
| 62 ASSERT(!value.IsEmpty()); | 62 DCHECK(!value.IsEmpty()); |
| 63 | 63 |
| 64 if (!value.IsObject()) | 64 if (!value.IsObject()) |
| 65 return false; | 65 return false; |
| 66 | 66 |
| 67 v8::Local<v8::Value> args[] = {value.V8Value()}; | 67 v8::Local<v8::Value> args[] = {value.V8Value()}; |
| 68 return V8ScriptRunner::CallExtraOrCrash(script_state, "IsReadableStream", | 68 return V8ScriptRunner::CallExtraOrCrash(script_state, "IsReadableStream", |
| 69 args) | 69 args) |
| 70 ->ToBoolean() | 70 ->ToBoolean() |
| 71 ->Value(); | 71 ->Value(); |
| 72 } | 72 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 v8::Local<v8::Value> args[] = {stream.V8Value()}; | 122 v8::Local<v8::Value> args[] = {stream.V8Value()}; |
| 123 return V8ScriptRunner::CallExtraOrCrash(script_state, | 123 return V8ScriptRunner::CallExtraOrCrash(script_state, |
| 124 "IsReadableStreamErrored", args) | 124 "IsReadableStreamErrored", args) |
| 125 ->ToBoolean() | 125 ->ToBoolean() |
| 126 ->Value(); | 126 ->Value(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 bool ReadableStreamOperations::IsReadableStreamDefaultReader( | 129 bool ReadableStreamOperations::IsReadableStreamDefaultReader( |
| 130 ScriptState* script_state, | 130 ScriptState* script_state, |
| 131 ScriptValue value) { | 131 ScriptValue value) { |
| 132 ASSERT(!value.IsEmpty()); | 132 DCHECK(!value.IsEmpty()); |
| 133 | 133 |
| 134 if (!value.IsObject()) | 134 if (!value.IsObject()) |
| 135 return false; | 135 return false; |
| 136 | 136 |
| 137 v8::Local<v8::Value> args[] = {value.V8Value()}; | 137 v8::Local<v8::Value> args[] = {value.V8Value()}; |
| 138 return V8ScriptRunner::CallExtraOrCrash(script_state, | 138 return V8ScriptRunner::CallExtraOrCrash(script_state, |
| 139 "IsReadableStreamDefaultReader", args) | 139 "IsReadableStreamDefaultReader", args) |
| 140 ->ToBoolean() | 140 ->ToBoolean() |
| 141 ->Value(); | 141 ->Value(); |
| 142 } | 142 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 173 branches->Get(script_state->GetContext(), 0).ToLocalChecked()); | 173 branches->Get(script_state->GetContext(), 0).ToLocalChecked()); |
| 174 *new_stream2 = ScriptValue( | 174 *new_stream2 = ScriptValue( |
| 175 script_state, | 175 script_state, |
| 176 branches->Get(script_state->GetContext(), 1).ToLocalChecked()); | 176 branches->Get(script_state->GetContext(), 1).ToLocalChecked()); |
| 177 | 177 |
| 178 DCHECK(IsReadableStream(script_state, *new_stream1)); | 178 DCHECK(IsReadableStream(script_state, *new_stream1)); |
| 179 DCHECK(IsReadableStream(script_state, *new_stream2)); | 179 DCHECK(IsReadableStream(script_state, *new_stream2)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace blink | 182 } // namespace blink |
| OLD | NEW |