| Index: net/url_request/url_request_http_job.cc
|
| diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
|
| index 13365dfe225d399b27f41ba6223172f6d284c694..dac461d01031d3d780531e13518515a030483747 100644
|
| --- a/net/url_request/url_request_http_job.cc
|
| +++ b/net/url_request/url_request_http_job.cc
|
| @@ -414,6 +414,11 @@ void URLRequestHttpJob::NotifyHeadersComplete() {
|
| URLRequestJob::NotifyHeadersComplete();
|
| }
|
|
|
| +void URLRequestHttpJob::NotifyDone(const URLRequestStatus& status) {
|
| + DoneWithRequest(FINISHED);
|
| + URLRequestJob::NotifyDone(status);
|
| +}
|
| +
|
| void URLRequestHttpJob::DestroyTransaction() {
|
| DCHECK(transaction_.get());
|
|
|
| @@ -993,16 +998,19 @@ void URLRequestHttpJob::OnHeadersReceivedCallback(int result) {
|
| void URLRequestHttpJob::OnReadCompleted(int result) {
|
| read_in_progress_ = false;
|
|
|
| - DCHECK_NE(ERR_IO_PENDING, result);
|
| -
|
| if (ShouldFixMismatchedContentLength(result))
|
| result = OK;
|
|
|
| - // EOF or error, done with this job.
|
| - if (result <= 0)
|
| - DoneWithRequest(FINISHED);
|
| + if (result == OK) {
|
| + NotifyDone(URLRequestStatus());
|
| + } else if (result < 0) {
|
| + NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result));
|
| + } else {
|
| + // Clear the IO_PENDING status
|
| + SetStatus(URLRequestStatus());
|
| + }
|
|
|
| - ReadRawDataComplete(result);
|
| + NotifyReadComplete(result);
|
| }
|
|
|
| void URLRequestHttpJob::RestartTransactionWithAuth(
|
| @@ -1326,8 +1334,11 @@ bool URLRequestHttpJob::ShouldFixMismatchedContentLength(int rv) const {
|
| return false;
|
| }
|
|
|
| -int URLRequestHttpJob::ReadRawData(IOBuffer* buf, int buf_size) {
|
| +bool URLRequestHttpJob::ReadRawData(IOBuffer* buf,
|
| + int buf_size,
|
| + int* bytes_read) {
|
| DCHECK_NE(buf_size, 0);
|
| + DCHECK(bytes_read);
|
| DCHECK(!read_in_progress_);
|
|
|
| int rv = transaction_->Read(
|
| @@ -1335,15 +1346,23 @@ int URLRequestHttpJob::ReadRawData(IOBuffer* buf, int buf_size) {
|
| base::Bind(&URLRequestHttpJob::OnReadCompleted, base::Unretained(this)));
|
|
|
| if (ShouldFixMismatchedContentLength(rv))
|
| - rv = OK;
|
| + rv = 0;
|
|
|
| - if (rv == 0 || (rv < 0 && rv != ERR_IO_PENDING))
|
| - DoneWithRequest(FINISHED);
|
| + if (rv >= 0) {
|
| + *bytes_read = rv;
|
| + if (!rv)
|
| + DoneWithRequest(FINISHED);
|
| + return true;
|
| + }
|
|
|
| - if (rv == ERR_IO_PENDING)
|
| + if (rv == ERR_IO_PENDING) {
|
| read_in_progress_ = true;
|
| + SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
|
| + } else {
|
| + NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
|
| + }
|
|
|
| - return rv;
|
| + return false;
|
| }
|
|
|
| void URLRequestHttpJob::StopCaching() {
|
|
|