Chromium Code Reviews| 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..89ec025ac698962946f0bc18874e7f00dfcdc035 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,35 @@ 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; |
| + 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; |
| + return ERR_IO_PENDING; |
| case REQUEST_COMPLETE: |
| - *bytes_read = 0; |
| - return true; |
| + return bytes_read; |
|
mmenke
2015/10/28 16:40:42
Can just merge this with the BUFFER_FILLED case
xunjieli
2015/10/28 21:11:52
Done.
|
| } |
| NOTREACHED(); |
| - return true; |
| + return OK; |
| } |
| void URLRequestSlowDownloadJob::CheckDoneStatus() { |
| @@ -223,12 +219,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, |