OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef UnderlyingSourceBase_h | 5 #ifndef UnderlyingSourceBase_h |
6 #define UnderlyingSourceBase_h | 6 #define UnderlyingSourceBase_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
10 #include "bindings/core/v8/ScriptValue.h" | 10 #include "bindings/core/v8/ScriptValue.h" |
11 #include "bindings/core/v8/ScriptWrappable.h" | 11 #include "bindings/core/v8/ScriptWrappable.h" |
12 #include "core/CoreExport.h" | 12 #include "core/CoreExport.h" |
13 #include "core/dom/ContextLifecycleObserver.h" | 13 #include "core/dom/ActiveDOMObject.h" |
14 #include "platform/heap/GarbageCollected.h" | 14 #include "platform/heap/GarbageCollected.h" |
15 #include "platform/heap/Handle.h" | 15 #include "platform/heap/Handle.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 class ReadableStreamController; | 19 class ReadableStreamController; |
20 | 20 |
21 class CORE_EXPORT UnderlyingSourceBase : public GarbageCollectedFinalized<Underl
yingSourceBase>, public ScriptWrappable, public ContextLifecycleObserver { | 21 class CORE_EXPORT UnderlyingSourceBase : public GarbageCollectedFinalized<Underl
yingSourceBase>, public ScriptWrappable, public ActiveDOMObject { |
22 DEFINE_WRAPPERTYPEINFO(); | 22 DEFINE_WRAPPERTYPEINFO(); |
23 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(UnderlyingSourceBase); | 23 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(UnderlyingSourceBase); |
24 | 24 |
25 public: | 25 public: |
26 DECLARE_VIRTUAL_TRACE(); | 26 DECLARE_VIRTUAL_TRACE(); |
27 virtual ~UnderlyingSourceBase() {} | 27 virtual ~UnderlyingSourceBase() {} |
28 | 28 |
29 ScriptPromise startWrapper(ScriptState*, ScriptValue stream); | 29 ScriptPromise startWrapper(ScriptState*, ScriptValue stream); |
30 virtual ScriptPromise start(ScriptState*); | 30 virtual ScriptPromise start(ScriptState*); |
31 | 31 |
32 virtual ScriptPromise pull(ScriptState*); | 32 virtual ScriptPromise pull(ScriptState*); |
33 | 33 |
34 ScriptPromise cancelWrapper(ScriptState*, ScriptValue reason); | 34 ScriptPromise cancelWrapper(ScriptState*, ScriptValue reason); |
35 virtual ScriptPromise cancel(ScriptState*, ScriptValue reason); | 35 virtual ScriptPromise cancel(ScriptState*, ScriptValue reason); |
36 | 36 |
| 37 // ActiveDOMObject |
37 bool hasPendingActivity() const override; | 38 bool hasPendingActivity() const override; |
38 void contextDestroyed() override; | 39 void stop() override; |
39 | 40 |
40 protected: | 41 protected: |
41 explicit UnderlyingSourceBase(ScriptState* scriptState) | 42 explicit UnderlyingSourceBase(ScriptState* scriptState) |
42 : ContextLifecycleObserver(scriptState->executionContext()) | 43 : ActiveDOMObject(scriptState->executionContext()) |
43 { | 44 { |
| 45 this->suspendIfNeeded(); |
44 } | 46 } |
45 | 47 |
46 ReadableStreamController* controller() const { return m_controller; } | 48 ReadableStreamController* controller() const { return m_controller; } |
47 | 49 |
48 private: | 50 private: |
49 Member<ReadableStreamController> m_controller; | 51 Member<ReadableStreamController> m_controller; |
50 }; | 52 }; |
51 | 53 |
52 } // namespace blink | 54 } // namespace blink |
53 | 55 |
54 #endif // UnderlyingSourceBase_h | 56 #endif // UnderlyingSourceBase_h |
OLD | NEW |