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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/modules/fetch/FetchDataLoader.cpp » ('j') | Source/modules/fetch/FetchDataLoader.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/fetch/FetchDataLoader.h
diff --git a/Source/modules/fetch/FetchDataLoader.h b/Source/modules/fetch/FetchDataLoader.h
new file mode 100644
index 0000000000000000000000000000000000000000..5136e124b420168ed0fe120670cdcbfcfce73c04
--- /dev/null
+++ b/Source/modules/fetch/FetchDataLoader.h
@@ -0,0 +1,65 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef FetchDataLoader_h
+#define FetchDataLoader_h
+
+#include "core/dom/DOMArrayBuffer.h"
+#include "modules/fetch/FetchDataConsumerHandle.h"
+#include "platform/blob/BlobData.h"
+#include "wtf/Forward.h"
+
+namespace blink {
+
+// FetchDataLoader subclasses
yhirano 2015/06/17 09:27:58 nit: "A FecthDataLoader subclass takes" or "FetchD
hiroshige 2015/06/17 18:27:29 Done.
+// 1. takes a reader of FetchDataConsumerHandle |handle|,
+// 2. reads all data, and
+// 3. calls either didFetchDataLoaded...() on success or
+// difFetchDataLoadFailed() otherwise.
+//
+// Client's methods can be called synchronously in start().
+// Client's methods can destruct FetchDataLoader.
+// If FetchDataLoader is destructed before Client's methods are called,
+// then the reader is also destructed and
+// Client's methods are not called anymore.
+// Ownership of |handle|, |handle|'s reader, and Client:
+// FetchDataLoader
+// - takes the ownership of |handle|'s reader.
+// - does not take the ownership of |handle|.
+// - does not take the ownership of Client.
+// The caller must guarantee Client is alive until
+// any of Client's method is called or FetchDataLoader is destructed.
+// Threading:
+// Client's methods are called and FetchDataLoader must be destructed
+// on the thread where FetchDataLoader is created.
+class FetchDataLoader {
+public:
+ class Client {
+ public:
+ virtual ~Client() { }
+
+ // The method corresponding to createLoaderAs... is called on success.
+ 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.
+ { }
+ virtual void didFetchDataLoadedArrayBuffer(PassRefPtr<DOMArrayBuffer>)
+ { }
+ virtual void didFetchDataLoadedString(const String&) { }
+
+ virtual void didFetchDataLoadFailed() = 0;
+ };
+
+ static PassOwnPtr<FetchDataLoader> createLoaderAsBlobHandle(const String& mimeType);
+ static PassOwnPtr<FetchDataLoader> createLoaderAsArrayBuffer();
+ static PassOwnPtr<FetchDataLoader> createLoaderAsString();
+
+ virtual ~FetchDataLoader() { }
+
+ // start() do not take the ownership of |handle|.
+ // |handle| must not be locked when called.
+ virtual void start(FetchDataConsumerHandle* /* handle */, Client*) = 0;
+};
+
+} // namespace blink
+
+#endif // FetchDataLoader_h
« 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