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

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: 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') | no next file with comments »
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..3acd0a1c8f608758049601449a674d200129650d
--- /dev/null
+++ b/Source/modules/fetch/FetchDataLoader.h
@@ -0,0 +1,70 @@
+// 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 "platform/heap/Handle.h"
+#include "wtf/Forward.h"
+
+namespace blink {
+
+// FetchDataLoader subclasses
+// 1. take a reader of FetchDataConsumerHandle |handle|,
+// 2. read all data, and
+// 3. call either didFetchDataLoaded...() on success or
+// difFetchDataLoadFailed() otherwise
+// on the thread where FetchDataLoader is created.
+//
+// - Client's methods can be called synchronously in start().
+// - If FetchDataLoader::cancel() is called (or FetchDataLoader is garbage
+// collected), Client's methods are not called anymore.
+// - FetchDataLoader takes the ownership of |handle|'s reader but not |handle|.
+class FetchDataLoader : public GarbageCollectedFinalized<FetchDataLoader> {
+public:
+ class Client : public GarbageCollectedMixin {
+ public:
+ virtual ~Client() { }
+
+ // The method corresponding to createLoaderAs... is called on success.
+ virtual void didFetchDataLoadedBlobHandle(PassRefPtr<BlobDataHandle>)
+ {
+ ASSERT_NOT_REACHED();
+ }
+ virtual void didFetchDataLoadedArrayBuffer(PassRefPtr<DOMArrayBuffer>)
+ {
+ ASSERT_NOT_REACHED();
+ }
+ virtual void didFetchDataLoadedString(const String&)
+ {
+ ASSERT_NOT_REACHED();
+ }
+
+ virtual void didFetchDataLoadFailed() = 0;
+
+ DEFINE_INLINE_VIRTUAL_TRACE() { }
+ };
+
+ static FetchDataLoader* createLoaderAsBlobHandle(const String& mimeType);
+ static FetchDataLoader* createLoaderAsArrayBuffer();
+ static FetchDataLoader* createLoaderAsString();
+
+ virtual ~FetchDataLoader() { }
+
+ // start() should be called only once on the created thread.
+ // start() do not take the ownership of |handle|.
+ // |handle| must not be locked when called.
+ virtual void start(FetchDataConsumerHandle* /* handle */, Client*) = 0;
+
+ virtual void cancel() = 0;
+
+ DEFINE_INLINE_VIRTUAL_TRACE() { }
+};
+
+} // namespace blink
+
+#endif // FetchDataLoader_h
« no previous file with comments | « no previous file | Source/modules/fetch/FetchDataLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698