Chromium Code Reviews| Index: Source/modules/fetch/FetchFormDataConsumerHandle.h |
| diff --git a/Source/modules/fetch/FetchFormDataConsumerHandle.h b/Source/modules/fetch/FetchFormDataConsumerHandle.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9169f4b5ac9a8b6d466bc570c24d9174250d2533 |
| --- /dev/null |
| +++ b/Source/modules/fetch/FetchFormDataConsumerHandle.h |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef FetchFormDataConsumerHandle_h |
| +#define FetchFormDataConsumerHandle_h |
| + |
| +#include "core/dom/DOMArrayBuffer.h" |
| +#include "core/dom/DOMArrayBufferView.h" |
| +#include "modules/ModulesExport.h" |
| +#include "modules/fetch/FetchBlobDataConsumerHandle.h" |
| +#include "modules/fetch/FetchDataConsumerHandle.h" |
| +#include "platform/blob/BlobData.h" |
| +#include "platform/network/FormData.h" |
| +#include "wtf/Forward.h" |
| +#include "wtf/PassOwnPtr.h" |
| +#include "wtf/PassRefPtr.h" |
| +#include "wtf/RefPtr.h" |
| +#include "wtf/ThreadSafeRefCounted.h" |
| + |
| +namespace blink { |
| + |
| +class ExecutionContext; |
| + |
| +// FetchFormDataConsumerHandle is a handle made from a FormData. It provides |
| +// drainAsFormData in the associated Reader. |
| +class MODULES_EXPORT FetchFormDataConsumerHandle final : public FetchDataConsumerHandle { |
| + WTF_MAKE_NONCOPYABLE(FetchFormDataConsumerHandle); |
| +public: |
| + static PassOwnPtr<FetchDataConsumerHandle> create(const String& body) { return adoptPtr(new FetchFormDataConsumerHandle(body)); } |
| + static PassOwnPtr<FetchDataConsumerHandle> create(PassRefPtr<DOMArrayBuffer> body) { return adoptPtr(new FetchFormDataConsumerHandle(body->data(), body->byteLength())); } |
| + static PassOwnPtr<FetchDataConsumerHandle> create(PassRefPtr<DOMArrayBufferView> body) { return adoptPtr(new FetchFormDataConsumerHandle(body->baseAddress(), body->byteLength())); } |
| + static PassOwnPtr<FetchDataConsumerHandle> create(const void* data, size_t size) { return adoptPtr(new FetchFormDataConsumerHandle(data, size)); } |
| + static PassOwnPtr<FetchDataConsumerHandle> create(ExecutionContext* executionContext, PassRefPtr<FormData> body) { return adoptPtr(new FetchFormDataConsumerHandle(executionContext, body)); } |
|
hiroshige
2015/08/11 09:35:01
optional: moving the bodies of the functions above
yhirano
2015/08/11 11:36:01
Done.
|
| + // Use FetchBlobDataConsumerHandle for blobs. |
| + |
| + ~FetchFormDataConsumerHandle() override; |
| + |
| + static PassOwnPtr<FetchDataConsumerHandle> createForTest(ExecutionContext* executionContext, |
|
hiroshige
2015/08/11 09:35:01
nit optional: how about wrapping this line before
yhirano
2015/08/11 11:36:01
Done.
|
| + PassRefPtr<FormData> body, |
| + FetchBlobDataConsumerHandle::LoaderFactory* loaderFactory) |
| + { |
| + return adoptPtr(new FetchFormDataConsumerHandle(executionContext, body, loaderFactory)); |
| + } |
| + |
| + static bool isSimple(const FormData*); |
|
hiroshige
2015/08/11 09:35:01
Can we move this to .cpp file? (I think we don't h
yhirano
2015/08/11 11:36:01
Done.
|
| + |
| +private: |
| + class Context; |
| + class SimpleContext; |
| + class ComplexContext; |
| + class ReaderImpl; |
| + |
| + explicit FetchFormDataConsumerHandle(const String& body); |
| + FetchFormDataConsumerHandle(const void*, size_t); |
| + FetchFormDataConsumerHandle(ExecutionContext*, const PassRefPtr<FormData> body, FetchBlobDataConsumerHandle::LoaderFactory* = nullptr); |
| + |
| + Reader* obtainReaderInternal(Client*) override; |
| + |
| + const char* debugName() const override { return "FetchFormDataConsumerHandle"; } |
| + |
| + RefPtr<Context> m_context; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // FetchFormDataConsumerHandle_h |