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