| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 FormDataBytesConsumer_h | 5 #ifndef FormDataBytesConsumer_h |
| 6 #define FormDataBytesConsumer_h | 6 #define FormDataBytesConsumer_h |
| 7 | 7 |
| 8 #include "modules/ModulesExport.h" | 8 #include "modules/ModulesExport.h" |
| 9 #include "modules/fetch/BytesConsumer.h" | 9 #include "modules/fetch/BytesConsumer.h" |
| 10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| 11 #include "wtf/Forward.h" | 11 #include "wtf/Forward.h" |
| 12 #include "wtf/Functional.h" |
| 12 #include "wtf/PassRefPtr.h" | 13 #include "wtf/PassRefPtr.h" |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 class DOMArrayBuffer; | 17 class DOMArrayBuffer; |
| 17 class DOMArrayBufferView; | 18 class DOMArrayBufferView; |
| 18 class EncodedFormData; | 19 class EncodedFormData; |
| 19 | 20 |
| 20 class FormDataBytesConsumer final : public BytesConsumer { | 21 class FormDataBytesConsumer final : public BytesConsumer { |
| 21 public: | 22 public: |
| 23 using BytesConsumerFactory = |
| 24 Function<BytesConsumer*(ExecutionContext*, PassRefPtr<BlobDataHandle>)>; |
| 25 |
| 22 explicit MODULES_EXPORT FormDataBytesConsumer(const String&); | 26 explicit MODULES_EXPORT FormDataBytesConsumer(const String&); |
| 23 explicit MODULES_EXPORT FormDataBytesConsumer(DOMArrayBuffer*); | 27 explicit MODULES_EXPORT FormDataBytesConsumer(DOMArrayBuffer*); |
| 24 explicit MODULES_EXPORT FormDataBytesConsumer(DOMArrayBufferView*); | 28 explicit MODULES_EXPORT FormDataBytesConsumer(DOMArrayBufferView*); |
| 25 MODULES_EXPORT FormDataBytesConsumer(const void* data, size_t); | 29 MODULES_EXPORT FormDataBytesConsumer(const void* data, size_t); |
| 26 MODULES_EXPORT FormDataBytesConsumer(ExecutionContext*, | 30 MODULES_EXPORT FormDataBytesConsumer(ExecutionContext*, |
| 27 PassRefPtr<EncodedFormData>); | 31 PassRefPtr<EncodedFormData>); |
| 28 MODULES_EXPORT static FormDataBytesConsumer* createForTesting( | 32 MODULES_EXPORT static FormDataBytesConsumer* createForTesting( |
| 29 ExecutionContext* executionContext, | 33 ExecutionContext* executionContext, |
| 30 PassRefPtr<EncodedFormData> formData, | 34 PassRefPtr<EncodedFormData> formData, |
| 31 BytesConsumer* consumer) { | 35 std::unique_ptr<BytesConsumerFactory> factory) { |
| 32 return new FormDataBytesConsumer(executionContext, std::move(formData), | 36 return new FormDataBytesConsumer(executionContext, std::move(formData), |
| 33 consumer); | 37 std::move(factory)); |
| 34 } | 38 } |
| 35 | 39 |
| 36 // BytesConsumer implementation | 40 // BytesConsumer implementation |
| 37 Result beginRead(const char** buffer, size_t* available) override { | 41 Result beginRead(const char** buffer, size_t* available) override { |
| 38 return m_impl->beginRead(buffer, available); | 42 return m_impl->beginRead(buffer, available); |
| 39 } | 43 } |
| 40 Result endRead(size_t readSize) override { return m_impl->endRead(readSize); } | 44 Result endRead(size_t readSize) override { return m_impl->endRead(readSize); } |
| 41 PassRefPtr<BlobDataHandle> drainAsBlobDataHandle( | 45 PassRefPtr<BlobDataHandle> drainAsBlobDataHandle( |
| 42 BlobSizePolicy policy) override { | 46 BlobSizePolicy policy) override { |
| 43 return m_impl->drainAsBlobDataHandle(policy); | 47 return m_impl->drainAsBlobDataHandle(policy); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 57 String debugName() const override { return m_impl->debugName(); } | 61 String debugName() const override { return m_impl->debugName(); } |
| 58 | 62 |
| 59 DEFINE_INLINE_TRACE() { | 63 DEFINE_INLINE_TRACE() { |
| 60 visitor->trace(m_impl); | 64 visitor->trace(m_impl); |
| 61 BytesConsumer::trace(visitor); | 65 BytesConsumer::trace(visitor); |
| 62 } | 66 } |
| 63 | 67 |
| 64 private: | 68 private: |
| 65 MODULES_EXPORT FormDataBytesConsumer(ExecutionContext*, | 69 MODULES_EXPORT FormDataBytesConsumer(ExecutionContext*, |
| 66 PassRefPtr<EncodedFormData>, | 70 PassRefPtr<EncodedFormData>, |
| 67 BytesConsumer*); | 71 std::unique_ptr<BytesConsumerFactory>); |
| 68 | 72 |
| 69 const Member<BytesConsumer> m_impl; | 73 const Member<BytesConsumer> m_impl; |
| 70 }; | 74 }; |
| 71 | 75 |
| 72 } // namespace blink | 76 } // namespace blink |
| 73 | 77 |
| 74 #endif // FormDataBytesConsumer_h | 78 #endif // FormDataBytesConsumer_h |
| OLD | NEW |