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

Unified Diff: third_party/WebKit/Source/modules/fetch/BytesConsumerTestUtil.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/BytesConsumerTestUtil.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/BytesConsumerTestUtil.cpp b/third_party/WebKit/Source/modules/fetch/BytesConsumerTestUtil.cpp
index 22a6f1e03f5f86caee26a74465dbda8d679ccbbe..1c2039d610df534961a4ca731aa3cee1ad9cafc1 100644
--- a/third_party/WebKit/Source/modules/fetch/BytesConsumerTestUtil.cpp
+++ b/third_party/WebKit/Source/modules/fetch/BytesConsumerTestUtil.cpp
@@ -161,26 +161,20 @@ void BytesConsumerTestUtil::TwoPhaseReader::onStateChange()
while (true) {
const char* buffer = nullptr;
size_t available = 0;
- switch (m_consumer->beginRead(&buffer, &available)) {
- case BytesConsumer::Result::Ok: {
+ auto result = m_consumer->beginRead(&buffer, &available);
+ if (result == BytesConsumer::Result::ShouldWait)
+ return;
+ if (result == BytesConsumer::Result::Ok) {
// We don't use |available| as-is to test cases where endRead
// is called with a number smaller than |available|. We choose 3
// because of the same reasons as Reader::onStateChange.
size_t read = std::min(static_cast<size_t>(3), available);
m_data.append(buffer, read);
- if (m_consumer->endRead(read) != BytesConsumer::Result::Ok) {
- m_result = BytesConsumer::Result::Error;
- return;
- }
- break;
+ result = m_consumer->endRead(read);
}
- case BytesConsumer::Result::ShouldWait:
- return;
- case BytesConsumer::Result::Done:
- m_result = BytesConsumer::Result::Done;
- return;
- case BytesConsumer::Result::Error:
- m_result = BytesConsumer::Result::Error;
+ DCHECK_NE(result, BytesConsumer::Result::ShouldWait);
+ if (result != BytesConsumer::Result::Ok) {
+ m_result = result;
return;
}
}
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/BytesConsumer.cpp ('k') | third_party/WebKit/Source/modules/fetch/FetchDataLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698