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

Unified Diff: third_party/WebKit/Source/modules/fetch/BytesConsumer.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
Index: third_party/WebKit/Source/modules/fetch/BytesConsumer.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/BytesConsumer.cpp b/third_party/WebKit/Source/modules/fetch/BytesConsumer.cpp
index f1584d0c76b0207a86630cf5082dd757e4ad425e..a71ad8a94f36ecdca2d8130f9508cc31d2e54086 100644
--- a/third_party/WebKit/Source/modules/fetch/BytesConsumer.cpp
+++ b/third_party/WebKit/Source/modules/fetch/BytesConsumer.cpp
@@ -48,23 +48,28 @@ public:
while (true) {
const char* buffer = nullptr;
size_t available = 0;
- switch (m_src->beginRead(&buffer, &available)) {
- case Result::Ok: {
- Chunk* chunk = new Chunk(buffer, available);
- if (m_src->endRead(available) != Result::Ok) {
- clearAndNotify();
- return;
- }
+ auto result = m_src->beginRead(&buffer, &available);
+ if (result == Result::ShouldWait) {
+ if (hasEnqueued && destination1WasEmpty)
+ m_destination1->notify();
+ if (hasEnqueued && destination2WasEmpty)
+ m_destination2->notify();
+ return;
+ }
+ Chunk* chunk = nullptr;
+ if (result == Result::Ok) {
+ chunk = new Chunk(buffer, available);
+ result = m_src->endRead(available);
+ }
+ switch (result) {
+ case Result::Ok:
+ DCHECK(chunk);
m_destination1->enqueue(chunk);
m_destination2->enqueue(chunk);
hasEnqueued = true;
break;
- }
case Result::ShouldWait:
- if (hasEnqueued && destination1WasEmpty)
- m_destination1->notify();
- if (hasEnqueued && destination2WasEmpty)
- m_destination2->notify();
+ NOTREACHED();
return;
case Result::Done:
if (destination1WasEmpty)

Powered by Google App Engine
This is Rietveld 408576698