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

Unified Diff: Source/modules/fetch/FetchDataConsumerHandle.h

Issue 1176243004: Add FetchDataConsumerHandle and utility functions/classes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Reflect comments. 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
Index: Source/modules/fetch/FetchDataConsumerHandle.h
diff --git a/Source/modules/fetch/FetchDataConsumerHandle.h b/Source/modules/fetch/FetchDataConsumerHandle.h
new file mode 100644
index 0000000000000000000000000000000000000000..0fa60c31a2ac2028a0b286ddfcaab1d8839953e8
--- /dev/null
+++ b/Source/modules/fetch/FetchDataConsumerHandle.h
@@ -0,0 +1,47 @@
+// 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 FetchDataConsumerHandle_h
+#define FetchDataConsumerHandle_h
+
+#include "public/platform/WebDataConsumerHandle.h"
+#include "wtf/Forward.h"
+#include "wtf/PassRefPtr.h"
+
+namespace blink {
+
+class BlobDataHandle;
+
+// This is an interface class that adds Reader's blobDataHandle() to
+// WebDataConsumerHandle.
+// This class works not very well with Oilpan: As this class is not garbage
+// collected while many clients or related objects may be, it is very easy
+// to create a reference cycle. When an client is garbage collected, making
+// the client own the handle is the right way.
+class FetchDataConsumerHandle : public WebDataConsumerHandle {
+public:
+ class Reader : public WebDataConsumerHandle::Reader {
+ public:
+ // Returns a blob handle representing the body data. This function can
+ // returns null when the object doesn't have such a handle. Calling
+ // this function drains the body data.
+ // This function is defined for performance. If this function returns a
+ // non-null handle, the bytes that will be read from the handle must be
+ // idential to the bytes that will be read
+ // through WebDataConsumerHandle APIs without calling this function.
+ virtual PassRefPtr<BlobDataHandle> blobDataHandle() = 0;
+ };
+
+ // TODO(yhirano): obtainReader() is currently non-virtual override, and
+ // will be changed into virtual override when we can use scoped_ptr /
+ // unique_ptr in both Blink and Chromium.
+ PassOwnPtr<Reader> obtainReader(Client* client) { return adoptPtr(obtainReaderInternal(client)); }
+
+private:
+ Reader* obtainReaderInternal(Client*) override = 0;
+};
+
+} // namespace blink
+
+#endif // FetchDataConsumerHandle_h

Powered by Google App Engine
This is Rietveld 408576698