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

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

Issue 2351643004: BytesConsumer::endRead can return Done (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 | « no previous file | third_party/WebKit/Source/modules/fetch/BytesConsumer.h » ('j') | 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 a02c20617351eedde1d179d073390be56084294b..b5cd7932f165a2aaa3f243f16752b301306d378d 100644
--- a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
+++ b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
@@ -311,14 +311,17 @@ void BodyStreamBuffer::processData()
while (m_streamNeedsMore) {
const char* buffer = nullptr;
size_t available = 0;
-
- switch (m_consumer->beginRead(&buffer, &available)) {
+ auto result = m_consumer->beginRead(&buffer, &available);
+ if (result == BytesConsumer::Result::ShouldWait)
+ return;
+ DOMUint8Array* array = nullptr;
+ if (result == BytesConsumer::Result::Ok) {
+ array = DOMUint8Array::create(reinterpret_cast<const unsigned char*>(buffer), available);
+ result = m_consumer->endRead(available);
+ }
+ switch (result) {
case BytesConsumer::Result::Ok: {
- DOMUint8Array* array = DOMUint8Array::create(reinterpret_cast<const unsigned char*>(buffer), available);
- if (m_consumer->endRead(available) != BytesConsumer::Result::Ok) {
- error();
- return;
- }
+ DCHECK(array);
// Clear m_streamNeedsMore in order to detect a pull call.
m_streamNeedsMore = false;
controller()->enqueue(array);
@@ -330,6 +333,7 @@ void BodyStreamBuffer::processData()
break;
}
case BytesConsumer::Result::ShouldWait:
+ NOTREACHED();
return;
case BytesConsumer::Result::Done:
close();
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/fetch/BytesConsumer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698