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

Unified Diff: net/url_request/url_request_http_job.cc

Issue 1459333002: Revert "Reland: URLRequestJob: change ReadRawData contract" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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() {
« 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