| 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 FetchDataLoader_h |
| 6 #define FetchDataLoader_h |
| 7 |
| 8 #include "core/dom/DOMArrayBuffer.h" |
| 9 #include "modules/fetch/FetchDataConsumerHandle.h" |
| 10 #include "platform/blob/BlobData.h" |
| 11 #include "platform/heap/Handle.h" |
| 12 #include "wtf/Forward.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 // FetchDataLoader subclasses |
| 17 // 1. take a reader of FetchDataConsumerHandle |handle|, |
| 18 // 2. read all data, and |
| 19 // 3. call either didFetchDataLoaded...() on success or |
| 20 // difFetchDataLoadFailed() otherwise |
| 21 // on the thread where FetchDataLoader is created. |
| 22 // |
| 23 // - Client's methods can be called synchronously in start(). |
| 24 // - If FetchDataLoader::cancel() is called (or FetchDataLoader is garbage |
| 25 // collected), Client's methods are not called anymore. |
| 26 // - FetchDataLoader takes the ownership of |handle|'s reader but not |handle|. |
| 27 class FetchDataLoader : public GarbageCollectedFinalized<FetchDataLoader> { |
| 28 public: |
| 29 class Client : public GarbageCollectedMixin { |
| 30 public: |
| 31 virtual ~Client() { } |
| 32 |
| 33 // The method corresponding to createLoaderAs... is called on success. |
| 34 virtual void didFetchDataLoadedBlobHandle(PassRefPtr<BlobDataHandle>) |
| 35 { |
| 36 ASSERT_NOT_REACHED(); |
| 37 } |
| 38 virtual void didFetchDataLoadedArrayBuffer(PassRefPtr<DOMArrayBuffer>) |
| 39 { |
| 40 ASSERT_NOT_REACHED(); |
| 41 } |
| 42 virtual void didFetchDataLoadedString(const String&) |
| 43 { |
| 44 ASSERT_NOT_REACHED(); |
| 45 } |
| 46 |
| 47 virtual void didFetchDataLoadFailed() = 0; |
| 48 |
| 49 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 50 }; |
| 51 |
| 52 static FetchDataLoader* createLoaderAsBlobHandle(const String& mimeType); |
| 53 static FetchDataLoader* createLoaderAsArrayBuffer(); |
| 54 static FetchDataLoader* createLoaderAsString(); |
| 55 |
| 56 virtual ~FetchDataLoader() { } |
| 57 |
| 58 // start() should be called only once on the created thread. |
| 59 // start() do not take the ownership of |handle|. |
| 60 // |handle| must not be locked when called. |
| 61 virtual void start(FetchDataConsumerHandle* /* handle */, Client*) = 0; |
| 62 |
| 63 virtual void cancel() = 0; |
| 64 |
| 65 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 66 }; |
| 67 |
| 68 } // namespace blink |
| 69 |
| 70 #endif // FetchDataLoader_h |
| OLD | NEW |