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) |