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 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() do not take the ownership of |handle|. | |
| 59 // |handle| must not be locked when called. | |
| 60 virtual void start(FetchDataConsumerHandle* /* handle */, Client*) = 0; | |
|
yhirano
2015/06/18 11:05:06
Just curious, is there any reason to prevent this
| |
| 61 | |
| 62 virtual void cancel() = 0; | |
| 63 | |
| 64 DEFINE_INLINE_VIRTUAL_TRACE() { } | |
| 65 }; | |
| 66 | |
| 67 } // namespace blink | |
| 68 | |
| 69 #endif // FetchDataLoader_h | |
| OLD | NEW |