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

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

Issue 837673002: Introduce ExclusiveStreamReader. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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 2015 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 ExclusiveStreamReader_h
6 #define ExclusiveStreamReader_h
7
8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseProperty.h"
10 #include "bindings/core/v8/ScriptValue.h"
11 #include "bindings/core/v8/ScriptWrappable.h"
12 #include "bindings/core/v8/ToV8.h"
13 #include "core/dom/ActiveDOMObject.h"
14 #include "core/streams/ReadableStream.h"
15 #include "platform/heap/Handle.h"
16
17 namespace blink {
18
19 class DOMException;
20 class ExceptionState;
21 class ScriptState;
22
23 // ExclusiveStreamReader corresponds the same-name class in the Streams spec
tyoshino (SeeGerritForStatus) 2015/02/02 04:24:11 corresponds to
yhirano 2015/02/02 06:05:37 Done.
24 // https://streams.spec.whatwg.org/. This class trusts ReadableStream, contrary
25 // to the class in the Streams spec, because we only support
26 // blink::Readable[Byte]Stream as this reader's customer.
27 class ExclusiveStreamReader final : public GarbageCollectedFinalized<ExclusiveSt reamReader>, public ScriptWrappable, public ActiveDOMObject {
28 DEFINE_WRAPPERTYPEINFO();
29 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ExclusiveStreamReader);
30 public:
31 // The stream must not be locked to any ExclusiveStreamReader when called.
32 ExclusiveStreamReader(ReadableStream*);
33
34 ScriptPromise closed(ScriptState*);
35 bool isActive() const;
36 ScriptPromise ready(ScriptState*);
37 String state() const;
38 ScriptPromise cancel(ScriptState*, ScriptValue reason);
39 ScriptValue read(ScriptState*, ExceptionState&);
40 void releaseLock();
41 ScriptPromise released(ScriptState*);
42
43 bool hasPendingActivity() const override;
44
45 void trace(Visitor*);
46
47 private:
48 using ReleasedPromise = ScriptPromiseProperty<Member<ExclusiveStreamReader>, ToV8UndefinedGenerator, ToV8UndefinedGenerator>;
49 using ClosedPromise = ScriptPromiseProperty<Member<ExclusiveStreamReader>, T oV8UndefinedGenerator, RefPtrWillBeMember<DOMException>>;
50 using ReadyPromise = ScriptPromiseProperty<Member<ExclusiveStreamReader>, To V8UndefinedGenerator, ToV8UndefinedGenerator>;
51
52 const Member<ReadableStream> m_stream;
53 const Member<ReleasedPromise> m_released;
54 ReadableStream::State m_stateAfterRelease;
55 Member<ClosedPromise> m_closedAfterRelease;
56 Member<ReadyPromise> m_readyAfterRelease;
57 };
58
59 } // namespace blink
60
61 #endif // ExclusiveStreamReader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698