OLD | NEW |
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/CoreExport.h" | 13 #include "core/CoreExport.h" |
14 #include "core/dom/ActiveDOMObject.h" | 14 #include "core/dom/ContextLifecycleObserver.h" |
15 #include "core/streams/ReadableStream.h" | 15 #include "core/streams/ReadableStream.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 DOMException; | 20 class DOMException; |
21 class ExceptionState; | 21 class ExceptionState; |
22 class ExecutionContext; | 22 class ExecutionContext; |
23 class ScriptState; | 23 class ScriptState; |
24 | 24 |
25 // ReadableStreamReader corresponds to the same-name class in the Streams spec | 25 // ReadableStreamReader corresponds to the same-name class in the Streams spec |
26 // https://streams.spec.whatwg.org/. | 26 // https://streams.spec.whatwg.org/. |
27 class CORE_EXPORT ReadableStreamReader final : public GarbageCollectedFinalized<
ReadableStreamReader>, public ScriptWrappable, public ActiveDOMObject { | 27 class CORE_EXPORT ReadableStreamReader final : public GarbageCollectedFinalized<
ReadableStreamReader>, public ScriptWrappable, public ContextLifecycleObserver { |
28 DEFINE_WRAPPERTYPEINFO(); | 28 DEFINE_WRAPPERTYPEINFO(); |
29 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ReadableStreamReader); | 29 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ReadableStreamReader); |
30 public: | 30 public: |
31 // The stream must not be locked to any ReadableStreamReader when called. | 31 // The stream must not be locked to any ReadableStreamReader when called. |
32 ReadableStreamReader(ExecutionContext*, ReadableStream*); | 32 ReadableStreamReader(ExecutionContext*, ReadableStream*); |
33 | 33 |
34 ScriptPromise closed(ScriptState*); | 34 ScriptPromise closed(ScriptState*); |
35 bool isActive() const; | 35 bool isActive() const; |
36 ScriptPromise cancel(ScriptState*); | 36 ScriptPromise cancel(ScriptState*); |
37 ScriptPromise cancel(ScriptState*, ScriptValue reason); | 37 ScriptPromise cancel(ScriptState*, ScriptValue reason); |
38 ScriptPromise read(ScriptState*); | 38 ScriptPromise read(ScriptState*); |
39 void releaseLock(ExceptionState&); | 39 void releaseLock(ExceptionState&); |
40 void releaseLock(); | 40 void releaseLock(); |
41 void close(); | 41 void close(); |
42 void error(); | 42 void error(); |
43 | 43 |
44 bool hasPendingActivity() const override; | 44 bool hasPendingActivity() const override; |
45 void stop() override; | 45 void contextDestroyed() override; |
46 | 46 |
47 DECLARE_TRACE(); | 47 DECLARE_TRACE(); |
48 | 48 |
49 private: | 49 private: |
50 using ClosedPromise = ScriptPromiseProperty<Member<ReadableStreamReader>, To
V8UndefinedGenerator, Member<DOMException>>; | 50 using ClosedPromise = ScriptPromiseProperty<Member<ReadableStreamReader>, To
V8UndefinedGenerator, Member<DOMException>>; |
51 | 51 |
52 const Member<ReadableStream> m_stream; | 52 const Member<ReadableStream> m_stream; |
53 Member<ClosedPromise> m_closed; | 53 Member<ClosedPromise> m_closed; |
54 }; | 54 }; |
55 | 55 |
56 } // namespace blink | 56 } // namespace blink |
57 | 57 |
58 #endif // ReadableStreamReader_h | 58 #endif // ReadableStreamReader_h |
OLD | NEW |