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

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

Issue 2356693002: Remove BytesConsumer::read (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/Source/modules/fetch/BytesConsumerTestUtil.h ('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/BytesConsumerTestUtil.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/BytesConsumerTestUtil.cpp b/third_party/WebKit/Source/modules/fetch/BytesConsumerTestUtil.cpp
index 27267d9945b09f9b04488c684b82d7ea85bbc1f1..22a6f1e03f5f86caee26a74465dbda8d679ccbbe 100644
--- a/third_party/WebKit/Source/modules/fetch/BytesConsumerTestUtil.cpp
+++ b/third_party/WebKit/Source/modules/fetch/BytesConsumerTestUtil.cpp
@@ -149,47 +149,6 @@ DEFINE_TRACE(BytesConsumerTestUtil::ReplayingBytesConsumer)
BytesConsumer::trace(visitor);
}
-BytesConsumerTestUtil::Reader::Reader(BytesConsumer* consumer)
- : m_consumer(consumer)
-{
- m_consumer->setClient(this);
-}
-
-void BytesConsumerTestUtil::Reader::onStateChange()
-{
- while (true) {
- // We choose 3 here because of the following reasons.
- // - We want to split a string with multiple chunks, so we need to
- // choose a small number.
- // - An odd number is preferable to check an out-of-range error.
- // - With 1, every chunk consists of one byte it's too simple.
- char buffer[3];
- size_t read = 0;
- switch (m_consumer->read(buffer, sizeof(buffer), &read)) {
- case BytesConsumer::Result::Ok:
- m_data.append(buffer, read);
- break;
- case BytesConsumer::Result::ShouldWait:
- return;
- case BytesConsumer::Result::Done:
- m_result = BytesConsumer::Result::Done;
- return;
- case BytesConsumer::Result::Error:
- m_result = BytesConsumer::Result::Error;
- return;
- }
- }
-}
-
-std::pair<BytesConsumer::Result, Vector<char>> BytesConsumerTestUtil::Reader::run()
-{
- onStateChange();
- while (m_result != BytesConsumer::Result::Done && m_result != BytesConsumer::Result::Error)
- testing::runPendingTasks();
- testing::runPendingTasks();
- return std::make_pair(m_result, std::move(m_data));
-}
-
BytesConsumerTestUtil::TwoPhaseReader::TwoPhaseReader(BytesConsumer* consumer)
: m_consumer(consumer)
{
@@ -207,7 +166,7 @@ void BytesConsumerTestUtil::TwoPhaseReader::onStateChange()
// 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::max(static_cast<size_t>(3), available);
+ size_t read = std::min(static_cast<size_t>(3), available);
yhirano 2016/09/20 08:44:41 This is a separate bug. I found this bug in the pr
m_data.append(buffer, read);
if (m_consumer->endRead(read) != BytesConsumer::Result::Ok) {
m_result = BytesConsumer::Result::Error;
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/BytesConsumerTestUtil.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698