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

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

Issue 1439953006: Reland: URLRequestJob: change ReadRawData contract (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address David's comment 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 f344feb1c4d8f69f22008c6ef9fee22cf70f0997..52fd71cac03cac5f0c4a03df3d15abf5da5cc0c1 100644
--- a/net/test/url_request/url_request_slow_download_job.cc
+++ b/net/test/url_request/url_request_slow_download_job.cc
@@ -179,39 +179,34 @@ URLRequestSlowDownloadJob::FillBufferHelper(IOBuffer* buf,
return REQUEST_COMPLETE;
}
-bool URLRequestSlowDownloadJob::ReadRawData(IOBuffer* buf,
- int buf_size,
- int* bytes_read) {
+int URLRequestSlowDownloadJob::ReadRawData(IOBuffer* buf, int buf_size) {
if (base::LowerCaseEqualsASCII(kFinishDownloadUrl,
request_->url().spec().c_str()) ||
base::LowerCaseEqualsASCII(kErrorDownloadUrl,
request_->url().spec().c_str())) {
VLOG(10) << __FUNCTION__ << " called w/ kFinish/ErrorDownloadUrl.";
- *bytes_read = 0;
- return true;
+ return 0;
}
VLOG(10) << __FUNCTION__ << " called at position " << bytes_already_sent_
<< " in the stream.";
- ReadStatus status = FillBufferHelper(buf, buf_size, bytes_read);
+ int bytes_read = 0;
+ ReadStatus status = FillBufferHelper(buf, buf_size, &bytes_read);
switch (status) {
case BUFFER_FILLED:
- return true;
+ case REQUEST_COMPLETE:
+ return bytes_read;
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 false;
- case REQUEST_COMPLETE:
- *bytes_read = 0;
- return true;
+ return ERR_IO_PENDING;
}
NOTREACHED();
- return true;
+ return OK;
}
void URLRequestSlowDownloadJob::CheckDoneStatus() {
@@ -223,12 +218,10 @@ void URLRequestSlowDownloadJob::CheckDoneStatus() {
FillBufferHelper(buffer_.get(), buffer_size_, &bytes_written);
DCHECK_EQ(BUFFER_FILLED, status);
buffer_ = NULL; // Release the reference.
- SetStatus(URLRequestStatus());
- NotifyReadComplete(bytes_written);
+ ReadRawDataComplete(bytes_written);
} else if (should_error_download_) {
VLOG(10) << __FUNCTION__ << " called w/ should_finish_ownload_ set.";
- NotifyDone(
- URLRequestStatus(URLRequestStatus::FAILED, ERR_CONNECTION_RESET));
+ ReadRawDataComplete(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