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

Unified Diff: net/url_request/url_request_ftp_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_ftp_job.h ('k') | net/url_request/url_request_http_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_ftp_job.cc
diff --git a/net/url_request/url_request_ftp_job.cc b/net/url_request/url_request_ftp_job.cc
index e422d036597461d138b6e9bc06ae38c841e70962..3a088bd87c9f4ef5de66a333efb14f691d6254cd 100644
--- a/net/url_request/url_request_ftp_job.cc
+++ b/net/url_request/url_request_ftp_job.cc
@@ -239,7 +239,7 @@ void URLRequestFtpJob::OnStartCompleted(int result) {
HandleAuthNeededResponse();
return;
} else {
- NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result));
+ NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result));
}
}
@@ -251,7 +251,15 @@ void URLRequestFtpJob::OnStartCompletedAsync(int result) {
void URLRequestFtpJob::OnReadCompleted(int result) {
read_in_progress_ = false;
- ReadRawDataComplete(result);
+ if (result == 0) {
+ NotifyDone(URLRequestStatus());
+ } else if (result < 0) {
+ NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result));
+ } else {
+ // Clear the IO_PENDING status
+ SetStatus(URLRequestStatus());
+ }
+ NotifyReadComplete(result);
}
void URLRequestFtpJob::RestartTransactionWithAuth() {
@@ -344,12 +352,14 @@ UploadProgress URLRequestFtpJob::GetUploadProgress() const {
return UploadProgress();
}
-int URLRequestFtpJob::ReadRawData(IOBuffer* buf, int buf_size) {
+bool URLRequestFtpJob::ReadRawData(IOBuffer* buf,
+ int buf_size,
+ int* bytes_read) {
DCHECK_NE(buf_size, 0);
+ DCHECK(bytes_read);
DCHECK(!read_in_progress_);
int rv;
-
if (proxy_info_.is_direct()) {
rv = ftp_transaction_->Read(buf, buf_size,
base::Bind(&URLRequestFtpJob::OnReadCompleted,
@@ -360,9 +370,18 @@ int URLRequestFtpJob::ReadRawData(IOBuffer* buf, int buf_size) {
base::Unretained(this)));
}
- if (rv == ERR_IO_PENDING)
+ if (rv >= 0) {
+ *bytes_read = rv;
+ return true;
+ }
+
+ if (rv == ERR_IO_PENDING) {
read_in_progress_ = true;
- return rv;
+ SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
+ } else {
+ NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
+ }
+ return false;
}
void URLRequestFtpJob::HandleAuthNeededResponse() {
« no previous file with comments | « net/url_request/url_request_ftp_job.h ('k') | net/url_request/url_request_http_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698