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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/BytesConsumerTestUtil.cpp

Issue 2319033002: Add WARN_UNUSED_RESULT to BytesConsumer read methods. (Closed)
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/fetch/BytesConsumerTestUtil.h" 5 #include "modules/fetch/BytesConsumerTestUtil.h"
6 6
7 #include "core/dom/ExecutionContext.h" 7 #include "core/dom/ExecutionContext.h"
8 #include "core/dom/TaskRunnerHelper.h" 8 #include "core/dom/TaskRunnerHelper.h"
9 #include "platform/testing/UnitTestHelpers.h" 9 #include "platform/testing/UnitTestHelpers.h"
10 #include "public/platform/WebTaskRunner.h" 10 #include "public/platform/WebTaskRunner.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 while (true) { 202 while (true) {
203 const char* buffer = nullptr; 203 const char* buffer = nullptr;
204 size_t available = 0; 204 size_t available = 0;
205 switch (m_consumer->beginRead(&buffer, &available)) { 205 switch (m_consumer->beginRead(&buffer, &available)) {
206 case BytesConsumer::Result::Ok: { 206 case BytesConsumer::Result::Ok: {
207 // We don't use |available| as-is to test cases where endRead 207 // We don't use |available| as-is to test cases where endRead
208 // is called with a number smaller than |available|. We choose 3 208 // is called with a number smaller than |available|. We choose 3
209 // because of the same reasons as Reader::onStateChange. 209 // because of the same reasons as Reader::onStateChange.
210 size_t read = std::max(static_cast<size_t>(3), available); 210 size_t read = std::max(static_cast<size_t>(3), available);
211 m_data.append(buffer, read); 211 m_data.append(buffer, read);
212 m_consumer->endRead(read); 212 if (m_consumer->endRead(read) != BytesConsumer::Result::Ok) {
213 m_result = BytesConsumer::Result::Error;
214 return;
215 }
213 break; 216 break;
214 } 217 }
215 case BytesConsumer::Result::ShouldWait: 218 case BytesConsumer::Result::ShouldWait:
216 return; 219 return;
217 case BytesConsumer::Result::Done: 220 case BytesConsumer::Result::Done:
218 m_result = BytesConsumer::Result::Done; 221 m_result = BytesConsumer::Result::Done;
219 return; 222 return;
220 case BytesConsumer::Result::Error: 223 case BytesConsumer::Result::Error:
221 m_result = BytesConsumer::Result::Error; 224 m_result = BytesConsumer::Result::Error;
222 return; 225 return;
223 } 226 }
224 } 227 }
225 } 228 }
226 229
227 std::pair<BytesConsumer::Result, Vector<char>> BytesConsumerTestUtil::TwoPhaseRe ader::run() 230 std::pair<BytesConsumer::Result, Vector<char>> BytesConsumerTestUtil::TwoPhaseRe ader::run()
228 { 231 {
229 onStateChange(); 232 onStateChange();
230 while (m_result != BytesConsumer::Result::Done && m_result != BytesConsumer: :Result::Error) 233 while (m_result != BytesConsumer::Result::Done && m_result != BytesConsumer: :Result::Error)
231 testing::runPendingTasks(); 234 testing::runPendingTasks();
232 testing::runPendingTasks(); 235 testing::runPendingTasks();
233 return std::make_pair(m_result, std::move(m_data)); 236 return std::make_pair(m_result, std::move(m_data));
234 } 237 }
235 238
236 } // namespace blink 239 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/BytesConsumer.h ('k') | third_party/WebKit/Source/modules/fetch/FetchDataLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698