Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: third_party/WebKit/Source/core/streams/ReadableStream.h

Issue 2227403002: Remove blink::ReadableStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ReadableStream_h
6 #define ReadableStream_h
7
8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseProperty.h"
10 #include "bindings/core/v8/ScriptState.h"
11 #include "bindings/core/v8/ScriptValue.h"
12 #include "bindings/core/v8/ScriptWrappable.h"
13 #include "bindings/core/v8/V8Binding.h"
14 #include "core/CoreExport.h"
15 #include "platform/heap/Handle.h"
16 #include "wtf/Forward.h"
17 #include "wtf/PassRefPtr.h"
18 #include "wtf/RefPtr.h"
19
20 namespace blink {
21
22 class DOMException;
23 class ExceptionState;
24 class ExecutionContext;
25 class ReadableStreamReader;
26 class UnderlyingSource;
27
28 class CORE_EXPORT ReadableStream : public GarbageCollectedFinalized<ReadableStre am> {
29 public:
30 enum State {
31 Readable,
32 Closed,
33 Errored,
34 };
35
36 // After ReadableStream construction, |didSourceStart| must be called when
37 // |source| initialization succeeds and |error| must be called when
38 // |source| initialization fails.
39 explicit ReadableStream(UnderlyingSource* /* source */);
40 virtual ~ReadableStream();
41
42 bool isStarted() const { return m_isStarted; }
43 bool isDraining() const { return m_isDraining; }
44 bool isPulling() const { return m_isPulling; }
45 State stateInternal() const { return m_state; }
46 DOMException* storedException() { return m_exception.get(); }
47
48 virtual ScriptPromise read(ScriptState*) = 0;
49 ScriptPromise cancel(ScriptState*);
50 ScriptPromise cancel(ScriptState*, ScriptValue reason);
51 ScriptPromise cancelInternal(ScriptState*, ScriptValue reason);
52
53 virtual bool hasPendingReads() const = 0;
54 virtual void resolveAllPendingReadsAsDone() = 0;
55 virtual void rejectAllPendingReads(DOMException*) = 0;
56
57 void close();
58 void error(DOMException*);
59
60 void didSourceStart();
61
62 // This function is not a getter. It creates an ReadableStreamReader and
63 // returns it.
64 ReadableStreamReader* getReader(ExecutionContext*, ExceptionState&);
65 // Only ReadableStreamReader methods should call this function.
66 void setReader(ReadableStreamReader*);
67
68 bool isLocked() const { return m_reader; }
69 bool isLockedTo(const ReadableStreamReader* reader) const { return m_reader == reader; }
70
71 bool isDisturbed() const { return m_isDisturbed; }
72 void setIsDisturbed() { m_isDisturbed = true; }
73
74 DECLARE_VIRTUAL_TRACE();
75
76 protected:
77 bool enqueuePreliminaryCheck();
78 bool enqueuePostAction();
79 void readInternalPostAction();
80
81 private:
82 using WaitPromise = ScriptPromiseProperty<Member<ReadableStream>, ToV8Undefi nedGenerator, Member<DOMException>>;
83 using ClosedPromise = ScriptPromiseProperty<Member<ReadableStream>, ToV8Unde finedGenerator, Member<DOMException>>;
84
85 virtual bool isQueueEmpty() const = 0;
86 virtual void clearQueue() = 0;
87 // This function will call ReadableStream::error on error.
88 virtual bool shouldApplyBackpressure() = 0;
89
90 void callPullIfNeeded();
91 void closeInternal();
92
93 Member<UnderlyingSource> m_source;
94 bool m_isStarted;
95 bool m_isDraining;
96 bool m_isPulling;
97 bool m_isDisturbed;
98 State m_state;
99
100 Member<DOMException> m_exception;
101 Member<ReadableStreamReader> m_reader;
102 };
103
104 } // namespace blink
105
106 #endif // ReadableStream_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698