| 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" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class ScriptState; | 26 class ScriptState; |
| 27 | 27 |
| 28 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 { |
| 29 WTF_MAKE_NONCOPYABLE(BodyStreamBuffer); | 29 WTF_MAKE_NONCOPYABLE(BodyStreamBuffer); |
| 30 USING_GARBAGE_COLLECTED_MIXIN(BodyStreamBuffer); | 30 USING_GARBAGE_COLLECTED_MIXIN(BodyStreamBuffer); |
| 31 public: | 31 public: |
| 32 // Needed because we have to release |m_reader| promptly. | 32 // Needed because we have to release |m_reader| promptly. |
| 33 EAGERLY_FINALIZE(); | 33 EAGERLY_FINALIZE(); |
| 34 // |handle| cannot be null and cannot be locked. | 34 // |handle| cannot be null and cannot be locked. |
| 35 BodyStreamBuffer(ScriptState*, PassOwnPtr<FetchDataConsumerHandle> /* handle
*/); | 35 BodyStreamBuffer(ScriptState*, PassOwnPtr<FetchDataConsumerHandle> /* handle
*/); |
| 36 // |ReadableStreamOperations::isReadableStream(stream)| must hold. |
| 37 BodyStreamBuffer(ScriptState*, ScriptValue stream); |
| 36 | 38 |
| 37 ScriptValue stream(); | 39 ScriptValue stream(); |
| 38 | 40 |
| 39 // Callable only when neither locked nor disturbed. | 41 // Callable only when neither locked nor disturbed. |
| 40 PassRefPtr<BlobDataHandle> drainAsBlobDataHandle(FetchDataConsumerHandle::Re
ader::BlobSizePolicy); | 42 PassRefPtr<BlobDataHandle> drainAsBlobDataHandle(FetchDataConsumerHandle::Re
ader::BlobSizePolicy); |
| 41 PassRefPtr<EncodedFormData> drainAsFormData(); | 43 PassRefPtr<EncodedFormData> drainAsFormData(); |
| 42 void startLoading(FetchDataLoader*, FetchDataLoader::Client* /* client */); | 44 void startLoading(FetchDataLoader*, FetchDataLoader::Client* /* client */); |
| 43 | 45 void tee(BodyStreamBuffer**, BodyStreamBuffer**); |
| 44 // Callable only when not locked. Returns a non-null handle. | |
| 45 // There is no means to "return" the handle to the body buffer: Calling | |
| 46 // this function locks, disturbs and closes the stream and no one will | |
| 47 // not be able to get any information from the stream and this buffer after | |
| 48 // that. | |
| 49 PassOwnPtr<FetchDataConsumerHandle> releaseHandle(); | |
| 50 | 46 |
| 51 // UnderlyingSource | 47 // UnderlyingSource |
| 52 void pullSource() override; | 48 void pullSource() override; |
| 53 ScriptPromise cancelSource(ScriptState*, ScriptValue reason) override; | 49 ScriptPromise cancelSource(ScriptState*, ScriptValue reason) override; |
| 54 | 50 |
| 55 // UnderlyingSourceBase | 51 // UnderlyingSourceBase |
| 56 ScriptPromise pull(ScriptState*) override; | 52 ScriptPromise pull(ScriptState*) override; |
| 57 ScriptPromise cancel(ScriptState*, ScriptValue reason) override; | 53 ScriptPromise cancel(ScriptState*, ScriptValue reason) override; |
| 58 bool hasPendingActivity() const override; | 54 bool hasPendingActivity() const override; |
| 59 void stop() override; | 55 void stop() override; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 77 } | 73 } |
| 78 | 74 |
| 79 private: | 75 private: |
| 80 class LoaderClient; | 76 class LoaderClient; |
| 81 | 77 |
| 82 void close(); | 78 void close(); |
| 83 void error(); | 79 void error(); |
| 84 void processData(); | 80 void processData(); |
| 85 void endLoading(); | 81 void endLoading(); |
| 86 void stopLoading(); | 82 void stopLoading(); |
| 83 PassOwnPtr<FetchDataConsumerHandle> releaseHandle(); |
| 87 | 84 |
| 88 RefPtr<ScriptState> m_scriptState; | 85 RefPtr<ScriptState> m_scriptState; |
| 89 OwnPtr<FetchDataConsumerHandle> m_handle; | 86 OwnPtr<FetchDataConsumerHandle> m_handle; |
| 90 OwnPtr<FetchDataConsumerHandle::Reader> m_reader; | 87 OwnPtr<FetchDataConsumerHandle::Reader> m_reader; |
| 91 Member<ReadableByteStream> m_stream; | 88 Member<ReadableByteStream> m_stream; |
| 92 // We need this member to keep it alive while loading. | 89 // We need this member to keep it alive while loading. |
| 93 Member<FetchDataLoader> m_loader; | 90 Member<FetchDataLoader> m_loader; |
| 94 bool m_streamNeedsMore = false; | 91 bool m_streamNeedsMore = false; |
| 92 bool m_madeFromReadableStream; |
| 95 }; | 93 }; |
| 96 | 94 |
| 97 } // namespace blink | 95 } // namespace blink |
| 98 | 96 |
| 99 #endif // BodyStreamBuffer_h | 97 #endif // BodyStreamBuffer_h |
| OLD | NEW |