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/UnderlyingSourceBase.h" |
| 7 |
| 8 #include "core/streams/ReadableStreamController.h" |
| 9 #include <v8.h> |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 ScriptPromise UnderlyingSourceBase::startWrapper(ScriptState* scriptState, Scrip
tValue stream) |
| 14 { |
| 15 // Cannot call start twice (e.g., cannot use the same UnderlyingSourceBase t
o construct multiple streams) |
| 16 ASSERT(!m_controller); |
| 17 |
| 18 // In ReadableStream.js, we special-case externally-controlled streams by ha
ving them pass themselves to start |
| 19 // as the first argument. This allows us to create a ReadableStreamControlle
r. |
| 20 |
| 21 m_controller = new ReadableStreamController(stream); |
| 22 |
| 23 return start(scriptState); |
| 24 } |
| 25 |
| 26 ScriptPromise UnderlyingSourceBase::start(ScriptState* scriptState) |
| 27 { |
| 28 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); |
| 29 } |
| 30 |
| 31 ScriptPromise UnderlyingSourceBase::pull(ScriptState* scriptState) |
| 32 { |
| 33 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); |
| 34 } |
| 35 |
| 36 ScriptPromise UnderlyingSourceBase::cancelWrapper(ScriptState* scriptState, Scri
ptValue reason) |
| 37 { |
| 38 m_controller->noteHasBeenCanceled(); |
| 39 return cancel(scriptState, reason); |
| 40 } |
| 41 |
| 42 ScriptPromise UnderlyingSourceBase::cancel(ScriptState* scriptState, ScriptValue
reason) |
| 43 { |
| 44 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); |
| 45 } |
| 46 |
| 47 bool UnderlyingSourceBase::hasPendingActivity() const |
| 48 { |
| 49 return m_controller && m_controller->isActive(); |
| 50 } |
| 51 |
| 52 |
| 53 DEFINE_TRACE(UnderlyingSourceBase) |
| 54 { |
| 55 ActiveDOMObject::trace(visitor); |
| 56 visitor->trace(m_controller); |
| 57 } |
| 58 |
| 59 } // namespace blink |
OLD | NEW |