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/ActiveScriptWrappable.h" | 8 #include "bindings/core/v8/ActiveScriptWrappable.h" |
9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
11 #include "bindings/core/v8/ScriptValue.h" | 11 #include "bindings/core/v8/ScriptValue.h" |
12 #include "bindings/core/v8/ScriptWrappable.h" | 12 #include "bindings/core/v8/ScriptWrappable.h" |
13 #include "core/CoreExport.h" | 13 #include "core/CoreExport.h" |
14 #include "core/dom/SuspendableObject.h" | 14 #include "core/dom/SuspendableObject.h" |
15 #include "platform/heap/GarbageCollected.h" | 15 #include "platform/heap/GarbageCollected.h" |
16 #include "platform/heap/Handle.h" | 16 #include "platform/heap/Handle.h" |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 class ReadableStreamController; | 20 class ReadableStreamController; |
21 | 21 |
22 class CORE_EXPORT UnderlyingSourceBase | 22 class CORE_EXPORT UnderlyingSourceBase |
23 : public GarbageCollectedFinalized<UnderlyingSourceBase>, | 23 : public GarbageCollectedFinalized<UnderlyingSourceBase>, |
24 public ScriptWrappable, | 24 public ScriptWrappable, |
25 public ActiveScriptWrappable, | 25 public ActiveScriptWrappable<UnderlyingSourceBase>, |
26 public SuspendableObject { | 26 public SuspendableObject { |
27 DEFINE_WRAPPERTYPEINFO(); | 27 DEFINE_WRAPPERTYPEINFO(); |
28 USING_GARBAGE_COLLECTED_MIXIN(UnderlyingSourceBase); | 28 USING_GARBAGE_COLLECTED_MIXIN(UnderlyingSourceBase); |
29 | 29 |
30 public: | 30 public: |
31 DECLARE_VIRTUAL_TRACE(); | 31 DECLARE_VIRTUAL_TRACE(); |
32 virtual ~UnderlyingSourceBase() {} | 32 virtual ~UnderlyingSourceBase() {} |
33 | 33 |
34 ScriptPromise startWrapper(ScriptState*, ScriptValue stream); | 34 ScriptPromise startWrapper(ScriptState*, ScriptValue stream); |
35 virtual ScriptPromise start(ScriptState*); | 35 virtual ScriptPromise start(ScriptState*); |
36 | 36 |
37 virtual ScriptPromise pull(ScriptState*); | 37 virtual ScriptPromise pull(ScriptState*); |
38 | 38 |
39 ScriptPromise cancelWrapper(ScriptState*, ScriptValue reason); | 39 ScriptPromise cancelWrapper(ScriptState*, ScriptValue reason); |
40 virtual ScriptPromise cancel(ScriptState*, ScriptValue reason); | 40 virtual ScriptPromise cancel(ScriptState*, ScriptValue reason); |
41 | 41 |
42 void notifyLockAcquired(); | 42 void notifyLockAcquired(); |
43 void notifyLockReleased(); | 43 void notifyLockReleased(); |
44 | 44 |
45 // ScriptWrappable | 45 // ScriptWrappable |
46 bool hasPendingActivity() const; | 46 bool hasPendingActivity() const; |
47 | 47 |
48 // SuspendableObject | 48 // SuspendableObject |
49 void contextDestroyed() override; | 49 void contextDestroyed() override; |
50 | 50 |
51 protected: | 51 protected: |
52 explicit UnderlyingSourceBase(ScriptState* scriptState) | 52 explicit UnderlyingSourceBase(ScriptState* scriptState) |
53 : ActiveScriptWrappable(this), | 53 : ActiveScriptWrappable<UnderlyingSourceBase>(this), |
54 SuspendableObject(scriptState->getExecutionContext()) { | 54 SuspendableObject(scriptState->getExecutionContext()) { |
55 this->suspendIfNeeded(); | 55 this->suspendIfNeeded(); |
56 } | 56 } |
57 | 57 |
58 ReadableStreamController* controller() const { return m_controller; } | 58 ReadableStreamController* controller() const { return m_controller; } |
59 | 59 |
60 private: | 60 private: |
61 Member<ReadableStreamController> m_controller; | 61 Member<ReadableStreamController> m_controller; |
62 bool m_isStreamLocked = false; | 62 bool m_isStreamLocked = false; |
63 }; | 63 }; |
64 | 64 |
65 } // namespace blink | 65 } // namespace blink |
66 | 66 |
67 #endif // UnderlyingSourceBase_h | 67 #endif // UnderlyingSourceBase_h |
OLD | NEW |