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

Unified Diff: third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp

Issue 2311063003: [Fetch API] Call endRead sooner to avoid recursive invocation (Closed)
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
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/stream-reader.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
index 1dd4bd18b16169f0fd4bb7a5f269e0b06a5ff209..11b50f742a10d067ed13b596b2655d051a6fef77 100644
--- a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
+++ b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
@@ -232,8 +232,9 @@ void BodyStreamBuffer::tee(BodyStreamBuffer** branch1, BodyStreamBuffer** branch
ScriptPromise BodyStreamBuffer::pull(ScriptState* scriptState)
{
- ASSERT(!m_streamNeedsMore);
ASSERT(scriptState == m_scriptState.get());
+ if (m_streamNeedsMore)
+ return ScriptPromise::castUndefined(scriptState);
m_streamNeedsMore = true;
processData();
return ScriptPromise::castUndefined(scriptState);
@@ -355,9 +356,15 @@ void BodyStreamBuffer::processData()
switch (result) {
case WebDataConsumerHandle::Ok: {
DOMUint8Array* array = DOMUint8Array::create(static_cast<const unsigned char*>(buffer), available);
- controller()->enqueue(array);
- m_streamNeedsMore = controller()->desiredSize() > 0;
m_reader->endRead(available);
+ // Clear m_streamNeedsMore in order to detect a pull call.
+ m_streamNeedsMore = false;
+ controller()->enqueue(array);
+ // If m_streamNeedsMore is true, it means that pull is called and
+ // the stream needs more data even if the desired size is not
+ // positive.
+ if (!m_streamNeedsMore)
+ m_streamNeedsMore = controller()->desiredSize() > 0;
break;
}
case WebDataConsumerHandle::Done:
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/stream-reader.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698