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

Side by Side Diff: Source/core/streams/ReadableStreamReader.h

Issue 1004623007: Streams Implementation Update: async read (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@stream-reader-read
Patch Set: Created 5 years, 9 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
« no previous file with comments | « Source/core/streams/ReadableStreamImpl.h ('k') | Source/core/streams/ReadableStreamReader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 ReadableStreamReader_h 5 #ifndef ReadableStreamReader_h
6 #define ReadableStreamReader_h 6 #define ReadableStreamReader_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/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 "bindings/core/v8/ToV8.h" 12 #include "bindings/core/v8/ToV8.h"
13 #include "core/dom/ActiveDOMObject.h" 13 #include "core/dom/ActiveDOMObject.h"
14 #include "core/streams/ReadableStream.h" 14 #include "core/streams/ReadableStream.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 DOMException; 19 class DOMException;
20 class ExceptionState; 20 class ExceptionState;
21 class ScriptState; 21 class ScriptState;
22 22
23 // ReadableStreamReader corresponds to the same-name class in the Streams spec 23 // ReadableStreamReader corresponds to the same-name class in the Streams spec
24 // https://streams.spec.whatwg.org/. This class trusts ReadableStream, contrary 24 // https://streams.spec.whatwg.org/.
25 // to the class in the Streams spec, because we only support
26 // blink::Readable[Byte]Stream as this reader's customer.
27 class ReadableStreamReader final : public GarbageCollectedFinalized<ReadableStre amReader>, public ScriptWrappable, public ActiveDOMObject { 25 class ReadableStreamReader final : public GarbageCollectedFinalized<ReadableStre amReader>, public ScriptWrappable, public ActiveDOMObject {
28 DEFINE_WRAPPERTYPEINFO(); 26 DEFINE_WRAPPERTYPEINFO();
29 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ReadableStreamReader); 27 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ReadableStreamReader);
30 public: 28 public:
31 // The stream must not be locked to any ReadableStreamReader when called. 29 // The stream must not be locked to any ReadableStreamReader when called.
32 ReadableStreamReader(ReadableStream*); 30 ReadableStreamReader(ReadableStream*);
33 31
34 ScriptPromise closed(ScriptState*); 32 ScriptPromise closed(ScriptState*);
35 bool isActive() const; 33 bool isActive() const;
36 ScriptPromise ready(ScriptState*);
37 String state() const;
38 ScriptPromise cancel(ScriptState*, ScriptValue reason); 34 ScriptPromise cancel(ScriptState*, ScriptValue reason);
39 ScriptValue read(ScriptState*, ExceptionState&); 35 ScriptPromise read(ScriptState*);
36 void releaseLock(ExceptionState&);
40 void releaseLock(); 37 void releaseLock();
41 ScriptPromise released(ScriptState*);
42 38
43 bool hasPendingActivity() const override; 39 bool hasPendingActivity() const override;
44 void stop() override; 40 void stop() override;
45 41
46 DECLARE_TRACE(); 42 DECLARE_TRACE();
47 43
48 private: 44 private:
49 using ReleasedPromise = ScriptPromiseProperty<Member<ReadableStreamReader>, ToV8UndefinedGenerator, ToV8UndefinedGenerator>;
50 using ClosedPromise = ScriptPromiseProperty<Member<ReadableStreamReader>, To V8UndefinedGenerator, RefPtrWillBeMember<DOMException>>; 45 using ClosedPromise = ScriptPromiseProperty<Member<ReadableStreamReader>, To V8UndefinedGenerator, RefPtrWillBeMember<DOMException>>;
51 using ReadyPromise = ScriptPromiseProperty<Member<ReadableStreamReader>, ToV 8UndefinedGenerator, ToV8UndefinedGenerator>;
52 46
53 const Member<ReadableStream> m_stream; 47 const Member<ReadableStream> m_stream;
54 const Member<ReleasedPromise> m_released;
55 ReadableStream::State m_stateAfterRelease; 48 ReadableStream::State m_stateAfterRelease;
56 Member<ClosedPromise> m_closedAfterRelease; 49 Member<ClosedPromise> m_closed;
57 Member<ReadyPromise> m_readyAfterRelease;
58 }; 50 };
59 51
60 } // namespace blink 52 } // namespace blink
61 53
62 #endif // ReadableStreamReader_h 54 #endif // ReadableStreamReader_h
OLDNEW
« no previous file with comments | « Source/core/streams/ReadableStreamImpl.h ('k') | Source/core/streams/ReadableStreamReader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698