OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 "core/streams/UnderlyingSourceBase.h" | |
6 | |
7 #include "bindings/core/v8/ScriptPromise.h" | |
8 #include "bindings/core/v8/ScriptState.h" | |
9 #include "bindings/core/v8/ScriptValue.h" | |
10 #include "core/streams/ReadableStreamController.h" | |
11 #include <v8.h> | |
12 | |
13 namespace blink { | |
14 | |
15 ScriptPromise UnderlyingSourceBase::startWrapper(ScriptState* scriptState, Scrip tValue stream) | |
16 { | |
17 // Cannot call start twice (e.g., cannot use the same UnderlyingSourceBase t o construct multiple streams) | |
18 ASSERT(!m_controller); | |
19 | |
20 // In ReadableStream.js, we special-case externally-controlled streams by ha ving them pass themselves to start | |
21 // as the first argument. This allows us to create a ReadableStreamControlle r. | |
22 | |
23 m_controller = new ReadableStreamController(stream); | |
24 | |
25 return start(scriptState); | |
26 } | |
27 | |
28 ScriptPromise UnderlyingSourceBase::start(ScriptState* scriptState) | |
29 { | |
30 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate() )); | |
31 } | |
32 | |
33 ScriptPromise UnderlyingSourceBase::pull(ScriptState* scriptState) | |
34 { | |
35 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate() )); | |
36 } | |
37 | |
38 ScriptPromise UnderlyingSourceBase::cancelWrapper(ScriptState* scriptState, Scri ptValue reason) | |
39 { | |
40 m_controller->noteHasBeenCanceled(); | |
41 return cancel(scriptState, reason); | |
42 } | |
43 | |
44 ScriptPromise UnderlyingSourceBase::cancel(ScriptState* scriptState, ScriptValue reason) | |
45 { | |
46 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate() )); | |
47 } | |
48 | |
49 bool UnderlyingSourceBase::hasPendingActivity() const | |
50 { | |
51 if (executionContext()->activeDOMObjectsAreStopped()) | |
haraken
2016/02/04 01:27:50
It looks a bit strange that you need to have the a
yhirano
2016/02/04 01:31:28
haraken@, are you talking about activeDOMObjectsAr
| |
52 return false; | |
53 | |
54 // This will return false within a finite time period _assuming_ that | |
55 // consumers use the controller to close or error the stream. | |
56 // Browser-created readable streams should always close or error within a | |
57 // finite time period, due to timeouts etc. | |
58 return m_controller && m_controller->isActive(); | |
59 } | |
60 | |
61 DEFINE_TRACE(UnderlyingSourceBase) | |
62 { | |
63 ActiveDOMObject::trace(visitor); | |
64 visitor->trace(m_controller); | |
65 } | |
66 | |
67 } // namespace blink | |
OLD | NEW |