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 "wtf/ArrayBufferBuilder.h" | |
|
yhirano
2015/06/17 05:18:54
+wtf/Forward.h
yhirano
2015/06/17 05:18:54
Why do we need ArrayBufferBuilder.h?
hiroshige
2015/06/17 08:48:55
Moved to .cpp.
hiroshige
2015/06/17 08:48:55
Done.
| |
| 12 | |
| 13 namespace blink { | |
| 14 | |
| 15 // FetchDataLoader subclasses | |
| 16 // 1. takes a reader of FetchDataConsumerHandle |handle|, | |
| 17 // 2. reads all data, and | |
| 18 // 3. calls either didFetchDataLoaded...() on success or | |
| 19 // difFetchDataLoadFailed() otherwise. | |
| 20 // | |
| 21 // Client's methods can be called synchronously in start(). | |
| 22 // Client's methods can destruct FetchDataLoader. | |
| 23 // If FetchDataLoader is destructed before Client's methods are called, | |
| 24 // then the reader is also destructed and | |
| 25 // Client's methods are not called anymore. | |
| 26 // Ownership of |handle|, |handle|'s reader, and Client: | |
| 27 // FetchDataLoader | |
| 28 // - takes the ownership of |handle|'s reader. | |
| 29 // - does not take the ownership of |handle|. | |
| 30 // - does not take the ownership of Client. | |
| 31 // The caller must guarantee Client is alive until | |
| 32 // any of Client's method is called or FetchDataLoader is destructed. | |
| 33 // Threading: | |
| 34 // Client's methods are called and FetchDataLoader must be destructed | |
| 35 // on the thread where FetchDataLoader is created. | |
| 36 class FetchDataLoader { | |
|
yhirano
2015/06/17 05:18:53
It is possible to make this class GarbageCollected
hiroshige
2015/06/17 18:27:29
Done.
| |
| 37 public: | |
| 38 class Client { | |
| 39 public: | |
| 40 virtual ~Client() { } | |
| 41 | |
| 42 // The method corresponding to createLoaderAs... is called on success. | |
| 43 virtual void didFetchDataLoadedBlobHandle(PassRefPtr<BlobDataHandle>) | |
| 44 { } | |
| 45 virtual void didFetchDataLoadedArrayBuffer(PassRefPtr<DOMArrayBuffer>) | |
| 46 { } | |
| 47 virtual void didFetchDataLoadedString(const String&) { } | |
| 48 | |
| 49 virtual void didFetchDataLoadFailed() = 0; | |
| 50 }; | |
| 51 | |
| 52 static PassOwnPtr<FetchDataLoader> createLoaderAsBlobHandle(const String& mi meType); | |
| 53 static PassOwnPtr<FetchDataLoader> createLoaderAsArrayBuffer(); | |
| 54 static PassOwnPtr<FetchDataLoader> createLoaderAsString(); | |
| 55 | |
| 56 virtual ~FetchDataLoader() { } | |
| 57 | |
| 58 // start() do not take the ownership of |handle|. | |
|
yhirano
2015/06/17 05:18:54
+"|handle| must not be locked when called".
hiroshige
2015/06/17 08:48:55
Done.
| |
| 59 virtual void start(FetchDataConsumerHandle* /* handle */, Client*) = 0; | |
| 60 | |
| 61 protected: | |
| 62 FetchDataLoader(); | |
|
yhirano
2015/06/17 05:18:54
You can make this constructor public (or delete it
hiroshige
2015/06/17 08:48:55
Done.
| |
| 63 | |
| 64 OwnPtr<FetchDataConsumerHandle::Reader> m_reader; | |
|
yhirano
2015/06/17 05:18:54
Can you move these members to derived classes? The
hiroshige
2015/06/17 08:48:55
Done.
| |
| 65 Client* m_client; | |
| 66 }; | |
| 67 | |
| 68 } // namespace blink | |
| 69 | |
| 70 #endif // FetchDataLoader_h | |
| OLD | NEW |