Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef FetchFormDataConsumerHandle_h | |
| 6 #define FetchFormDataConsumerHandle_h | |
| 7 | |
| 8 #include "core/dom/DOMArrayBuffer.h" | |
| 9 #include "core/dom/DOMArrayBufferView.h" | |
| 10 #include "modules/ModulesExport.h" | |
| 11 #include "modules/fetch/FetchBlobDataConsumerHandle.h" | |
| 12 #include "modules/fetch/FetchDataConsumerHandle.h" | |
| 13 #include "platform/blob/BlobData.h" | |
| 14 #include "platform/network/FormData.h" | |
| 15 #include "wtf/Forward.h" | |
| 16 #include "wtf/PassOwnPtr.h" | |
| 17 #include "wtf/PassRefPtr.h" | |
| 18 #include "wtf/RefPtr.h" | |
| 19 #include "wtf/ThreadSafeRefCounted.h" | |
| 20 | |
| 21 namespace blink { | |
| 22 | |
| 23 class ExecutionContext; | |
| 24 | |
| 25 // FetchFormDataConsumerHandle is a handle made from a FormData. It provides | |
| 26 // drainAsFormData in the associated Reader. | |
| 27 class MODULES_EXPORT FetchFormDataConsumerHandle final : public FetchDataConsume rHandle { | |
| 28 WTF_MAKE_NONCOPYABLE(FetchFormDataConsumerHandle); | |
| 29 public: | |
| 30 static PassOwnPtr<FetchDataConsumerHandle> create(const String& body) { retu rn adoptPtr(new FetchFormDataConsumerHandle(body)); } | |
| 31 static PassOwnPtr<FetchDataConsumerHandle> create(PassRefPtr<DOMArrayBuffer> body) { return adoptPtr(new FetchFormDataConsumerHandle(body->data(), body->byt eLength())); } | |
| 32 static PassOwnPtr<FetchDataConsumerHandle> create(PassRefPtr<DOMArrayBufferV iew> body) { return adoptPtr(new FetchFormDataConsumerHandle(body->baseAddress() , body->byteLength())); } | |
| 33 static PassOwnPtr<FetchDataConsumerHandle> create(const void* data, size_t s ize) { return adoptPtr(new FetchFormDataConsumerHandle(data, size)); } | |
| 34 static PassOwnPtr<FetchDataConsumerHandle> create(ExecutionContext* executio nContext, PassRefPtr<FormData> body) { return adoptPtr(new FetchFormDataConsumer Handle(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.
| |
| 35 // Use FetchBlobDataConsumerHandle for blobs. | |
| 36 | |
| 37 ~FetchFormDataConsumerHandle() override; | |
| 38 | |
| 39 static PassOwnPtr<FetchDataConsumerHandle> createForTest(ExecutionContext* e xecutionContext, | |
|
hiroshige
2015/08/11 09:35:01
nit optional: how about wrapping this line before
yhirano
2015/08/11 11:36:01
Done.
| |
| 40 PassRefPtr<FormData> body, | |
| 41 FetchBlobDataConsumerHandle::LoaderFactory* loaderFactory) | |
| 42 { | |
| 43 return adoptPtr(new FetchFormDataConsumerHandle(executionContext, body, loaderFactory)); | |
| 44 } | |
| 45 | |
| 46 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.
| |
| 47 | |
| 48 private: | |
| 49 class Context; | |
| 50 class SimpleContext; | |
| 51 class ComplexContext; | |
| 52 class ReaderImpl; | |
| 53 | |
| 54 explicit FetchFormDataConsumerHandle(const String& body); | |
| 55 FetchFormDataConsumerHandle(const void*, size_t); | |
| 56 FetchFormDataConsumerHandle(ExecutionContext*, const PassRefPtr<FormData> bo dy, FetchBlobDataConsumerHandle::LoaderFactory* = nullptr); | |
| 57 | |
| 58 Reader* obtainReaderInternal(Client*) override; | |
| 59 | |
| 60 const char* debugName() const override { return "FetchFormDataConsumerHandle "; } | |
| 61 | |
| 62 RefPtr<Context> m_context; | |
| 63 }; | |
| 64 | |
| 65 } // namespace blink | |
| 66 | |
| 67 #endif // FetchFormDataConsumerHandle_h | |
| OLD | NEW |