OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 ReadableStream_h | 5 #ifndef ReadableStream_h |
6 #define ReadableStream_h | 6 #define ReadableStream_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseProperty.h" | 9 #include "bindings/core/v8/ScriptPromiseProperty.h" |
10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 State stateInternal() const { return m_state; } | 46 State stateInternal() const { return m_state; } |
47 DOMException* storedException() { return m_exception.get(); } | 47 DOMException* storedException() { return m_exception.get(); } |
48 | 48 |
49 virtual ScriptPromise read(ScriptState*) = 0; | 49 virtual ScriptPromise read(ScriptState*) = 0; |
50 ScriptPromise cancel(ScriptState*); | 50 ScriptPromise cancel(ScriptState*); |
51 ScriptPromise cancel(ScriptState*, ScriptValue reason); | 51 ScriptPromise cancel(ScriptState*, ScriptValue reason); |
52 ScriptPromise cancelInternal(ScriptState*, ScriptValue reason); | 52 ScriptPromise cancelInternal(ScriptState*, ScriptValue reason); |
53 | 53 |
54 virtual bool hasPendingReads() const = 0; | 54 virtual bool hasPendingReads() const = 0; |
55 virtual void resolveAllPendingReadsAsDone() = 0; | 55 virtual void resolveAllPendingReadsAsDone() = 0; |
56 virtual void rejectAllPendingReads(PassRefPtrWillBeRawPtr<DOMException>) = 0
; | 56 virtual void rejectAllPendingReads(DOMException*) = 0; |
57 | 57 |
58 void close(); | 58 void close(); |
59 void error(PassRefPtrWillBeRawPtr<DOMException>); | 59 void error(DOMException*); |
60 | 60 |
61 void didSourceStart(); | 61 void didSourceStart(); |
62 | 62 |
63 // This function is not a getter. It creates an ReadableStreamReader and | 63 // This function is not a getter. It creates an ReadableStreamReader and |
64 // returns it. | 64 // returns it. |
65 ReadableStreamReader* getReader(ExecutionContext*, ExceptionState&); | 65 ReadableStreamReader* getReader(ExecutionContext*, ExceptionState&); |
66 // Only ReadableStreamReader methods should call this function. | 66 // Only ReadableStreamReader methods should call this function. |
67 void setReader(ReadableStreamReader*); | 67 void setReader(ReadableStreamReader*); |
68 | 68 |
69 bool isLocked() const { return m_reader; } | 69 bool isLocked() const { return m_reader; } |
70 bool isLockedTo(const ReadableStreamReader* reader) const { return m_reader
== reader; } | 70 bool isLockedTo(const ReadableStreamReader* reader) const { return m_reader
== reader; } |
71 | 71 |
72 DECLARE_VIRTUAL_TRACE(); | 72 DECLARE_VIRTUAL_TRACE(); |
73 | 73 |
74 protected: | 74 protected: |
75 bool enqueuePreliminaryCheck(); | 75 bool enqueuePreliminaryCheck(); |
76 bool enqueuePostAction(); | 76 bool enqueuePostAction(); |
77 void readInternalPostAction(); | 77 void readInternalPostAction(); |
78 | 78 |
79 private: | 79 private: |
80 using WaitPromise = ScriptPromiseProperty<Member<ReadableStream>, ToV8Undefi
nedGenerator, RefPtrWillBeMember<DOMException>>; | 80 using WaitPromise = ScriptPromiseProperty<Member<ReadableStream>, ToV8Undefi
nedGenerator, Member<DOMException>>; |
81 using ClosedPromise = ScriptPromiseProperty<Member<ReadableStream>, ToV8Unde
finedGenerator, RefPtrWillBeMember<DOMException>>; | 81 using ClosedPromise = ScriptPromiseProperty<Member<ReadableStream>, ToV8Unde
finedGenerator, Member<DOMException>>; |
82 | 82 |
83 virtual bool isQueueEmpty() const = 0; | 83 virtual bool isQueueEmpty() const = 0; |
84 virtual void clearQueue() = 0; | 84 virtual void clearQueue() = 0; |
85 // This function will call ReadableStream::error on error. | 85 // This function will call ReadableStream::error on error. |
86 virtual bool shouldApplyBackpressure() = 0; | 86 virtual bool shouldApplyBackpressure() = 0; |
87 | 87 |
88 void callPullIfNeeded(); | 88 void callPullIfNeeded(); |
89 void closeInternal(); | 89 void closeInternal(); |
90 | 90 |
91 Member<UnderlyingSource> m_source; | 91 Member<UnderlyingSource> m_source; |
92 bool m_isStarted; | 92 bool m_isStarted; |
93 bool m_isDraining; | 93 bool m_isDraining; |
94 bool m_isPulling; | 94 bool m_isPulling; |
95 State m_state; | 95 State m_state; |
96 | 96 |
97 RefPtrWillBeMember<DOMException> m_exception; | 97 Member<DOMException> m_exception; |
98 Member<ReadableStreamReader> m_reader; | 98 Member<ReadableStreamReader> m_reader; |
99 }; | 99 }; |
100 | 100 |
101 } // namespace blink | 101 } // namespace blink |
102 | 102 |
103 #endif // ReadableStream_h | 103 #endif // ReadableStream_h |
OLD | NEW |