Chromium Code Reviews| Index: net/url_request/url_request_simple_job.cc |
| diff --git a/net/url_request/url_request_simple_job.cc b/net/url_request/url_request_simple_job.cc |
| index 2fdbef4049ad0db86e25562b041ace700c20a0f5..76ca25d62e7f224ec02d25fdaeae89c1a1c4bc7e 100644 |
| --- a/net/url_request/url_request_simple_job.cc |
| +++ b/net/url_request/url_request_simple_job.cc |
| @@ -65,17 +65,11 @@ bool URLRequestSimpleJob::GetCharset(std::string* charset) { |
| URLRequestSimpleJob::~URLRequestSimpleJob() {} |
| -bool URLRequestSimpleJob::ReadRawData(IOBuffer* buf, int buf_size, |
| - int* bytes_read) { |
| - DCHECK(bytes_read); |
| - buf_size = static_cast<int>( |
| - std::min(static_cast<int64>(buf_size), |
| - byte_range_.last_byte_position() - next_data_offset_ + 1)); |
| - DCHECK_GE(buf_size, 0); |
| - if (buf_size == 0) { |
| - *bytes_read = 0; |
| - return true; |
| - } |
| +int URLRequestSimpleJob::ReadRawData(IOBuffer* buf, int buf_size) { |
| + buf_size = std::min(static_cast<int64>(buf_size), |
| + byte_range_.last_byte_position() - next_data_offset_ + 1); |
| + if (buf_size == 0) |
| + return 0; |
| // Do memory copy on a background thread. See crbug.com/422489. |
| GetTaskRunner()->PostTaskAndReply( |
| @@ -84,13 +78,11 @@ bool URLRequestSimpleJob::ReadRawData(IOBuffer* buf, int buf_size, |
| base::Bind(&URLRequestSimpleJob::OnReadCompleted, |
| weak_factory_.GetWeakPtr(), buf_size)); |
| next_data_offset_ += buf_size; |
| - SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); |
| - return false; |
| + return ERR_IO_PENDING; |
| } |
| void URLRequestSimpleJob::OnReadCompleted(int bytes_read) { |
| - SetStatus(URLRequestStatus()); |
| - NotifyReadComplete(bytes_read); |
| + ReadRawDataComplete(bytes_read); |
| } |
|
mmenke
2015/10/27 19:41:08
Get rid of this method, and just have the posted t
xunjieli
2015/10/27 21:24:07
Done.
|
| base::TaskRunner* URLRequestSimpleJob::GetTaskRunner() const { |
| @@ -121,8 +113,8 @@ void URLRequestSimpleJob::StartAsync() { |
| return; |
| if (ranges().size() > 1) { |
| - NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, |
| - ERR_REQUEST_RANGE_NOT_SATISFIABLE)); |
| + NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, |
| + ERR_REQUEST_RANGE_NOT_SATISFIABLE)); |
| return; |
| } |
| @@ -142,8 +134,8 @@ void URLRequestSimpleJob::OnGetDataCompleted(int result) { |
| if (result == OK) { |
| // Notify that the headers are complete |
| if (!byte_range_.ComputeBounds(data_->size())) { |
| - NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, |
| - ERR_REQUEST_RANGE_NOT_SATISFIABLE)); |
| + NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, |
| + ERR_REQUEST_RANGE_NOT_SATISFIABLE)); |
| return; |
| } |