| 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" |
| 11 #include "platform/bindings/ScriptState.h" | 11 #include "platform/bindings/ScriptState.h" |
| 12 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 ScriptValue ReadableStreamOperations::CreateReadableStream( | 16 ScriptValue ReadableStreamOperations::CreateReadableStream( |
| 16 ScriptState* script_state, | 17 ScriptState* script_state, |
| 17 UnderlyingSourceBase* underlying_source, | 18 UnderlyingSourceBase* underlying_source, |
| 18 ScriptValue strategy) { | 19 ScriptValue strategy) { |
| 20 TRACE_EVENT0("ServiceWorker", |
| 21 "ReadableStreamOperations::CreateReadableStream"); |
| 19 ScriptState::Scope scope(script_state); | 22 ScriptState::Scope scope(script_state); |
| 20 | 23 |
| 21 v8::Local<v8::Value> js_underlying_source = | 24 v8::Local<v8::Value> js_underlying_source = |
| 22 ToV8(underlying_source, script_state); | 25 ToV8(underlying_source, script_state); |
| 23 v8::Local<v8::Value> js_strategy = strategy.V8Value(); | 26 v8::Local<v8::Value> js_strategy = strategy.V8Value(); |
| 24 v8::Local<v8::Value> args[] = {js_underlying_source, js_strategy}; | 27 v8::Local<v8::Value> args[] = {js_underlying_source, js_strategy}; |
| 25 return ScriptValue( | 28 return ScriptValue( |
| 26 script_state, | 29 script_state, |
| 27 V8ScriptRunner::CallExtraOrCrash( | 30 V8ScriptRunner::CallExtraOrCrash( |
| 28 script_state, "createReadableStreamWithExternalController", args)); | 31 script_state, "createReadableStreamWithExternalController", args)); |
| 29 } | 32 } |
| 30 | 33 |
| 31 ScriptValue ReadableStreamOperations::CreateCountQueuingStrategy( | 34 ScriptValue ReadableStreamOperations::CreateCountQueuingStrategy( |
| 32 ScriptState* script_state, | 35 ScriptState* script_state, |
| 33 size_t high_water_mark) { | 36 size_t high_water_mark) { |
| 37 TRACE_EVENT0("ServiceWorker", |
| 38 "ReadableStreamOperations::CreateCountQueuingStrategy"); |
| 34 ScriptState::Scope scope(script_state); | 39 ScriptState::Scope scope(script_state); |
| 35 | 40 |
| 36 v8::Local<v8::Value> args[] = { | 41 v8::Local<v8::Value> args[] = { |
| 37 v8::Number::New(script_state->GetIsolate(), high_water_mark)}; | 42 v8::Number::New(script_state->GetIsolate(), high_water_mark)}; |
| 38 return ScriptValue( | 43 return ScriptValue( |
| 39 script_state, | 44 script_state, |
| 40 V8ScriptRunner::CallExtraOrCrash( | 45 V8ScriptRunner::CallExtraOrCrash( |
| 41 script_state, "createBuiltInCountQueuingStrategy", args)); | 46 script_state, "createBuiltInCountQueuingStrategy", args)); |
| 42 } | 47 } |
| 43 | 48 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 branches->Get(script_state->GetContext(), 0).ToLocalChecked()); | 178 branches->Get(script_state->GetContext(), 0).ToLocalChecked()); |
| 174 *new_stream2 = ScriptValue( | 179 *new_stream2 = ScriptValue( |
| 175 script_state, | 180 script_state, |
| 176 branches->Get(script_state->GetContext(), 1).ToLocalChecked()); | 181 branches->Get(script_state->GetContext(), 1).ToLocalChecked()); |
| 177 | 182 |
| 178 DCHECK(IsReadableStream(script_state, *new_stream1)); | 183 DCHECK(IsReadableStream(script_state, *new_stream1)); |
| 179 DCHECK(IsReadableStream(script_state, *new_stream2)); | 184 DCHECK(IsReadableStream(script_state, *new_stream2)); |
| 180 } | 185 } |
| 181 | 186 |
| 182 } // namespace blink | 187 } // namespace blink |
| OLD | NEW |