| Index: chrome/browser/chromeos/fileapi/external_file_url_request_job.cc
|
| diff --git a/chrome/browser/chromeos/fileapi/external_file_url_request_job.cc b/chrome/browser/chromeos/fileapi/external_file_url_request_job.cc
|
| index 213211377f192621a57a32919c58159adc29bffe..ef8d93a30c39c861ba66c278d8d83d816b9e07cb 100644
|
| --- a/chrome/browser/chromeos/fileapi/external_file_url_request_job.cc
|
| +++ b/chrome/browser/chromeos/fileapi/external_file_url_request_job.cc
|
| @@ -163,9 +163,9 @@ ExternalFileURLRequestJob::ExternalFileURLRequestJob(
|
| net::NetworkDelegate* network_delegate)
|
| : net::URLRequestJob(request, network_delegate),
|
| profile_id_(profile_id),
|
| + range_parse_result_(net::OK),
|
| remaining_bytes_(0),
|
| - weak_ptr_factory_(this) {
|
| -}
|
| + weak_ptr_factory_(this) {}
|
|
|
| void ExternalFileURLRequestJob::SetExtraRequestHeaders(
|
| const net::HttpRequestHeaders& headers) {
|
| @@ -177,18 +177,23 @@ void ExternalFileURLRequestJob::SetExtraRequestHeaders(
|
| ranges.size() == 1) {
|
| byte_range_ = ranges[0];
|
| } else {
|
| - // Failed to parse Range: header, so notify the error.
|
| - NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED,
|
| - net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
|
| + // Failed to parse Range: header, so save the error whih will be reported
|
| + // in Start.
|
| + range_parse_result_ = net::ERR_REQUEST_RANGE_NOT_SATISFIABLE;
|
| }
|
| }
|
| }
|
| -
|
| void ExternalFileURLRequestJob::Start() {
|
| DVLOG(1) << "Starting request";
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| DCHECK(!stream_reader_);
|
|
|
| + if (range_parse_result_ != net::OK) {
|
| + NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED,
|
| + range_parse_result_));
|
| + return;
|
| + }
|
| +
|
| // We only support GET request.
|
| if (request()->method() != "GET") {
|
| LOG(WARNING) << "Failed to start request: " << request()->method()
|
| @@ -326,38 +331,23 @@ bool ExternalFileURLRequestJob::IsRedirectResponse(GURL* location,
|
| return true;
|
| }
|
|
|
| -bool ExternalFileURLRequestJob::ReadRawData(net::IOBuffer* buf,
|
| - int buf_size,
|
| - int* bytes_read) {
|
| +int ExternalFileURLRequestJob::ReadRawData(net::IOBuffer* buf, int buf_size) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| DCHECK(stream_reader_);
|
|
|
| - if (remaining_bytes_ == 0) {
|
| - *bytes_read = 0;
|
| - return true;
|
| - }
|
| + if (remaining_bytes_ == 0)
|
| + return 0;
|
|
|
| const int result = stream_reader_->Read(
|
| - buf,
|
| - std::min<int64>(buf_size, remaining_bytes_),
|
| + buf, std::min<int64>(buf_size, remaining_bytes_),
|
| base::Bind(&ExternalFileURLRequestJob::OnReadCompleted,
|
| weak_ptr_factory_.GetWeakPtr()));
|
|
|
| - if (result == net::ERR_IO_PENDING) {
|
| - // The data is not yet available.
|
| - SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
|
| - return false;
|
| - }
|
| - if (result < 0) {
|
| - // An error occurs.
|
| - NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, result));
|
| - return false;
|
| - }
|
| + if (result < 0)
|
| + return result;
|
|
|
| - // Reading has been finished immediately.
|
| - *bytes_read = result;
|
| remaining_bytes_ -= result;
|
| - return true;
|
| + return result;
|
| }
|
|
|
| ExternalFileURLRequestJob::~ExternalFileURLRequestJob() {
|
| @@ -366,15 +356,10 @@ ExternalFileURLRequestJob::~ExternalFileURLRequestJob() {
|
| void ExternalFileURLRequestJob::OnReadCompleted(int read_result) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
|
|
| - if (read_result < 0) {
|
| - DCHECK_NE(read_result, net::ERR_IO_PENDING);
|
| - NotifyDone(
|
| - net::URLRequestStatus(net::URLRequestStatus::FAILED, read_result));
|
| - }
|
| + if (read_result > 0)
|
| + remaining_bytes_ -= read_result;
|
|
|
| - remaining_bytes_ -= read_result;
|
| - SetStatus(net::URLRequestStatus()); // Clear the IO_PENDING status.
|
| - NotifyReadComplete(read_result);
|
| + ReadRawDataComplete(read_result);
|
| }
|
|
|
| } // namespace chromeos
|
|
|