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

Unified Diff: mojo/services/network/url_loader_impl_apptest.cc

Issue 1410643007: URLRequestJob: change ReadRawData contract (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move NotifyReadCompleted Created 5 years, 2 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: mojo/services/network/url_loader_impl_apptest.cc
diff --git a/mojo/services/network/url_loader_impl_apptest.cc b/mojo/services/network/url_loader_impl_apptest.cc
index 2fb2210f032971cc6cfb07cb85091150f3772364..05660b7c9c27a63f3073c07e5a8f28a26d78596b 100644
--- a/mojo/services/network/url_loader_impl_apptest.cc
+++ b/mojo/services/network/url_loader_impl_apptest.cc
@@ -49,30 +49,22 @@ class TestURLRequestJob : public net::URLRequestJob {
void Start() override { status_ = STARTED; }
- bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override {
+ int ReadRawData(net::IOBuffer* buf, int buf_size) override {
status_ = READING;
buf_size_ = buf_size;
- SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
- return false;
+ return net::ERR_IO_PENDING;
}
void NotifyHeadersComplete() { net::URLRequestJob::NotifyHeadersComplete(); }
- void NotifyReadComplete(int bytes_read) {
- if (bytes_read < 0) {
- status_ = COMPLETED;
- NotifyDone(net::URLRequestStatus(
- net::URLRequestStatus::FromError(net::ERR_FAILED)));
- net::URLRequestJob::NotifyReadComplete(0);
- } else if (bytes_read == 0) {
- status_ = COMPLETED;
- NotifyDone(net::URLRequestStatus());
- net::URLRequestJob::NotifyReadComplete(bytes_read);
- } else {
- status_ = STARTED;
- SetStatus(net::URLRequestStatus());
- net::URLRequestJob::NotifyReadComplete(bytes_read);
- }
+ void NotifyReadComplete(int result) {
+ status_ = result == 0 ? COMPLETED : STARTED;
mmenke 2015/10/28 16:40:42 BUG: result <= 0
xunjieli 2015/10/28 21:11:52 Done.
+
+ // Map errors to net::ERR_FAILED.
+ if (result < 0)
+ result = net::ERR_FAILED;
+
+ ReadRawDataComplete(result);
}
private:

Powered by Google App Engine
This is Rietveld 408576698