OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 BodyStreamBuffer_h | 5 #ifndef BodyStreamBuffer_h |
6 #define BodyStreamBuffer_h | 6 #define BodyStreamBuffer_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
11 #include "core/streams/ReadableByteStream.h" | 11 #include "core/streams/ReadableByteStream.h" |
12 #include "core/streams/ReadableByteStreamReader.h" | 12 #include "core/streams/ReadableByteStreamReader.h" |
13 #include "core/streams/UnderlyingSource.h" | 13 #include "core/streams/UnderlyingSource.h" |
14 #include "core/streams/UnderlyingSourceBase.h" | 14 #include "core/streams/UnderlyingSourceBase.h" |
15 #include "modules/ModulesExport.h" | 15 #include "modules/ModulesExport.h" |
16 #include "modules/fetch/FetchDataConsumerHandle.h" | 16 #include "modules/fetch/FetchDataConsumerHandle.h" |
17 #include "modules/fetch/FetchDataLoader.h" | 17 #include "modules/fetch/FetchDataLoader.h" |
18 #include "platform/heap/Handle.h" | 18 #include "platform/heap/Handle.h" |
19 #include "public/platform/WebDataConsumerHandle.h" | 19 #include "public/platform/WebDataConsumerHandle.h" |
20 #include <memory> | 20 #include "wtf/OwnPtr.h" |
| 21 #include "wtf/PassOwnPtr.h" |
21 | 22 |
22 namespace blink { | 23 namespace blink { |
23 | 24 |
24 class EncodedFormData; | 25 class EncodedFormData; |
25 class ScriptState; | 26 class ScriptState; |
26 | 27 |
27 class MODULES_EXPORT BodyStreamBuffer final : public UnderlyingSourceBase, publi
c UnderlyingSource, public WebDataConsumerHandle::Client { | 28 class MODULES_EXPORT BodyStreamBuffer final : public UnderlyingSourceBase, publi
c UnderlyingSource, public WebDataConsumerHandle::Client { |
28 WTF_MAKE_NONCOPYABLE(BodyStreamBuffer); | 29 WTF_MAKE_NONCOPYABLE(BodyStreamBuffer); |
29 USING_GARBAGE_COLLECTED_MIXIN(BodyStreamBuffer); | 30 USING_GARBAGE_COLLECTED_MIXIN(BodyStreamBuffer); |
30 public: | 31 public: |
31 // Needed because we have to release |m_reader| promptly. | 32 // Needed because we have to release |m_reader| promptly. |
32 EAGERLY_FINALIZE(); | 33 EAGERLY_FINALIZE(); |
33 // |handle| cannot be null and cannot be locked. | 34 // |handle| cannot be null and cannot be locked. |
34 BodyStreamBuffer(ScriptState*, std::unique_ptr<FetchDataConsumerHandle> /* h
andle */); | 35 BodyStreamBuffer(ScriptState*, PassOwnPtr<FetchDataConsumerHandle> /* handle
*/); |
35 // |ReadableStreamOperations::isReadableStream(stream)| must hold. | 36 // |ReadableStreamOperations::isReadableStream(stream)| must hold. |
36 BodyStreamBuffer(ScriptState*, ScriptValue stream); | 37 BodyStreamBuffer(ScriptState*, ScriptValue stream); |
37 | 38 |
38 ScriptValue stream(); | 39 ScriptValue stream(); |
39 | 40 |
40 // Callable only when neither locked nor disturbed. | 41 // Callable only when neither locked nor disturbed. |
41 PassRefPtr<BlobDataHandle> drainAsBlobDataHandle(FetchDataConsumerHandle::Re
ader::BlobSizePolicy); | 42 PassRefPtr<BlobDataHandle> drainAsBlobDataHandle(FetchDataConsumerHandle::Re
ader::BlobSizePolicy); |
42 PassRefPtr<EncodedFormData> drainAsFormData(); | 43 PassRefPtr<EncodedFormData> drainAsFormData(); |
43 void startLoading(FetchDataLoader*, FetchDataLoader::Client* /* client */); | 44 void startLoading(FetchDataLoader*, FetchDataLoader::Client* /* client */); |
44 void tee(BodyStreamBuffer**, BodyStreamBuffer**); | 45 void tee(BodyStreamBuffer**, BodyStreamBuffer**); |
(...skipping 28 matching lines...) Expand all Loading... |
73 } | 74 } |
74 | 75 |
75 private: | 76 private: |
76 class LoaderClient; | 77 class LoaderClient; |
77 | 78 |
78 void close(); | 79 void close(); |
79 void error(); | 80 void error(); |
80 void processData(); | 81 void processData(); |
81 void endLoading(); | 82 void endLoading(); |
82 void stopLoading(); | 83 void stopLoading(); |
83 std::unique_ptr<FetchDataConsumerHandle> releaseHandle(); | 84 PassOwnPtr<FetchDataConsumerHandle> releaseHandle(); |
84 | 85 |
85 RefPtr<ScriptState> m_scriptState; | 86 RefPtr<ScriptState> m_scriptState; |
86 std::unique_ptr<FetchDataConsumerHandle> m_handle; | 87 OwnPtr<FetchDataConsumerHandle> m_handle; |
87 std::unique_ptr<FetchDataConsumerHandle::Reader> m_reader; | 88 OwnPtr<FetchDataConsumerHandle::Reader> m_reader; |
88 Member<ReadableByteStream> m_stream; | 89 Member<ReadableByteStream> m_stream; |
89 // We need this member to keep it alive while loading. | 90 // We need this member to keep it alive while loading. |
90 Member<FetchDataLoader> m_loader; | 91 Member<FetchDataLoader> m_loader; |
91 bool m_streamNeedsMore = false; | 92 bool m_streamNeedsMore = false; |
92 bool m_madeFromReadableStream; | 93 bool m_madeFromReadableStream; |
93 }; | 94 }; |
94 | 95 |
95 } // namespace blink | 96 } // namespace blink |
96 | 97 |
97 #endif // BodyStreamBuffer_h | 98 #endif // BodyStreamBuffer_h |
OLD | NEW |