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

Unified Diff: net/url_request/url_request_http_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/url_request/url_request_http_job.h ('k') | net/url_request/url_request_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dac461d01031d3d780531e13518515a030483747..13365dfe225d399b27f41ba6223172f6d284c694 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -414,11 +414,6 @@ void URLRequestHttpJob::NotifyHeadersComplete() {
URLRequestJob::NotifyHeadersComplete();
}
-void URLRequestHttpJob::NotifyDone(const URLRequestStatus& status) {
- DoneWithRequest(FINISHED);
- URLRequestJob::NotifyDone(status);
-}
-
void URLRequestHttpJob::DestroyTransaction() {
DCHECK(transaction_.get());
@@ -998,19 +993,16 @@ 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;
- if (result == OK) {
- NotifyDone(URLRequestStatus());
- } else if (result < 0) {
- NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result));
- } else {
- // Clear the IO_PENDING status
- SetStatus(URLRequestStatus());
- }
+ // EOF or error, done with this job.
+ if (result <= 0)
+ DoneWithRequest(FINISHED);
- NotifyReadComplete(result);
+ ReadRawDataComplete(result);
}
void URLRequestHttpJob::RestartTransactionWithAuth(
@@ -1334,11 +1326,8 @@ bool URLRequestHttpJob::ShouldFixMismatchedContentLength(int rv) const {
return false;
}
-bool URLRequestHttpJob::ReadRawData(IOBuffer* buf,
- int buf_size,
- int* bytes_read) {
+int URLRequestHttpJob::ReadRawData(IOBuffer* buf, int buf_size) {
DCHECK_NE(buf_size, 0);
- DCHECK(bytes_read);
DCHECK(!read_in_progress_);
int rv = transaction_->Read(
@@ -1346,23 +1335,15 @@ bool URLRequestHttpJob::ReadRawData(IOBuffer* buf,
base::Bind(&URLRequestHttpJob::OnReadCompleted, base::Unretained(this)));
if (ShouldFixMismatchedContentLength(rv))
- rv = 0;
+ rv = OK;
- if (rv >= 0) {
- *bytes_read = rv;
- if (!rv)
- DoneWithRequest(FINISHED);
- return true;
- }
+ if (rv == 0 || (rv < 0 && rv != ERR_IO_PENDING))
+ DoneWithRequest(FINISHED);
- 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 false;
+ return rv;
}
void URLRequestHttpJob::StopCaching() {
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | net/url_request/url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698