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

Unified Diff: Source/modules/fetch/DataConsumerTee.cpp

Issue 1192913007: Change BodyStreamBuffer to be FetchDataConsumerHandle-based and enable backpressure in Fetch API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: (temp) alternative to calling didGetReadable in sync. 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/DataConsumerTee.cpp
diff --git a/Source/modules/fetch/DataConsumerTee.cpp b/Source/modules/fetch/DataConsumerTee.cpp
index 72b6750742dc59cf7b1b334dee2d05a577171f86..dfa4d4343fdf9a4e592f600f83c77f86e7a6d5e0 100644
--- a/Source/modules/fetch/DataConsumerTee.cpp
+++ b/Source/modules/fetch/DataConsumerTee.cpp
@@ -7,6 +7,8 @@
#include "core/dom/ActiveDOMObject.h"
#include "core/dom/ExecutionContext.h"
+#include "modules/fetch/DataConsumerHandleUtil.h"
+#include "modules/fetch/FetchBlobDataConsumerHandle.h"
#include "platform/Task.h"
#include "platform/ThreadSafeFunctional.h"
#include "platform/heap/Handle.h"
@@ -422,4 +424,20 @@ void DataConsumerTee::create(ExecutionContext* executionContext, PassOwnPtr<WebD
*dest2 = adoptPtr(new DestinationHandle(DestinationContext::Proxy::create(context2, tracker)));
}
+void DataConsumerTee::create(ExecutionContext* executionContext, PassOwnPtr<FetchDataConsumerHandle> src, OwnPtr<FetchDataConsumerHandle>* dest1, OwnPtr<FetchDataConsumerHandle>* dest2)
+{
+ RefPtr<BlobDataHandle> blobDataHandle = src->obtainReader(nullptr)->drainAsBlobDataHandle(FetchDataConsumerHandle::Reader::AllowBlobWithInvalidSize);
+ if (blobDataHandle) {
+ *dest1 = FetchBlobDataConsumerHandle::create(executionContext, blobDataHandle);
+ *dest2 = FetchBlobDataConsumerHandle::create(executionContext, blobDataHandle);
+ return;
+ }
+
+ OwnPtr<WebDataConsumerHandle> webDest1, webDest2;
+ DataConsumerTee::create(executionContext, static_cast<PassOwnPtr<WebDataConsumerHandle>>(src), &webDest1, &webDest2);
+ *dest1 = createFetchDataConsumerHandleFromWebHandle(webDest1.release());
+ *dest2 = createFetchDataConsumerHandleFromWebHandle(webDest2.release());
+ return;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698