OLD | NEW |
---|---|
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/html/FormData.h" | |
horo
2016/08/30 05:12:56
you don't need to include here.
e_hakkinen
2016/08/30 07:59:08
Done.
| |
9 #include "core/streams/Stream.h" | 10 #include "core/streams/Stream.h" |
10 #include "modules/ModulesExport.h" | 11 #include "modules/ModulesExport.h" |
11 #include "modules/fetch/FetchDataConsumerHandle.h" | 12 #include "modules/fetch/FetchDataConsumerHandle.h" |
12 #include "platform/blob/BlobData.h" | 13 #include "platform/blob/BlobData.h" |
13 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
14 #include "wtf/Forward.h" | 15 #include "wtf/Forward.h" |
15 | 16 |
16 namespace blink { | 17 namespace blink { |
17 | 18 |
18 class BytesConsumer; | 19 class BytesConsumer; |
19 | 20 |
horo
2016/08/30 05:12:56
class FormData;
e_hakkinen
2016/08/30 07:59:08
Done.
| |
20 // FetchDataLoader subclasses | 21 // FetchDataLoader subclasses |
21 // 1. take a BytesConsumer, | 22 // 1. take a BytesConsumer, |
22 // 2. read all data, and | 23 // 2. read all data, and |
23 // 3. call either didFetchDataLoaded...() on success or | 24 // 3. call either didFetchDataLoaded...() on success or |
24 // difFetchDataLoadFailed() otherwise | 25 // difFetchDataLoadFailed() otherwise |
25 // on the thread where FetchDataLoader is created. | 26 // on the thread where FetchDataLoader is created. |
26 // | 27 // |
27 // - Client's methods can be called synchronously in start(). | 28 // - Client's methods can be called synchronously in start(). |
28 // - If FetchDataLoader::cancel() is called, Client's methods will not be | 29 // - If FetchDataLoader::cancel() is called, Client's methods will not be |
29 // called anymore. | 30 // called anymore. |
30 class MODULES_EXPORT FetchDataLoader : public GarbageCollectedFinalized<FetchDat aLoader> { | 31 class MODULES_EXPORT FetchDataLoader : public GarbageCollectedFinalized<FetchDat aLoader> { |
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 { | 39 { |
39 ASSERT_NOT_REACHED(); | 40 NOTREACHED(); |
40 } | 41 } |
41 virtual void didFetchDataLoadedArrayBuffer(DOMArrayBuffer*) | 42 virtual void didFetchDataLoadedArrayBuffer(DOMArrayBuffer*) |
42 { | 43 { |
43 ASSERT_NOT_REACHED(); | 44 NOTREACHED(); |
45 } | |
46 virtual void didFetchDataLoadedFormData(FormData*) | |
47 { | |
48 NOTREACHED(); | |
44 } | 49 } |
45 virtual void didFetchDataLoadedString(const String&) | 50 virtual void didFetchDataLoadedString(const String&) |
46 { | 51 { |
47 ASSERT_NOT_REACHED(); | 52 NOTREACHED(); |
48 } | 53 } |
49 // This is called after all data are read from |handle| and written | 54 // This is called after all data are read from |handle| and written |
50 // to |outStream|, and |outStream| is closed or aborted. | 55 // to |outStream|, and |outStream| is closed or aborted. |
51 virtual void didFetchDataLoadedStream() | 56 virtual void didFetchDataLoadedStream() |
52 { | 57 { |
53 ASSERT_NOT_REACHED(); | 58 NOTREACHED(); |
54 } | 59 } |
55 | 60 |
56 virtual void didFetchDataLoadFailed() = 0; | 61 virtual void didFetchDataLoadFailed() = 0; |
57 | 62 |
58 DEFINE_INLINE_VIRTUAL_TRACE() { } | 63 DEFINE_INLINE_VIRTUAL_TRACE() { } |
59 }; | 64 }; |
60 | 65 |
61 static FetchDataLoader* createLoaderAsBlobHandle(const String& mimeType); | 66 static FetchDataLoader* createLoaderAsBlobHandle(const String& mimeType); |
62 static FetchDataLoader* createLoaderAsArrayBuffer(); | 67 static FetchDataLoader* createLoaderAsArrayBuffer(); |
68 static FetchDataLoader* createLoaderAsFormData(const String& multipartBounda ry); | |
63 static FetchDataLoader* createLoaderAsString(); | 69 static FetchDataLoader* createLoaderAsString(); |
64 static FetchDataLoader* createLoaderAsStream(Stream* outStream); | 70 static FetchDataLoader* createLoaderAsStream(Stream* outStream); |
65 | 71 |
66 virtual ~FetchDataLoader() { } | 72 virtual ~FetchDataLoader() { } |
67 | 73 |
68 // |consumer| must not have a client when called. | 74 // |consumer| must not have a client when called. |
69 virtual void start(BytesConsumer* /* consumer */, Client*) = 0; | 75 virtual void start(BytesConsumer* /* consumer */, Client*) = 0; |
70 | 76 |
71 virtual void cancel() = 0; | 77 virtual void cancel() = 0; |
72 | 78 |
73 DEFINE_INLINE_VIRTUAL_TRACE() { } | 79 DEFINE_INLINE_VIRTUAL_TRACE() { } |
74 }; | 80 }; |
75 | 81 |
76 } // namespace blink | 82 } // namespace blink |
77 | 83 |
78 #endif // FetchDataLoader_h | 84 #endif // FetchDataLoader_h |
OLD | NEW |