| 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/streams/Stream.h" | 9 #include "core/streams/Stream.h" |
| 10 #include "modules/ModulesExport.h" | 10 #include "modules/ModulesExport.h" |
| 11 #include "mojo/public/cpp/system/data_pipe.h" |
| 11 #include "platform/blob/BlobData.h" | 12 #include "platform/blob/BlobData.h" |
| 12 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
| 13 #include "wtf/Forward.h" | 14 #include "wtf/Forward.h" |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| 17 class BytesConsumer; | 18 class BytesConsumer; |
| 18 | 19 |
| 19 // FetchDataLoader subclasses | 20 // FetchDataLoader subclasses |
| 20 // 1. take a BytesConsumer, | 21 // 1. take a BytesConsumer, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 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 NOTREACHED(); | 39 NOTREACHED(); |
| 39 } | 40 } |
| 40 virtual void DidFetchDataLoadedArrayBuffer(DOMArrayBuffer*) { | 41 virtual void DidFetchDataLoadedArrayBuffer(DOMArrayBuffer*) { |
| 41 NOTREACHED(); | 42 NOTREACHED(); |
| 42 } | 43 } |
| 43 virtual void DidFetchDataLoadedString(const String&) { NOTREACHED(); } | 44 virtual void DidFetchDataLoadedString(const String&) { NOTREACHED(); } |
| 44 // This is called after all data are read from |handle| and written | 45 // This is called after all data are read from |handle| and written |
| 45 // to |outStream|, and |outStream| is closed or aborted. | 46 // to |out_datapipe|, and |out_datapipe| is closed or aborted. |
| 46 virtual void DidFetchDataLoadedStream() { NOTREACHED(); } | 47 virtual void DidFetchDataLoadedDataPipe() { NOTREACHED(); } |
| 47 | 48 |
| 48 // This function is called when a "custom" FetchDataLoader (none of the | 49 // This function is called when a "custom" FetchDataLoader (none of the |
| 49 // ones listed above) finishes loading. | 50 // ones listed above) finishes loading. |
| 50 virtual void DidFetchDataLoadedCustomFormat() { NOTREACHED(); } | 51 virtual void DidFetchDataLoadedCustomFormat() { NOTREACHED(); } |
| 51 | 52 |
| 52 virtual void DidFetchDataLoadFailed() = 0; | 53 virtual void DidFetchDataLoadFailed() = 0; |
| 53 | 54 |
| 54 DEFINE_INLINE_VIRTUAL_TRACE() {} | 55 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 static FetchDataLoader* CreateLoaderAsBlobHandle(const String& mime_type); | 58 static FetchDataLoader* CreateLoaderAsBlobHandle(const String& mime_type); |
| 58 static FetchDataLoader* CreateLoaderAsArrayBuffer(); | 59 static FetchDataLoader* CreateLoaderAsArrayBuffer(); |
| 59 static FetchDataLoader* CreateLoaderAsString(); | 60 static FetchDataLoader* CreateLoaderAsString(); |
| 60 static FetchDataLoader* CreateLoaderAsStream(Stream*); | 61 static FetchDataLoader* CreateLoaderAsDataPipe( |
| 62 mojo::ScopedDataPipeProducerHandle out_datapipe); |
| 63 |
| 61 virtual ~FetchDataLoader() {} | 64 virtual ~FetchDataLoader() {} |
| 62 | 65 |
| 63 // |consumer| must not have a client when called. | 66 // |consumer| must not have a client when called. |
| 64 virtual void Start(BytesConsumer* /* consumer */, Client*) = 0; | 67 virtual void Start(BytesConsumer* /* consumer */, Client*) = 0; |
| 65 | 68 |
| 66 virtual void Cancel() = 0; | 69 virtual void Cancel() = 0; |
| 67 | 70 |
| 68 DEFINE_INLINE_VIRTUAL_TRACE() {} | 71 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 69 }; | 72 }; |
| 70 | 73 |
| 71 } // namespace blink | 74 } // namespace blink |
| 72 | 75 |
| 73 #endif // FetchDataLoader_h | 76 #endif // FetchDataLoader_h |
| OLD | NEW |