Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: Source/modules/fetch/FetchDataLoader.h

Issue 1179393007: [2a] Implement FetchDataLoader (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Reflect comments (except for making GarbageCollected). Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/Forward.h"
12
13 namespace blink {
14
15 // FetchDataLoader subclasses
yhirano 2015/06/17 09:27:58 nit: "A FecthDataLoader subclass takes" or "FetchD
hiroshige 2015/06/17 18:27:29 Done.
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 {
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>)
yhirano 2015/06/17 09:27:58 [optional] Is it a good idea to put ASSERT_NOT_REA
hiroshige 2015/06/17 18:27:29 Done.
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|.
59 // |handle| must not be locked when called.
60 virtual void start(FetchDataConsumerHandle* /* handle */, Client*) = 0;
61 };
62
63 } // namespace blink
64
65 #endif // FetchDataLoader_h
OLDNEW
« no previous file with comments | « no previous file | Source/modules/fetch/FetchDataLoader.cpp » ('j') | Source/modules/fetch/FetchDataLoader.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698