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

Unified Diff: third_party/WebKit/Source/modules/fetch/BytesConsumer.h

Issue 2269953004: Implment BytesConsumer::tee (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 3 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: third_party/WebKit/Source/modules/fetch/BytesConsumer.h
diff --git a/third_party/WebKit/Source/modules/fetch/BytesConsumer.h b/third_party/WebKit/Source/modules/fetch/BytesConsumer.h
index 894cfb71a87de559dfdebbea6fe029f5757c64e2..c2be7729cb3272dd2376a68999936b814e281a05 100644
--- a/third_party/WebKit/Source/modules/fetch/BytesConsumer.h
+++ b/third_party/WebKit/Source/modules/fetch/BytesConsumer.h
@@ -14,6 +14,8 @@
namespace blink {
+class ExecutionContext;
+
// BytesConsumer represents the "consumer" side of a data pipe. A user
// can read data from it.
//
@@ -91,6 +93,9 @@ public:
// When not readable, the caller don't have to (and must not) call
// endRead, because the read session implicitly ends in that case.
//
+ // |*buffer| will become invalid when this object becomes unreachable,
+ // even if endRead is not called.
+ //
// |*buffer| will be set to null and |*available| will be set to 0 if not
// readable.
virtual Result beginRead(const char** buffer, size_t* available) = 0;
@@ -119,13 +124,17 @@ public:
// from an EncodedFormData-convertible value.
virtual PassRefPtr<EncodedFormData> drainAsFormData() { return nullptr; }
- // Sets a client.
+ // Sets a client. This can be called only when no client is set. When
+ // this object is already closed or errored, this function does nothing.
virtual void setClient(Client*) = 0;
- // Clears the set client. This can be called only when a client is set.
+ // Clears the set client.
+ // A client will be implicitly cleared when this object gets closed or
+ // errored (after the state change itself is notified).
virtual void clearClient() = 0;
// Cancels this ByteConsumer. This function does nothing when |this| is
// already closed or errored. Otherwise, this object becomes closed.
+ // This function cannot be called in a two-phase read.
virtual void cancel() = 0;
// Returns the current state.
@@ -139,6 +148,11 @@ public:
// implementation for debug purpose.
virtual String debugName() const = 0;
+ // Creates two BytesConsumer both of which represent the data sequence that
+ // would be read from |src| and store them to |*dest1| and |*dest2|.
+ // |src| must not have a client when called.
+ static void tee(ExecutionContext*, BytesConsumer* src, BytesConsumer** dest1, BytesConsumer** dest2);
+
DEFINE_INLINE_VIRTUAL_TRACE() {}
protected:

Powered by Google App Engine
This is Rietveld 408576698