Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: third_party/WebKit/Source/modules/fetch/FetchDataLoader.h

Issue 2292763002: [Fetch API] Implement Request.formData and Response.formData. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 FetchDataLoader_h 5 #ifndef FetchDataLoader_h
6 #define FetchDataLoader_h 6 #define FetchDataLoader_h
7 7
8 #include "core/dom/DOMArrayBuffer.h" 8 #include "core/dom/DOMArrayBuffer.h"
9 #include "core/streams/Stream.h" 9 #include "core/streams/Stream.h"
10 #include "modules/ModulesExport.h" 10 #include "modules/ModulesExport.h"
11 #include "platform/blob/BlobData.h" 11 #include "platform/blob/BlobData.h"
12 #include "platform/heap/Handle.h" 12 #include "platform/heap/Handle.h"
13 #include "wtf/Forward.h" 13 #include "wtf/Forward.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class BytesConsumer; 17 class BytesConsumer;
18 class FormData;
18 19
19 // FetchDataLoader subclasses 20 // FetchDataLoader subclasses
20 // 1. take a BytesConsumer, 21 // 1. take a BytesConsumer,
21 // 2. read all data, and 22 // 2. read all data, and
22 // 3. call either didFetchDataLoaded...() on success or 23 // 3. call either didFetchDataLoaded...() on success or
23 // difFetchDataLoadFailed() otherwise 24 // difFetchDataLoadFailed() otherwise
24 // on the thread where FetchDataLoader is created. 25 // on the thread where FetchDataLoader is created.
25 // 26 //
26 // - Client's methods can be called synchronously in start(). 27 // - Client's methods can be called synchronously in start().
27 // - If FetchDataLoader::cancel() is called, Client's methods will not be 28 // - If FetchDataLoader::cancel() is called, Client's methods will not be
28 // called anymore. 29 // called anymore.
29 class MODULES_EXPORT FetchDataLoader 30 class MODULES_EXPORT FetchDataLoader
30 : public GarbageCollectedFinalized<FetchDataLoader> { 31 : public GarbageCollectedFinalized<FetchDataLoader> {
31 public: 32 public:
32 class MODULES_EXPORT Client : public GarbageCollectedMixin { 33 class MODULES_EXPORT Client : public GarbageCollectedMixin {
33 public: 34 public:
34 virtual ~Client() {} 35 virtual ~Client() {}
35 36
36 // The method corresponding to createLoaderAs... is called on success. 37 // The method corresponding to createLoaderAs... is called on success.
37 virtual void didFetchDataLoadedBlobHandle(PassRefPtr<BlobDataHandle>) { 38 virtual void didFetchDataLoadedBlobHandle(PassRefPtr<BlobDataHandle>) {
38 ASSERT_NOT_REACHED(); 39 NOTREACHED();
39 } 40 }
40 virtual void didFetchDataLoadedArrayBuffer(DOMArrayBuffer*) { 41 virtual void didFetchDataLoadedArrayBuffer(DOMArrayBuffer*) {
41 ASSERT_NOT_REACHED(); 42 NOTREACHED();
42 } 43 }
43 virtual void didFetchDataLoadedString(const String&) { 44 virtual void didFetchDataLoadedFormData(FormData*) { NOTREACHED(); }
44 ASSERT_NOT_REACHED(); 45 virtual void didFetchDataLoadedString(const String&) { NOTREACHED(); }
45 }
46 // This is called after all data are read from |handle| and written 46 // This is called after all data are read from |handle| and written
47 // to |outStream|, and |outStream| is closed or aborted. 47 // to |outStream|, and |outStream| is closed or aborted.
48 virtual void didFetchDataLoadedStream() { ASSERT_NOT_REACHED(); } 48 virtual void didFetchDataLoadedStream() { NOTREACHED(); }
49 49
50 virtual void didFetchDataLoadFailed() = 0; 50 virtual void didFetchDataLoadFailed() = 0;
51 51
52 DEFINE_INLINE_VIRTUAL_TRACE() {} 52 DEFINE_INLINE_VIRTUAL_TRACE() {}
53 }; 53 };
54 54
55 static FetchDataLoader* createLoaderAsBlobHandle(const String& mimeType); 55 static FetchDataLoader* createLoaderAsBlobHandle(const String& mimeType);
56 static FetchDataLoader* createLoaderAsArrayBuffer(); 56 static FetchDataLoader* createLoaderAsArrayBuffer();
57 static FetchDataLoader* createLoaderAsFormData(
58 const String& multipartBoundary);
57 static FetchDataLoader* createLoaderAsString(); 59 static FetchDataLoader* createLoaderAsString();
58 static FetchDataLoader* createLoaderAsStream(Stream* outStream); 60 static FetchDataLoader* createLoaderAsStream(Stream* outStream);
59 61
60 virtual ~FetchDataLoader() {} 62 virtual ~FetchDataLoader() {}
61 63
62 // |consumer| must not have a client when called. 64 // |consumer| must not have a client when called.
63 virtual void start(BytesConsumer* /* consumer */, Client*) = 0; 65 virtual void start(BytesConsumer* /* consumer */, Client*) = 0;
64 66
65 virtual void cancel() = 0; 67 virtual void cancel() = 0;
66 68
67 DEFINE_INLINE_VIRTUAL_TRACE() {} 69 DEFINE_INLINE_VIRTUAL_TRACE() {}
68 }; 70 };
69 71
70 } // namespace blink 72 } // namespace blink
71 73
72 #endif // FetchDataLoader_h 74 #endif // FetchDataLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698