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

Unified Diff: net/test/url_request/url_request_slow_download_job.cc

Issue 1459333002: Revert "Reland: URLRequestJob: change ReadRawData contract" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « net/test/url_request/url_request_slow_download_job.h ('k') | net/url_request/url_request_file_dir_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/url_request/url_request_slow_download_job.cc
diff --git a/net/test/url_request/url_request_slow_download_job.cc b/net/test/url_request/url_request_slow_download_job.cc
index 52fd71cac03cac5f0c4a03df3d15abf5da5cc0c1..f344feb1c4d8f69f22008c6ef9fee22cf70f0997 100644
--- a/net/test/url_request/url_request_slow_download_job.cc
+++ b/net/test/url_request/url_request_slow_download_job.cc
@@ -179,34 +179,39 @@ URLRequestSlowDownloadJob::FillBufferHelper(IOBuffer* buf,
return REQUEST_COMPLETE;
}
-int URLRequestSlowDownloadJob::ReadRawData(IOBuffer* buf, int buf_size) {
+bool URLRequestSlowDownloadJob::ReadRawData(IOBuffer* buf,
+ int buf_size,
+ int* bytes_read) {
if (base::LowerCaseEqualsASCII(kFinishDownloadUrl,
request_->url().spec().c_str()) ||
base::LowerCaseEqualsASCII(kErrorDownloadUrl,
request_->url().spec().c_str())) {
VLOG(10) << __FUNCTION__ << " called w/ kFinish/ErrorDownloadUrl.";
- return 0;
+ *bytes_read = 0;
+ return true;
}
VLOG(10) << __FUNCTION__ << " called at position " << bytes_already_sent_
<< " in the stream.";
- int bytes_read = 0;
- ReadStatus status = FillBufferHelper(buf, buf_size, &bytes_read);
+ ReadStatus status = FillBufferHelper(buf, buf_size, bytes_read);
switch (status) {
case BUFFER_FILLED:
- case REQUEST_COMPLETE:
- return bytes_read;
+ return true;
case REQUEST_BLOCKED:
buffer_ = buf;
buffer_size_ = buf_size;
+ SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&URLRequestSlowDownloadJob::CheckDoneStatus,
weak_factory_.GetWeakPtr()),
base::TimeDelta::FromMilliseconds(100));
- return ERR_IO_PENDING;
+ return false;
+ case REQUEST_COMPLETE:
+ *bytes_read = 0;
+ return true;
}
NOTREACHED();
- return OK;
+ return true;
}
void URLRequestSlowDownloadJob::CheckDoneStatus() {
@@ -218,10 +223,12 @@ void URLRequestSlowDownloadJob::CheckDoneStatus() {
FillBufferHelper(buffer_.get(), buffer_size_, &bytes_written);
DCHECK_EQ(BUFFER_FILLED, status);
buffer_ = NULL; // Release the reference.
- ReadRawDataComplete(bytes_written);
+ SetStatus(URLRequestStatus());
+ NotifyReadComplete(bytes_written);
} else if (should_error_download_) {
VLOG(10) << __FUNCTION__ << " called w/ should_finish_ownload_ set.";
- ReadRawDataComplete(ERR_CONNECTION_RESET);
+ NotifyDone(
+ URLRequestStatus(URLRequestStatus::FAILED, ERR_CONNECTION_RESET));
} else {
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&URLRequestSlowDownloadJob::CheckDoneStatus,
« no previous file with comments | « net/test/url_request/url_request_slow_download_job.h ('k') | net/url_request/url_request_file_dir_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698