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

Unified Diff: net/url_request/url_fetcher_core.cc

Issue 2265873002: Adjust callers and networking delegates in net/ to modified APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@URLRequestRead
Patch Set: rebased Created 4 years, 4 months 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
Index: net/url_request/url_fetcher_core.cc
diff --git a/net/url_request/url_fetcher_core.cc b/net/url_request/url_fetcher_core.cc
index 3d49ad233d242badf58232f4f1897b3740ef2330..28abbf3ef8378830b5c7d74e83eec11bfa10cc22 100644
--- a/net/url_request/url_fetcher_core.cc
+++ b/net/url_request/url_fetcher_core.cc
@@ -407,15 +407,17 @@ void URLFetcherCore::OnReceivedRedirect(URLRequest* request,
was_fetched_via_proxy_ = request_->was_fetched_via_proxy();
was_cached_ = request_->was_cached();
total_received_bytes_ += request_->GetTotalReceivedBytes();
- request->Cancel();
- OnReadCompleted(request, 0);
+ int result = request->Cancel();
+ OnReadCompleted(request, result);
}
}
-void URLFetcherCore::OnResponseStarted(URLRequest* request) {
+void URLFetcherCore::OnResponseStarted(URLRequest* request, int net_error) {
DCHECK_EQ(request, request_.get());
DCHECK(network_task_runner_->BelongsToCurrentThread());
- if (request_->status().is_success()) {
+ DCHECK_NE(ERR_IO_PENDING, net_error);
+
+ if (net_error == OK) {
response_code_ = request_->GetResponseCode();
response_headers_ = request_->response_headers();
socket_address_ = request_->GetSocketAddress();
@@ -453,7 +455,7 @@ void URLFetcherCore::OnReadCompleted(URLRequest* request,
url_throttler_entry_ = throttler_manager->RegisterRequestUrl(url_);
do {
- if (!request_->status().is_success() || bytes_read <= 0)
+ if (bytes_read <= 0)
break;
current_response_bytes_ += bytes_read;
@@ -465,13 +467,12 @@ void URLFetcherCore::OnReadCompleted(URLRequest* request,
// Write failed or waiting for write completion.
return;
}
- } while (request_->Read(buffer_.get(), kBufferSize, &bytes_read));
-
- const URLRequestStatus status = request_->status();
+ bytes_read = request_->Read(buffer_.get(), kBufferSize);
+ } while (bytes_read > 0);
// See comments re: HEAD requests in ReadResponse().
- if (!status.is_io_pending() || request_type_ == URLFetcher::HEAD) {
- status_ = status;
+ if (bytes_read != ERR_IO_PENDING || request_type_ == URLFetcher::HEAD) {
+ status_ = URLRequestStatus::FromError(bytes_read);
received_response_content_length_ =
request_->received_response_content_length();
total_received_bytes_ += request_->GetTotalReceivedBytes();
@@ -886,11 +887,9 @@ void URLFetcherCore::ReadResponse() {
// completed immediately, without trying to read any data back (all we care
// about is the response code and headers, which we already have).
int bytes_read = 0;
- if (request_->status().is_success() &&
- (request_type_ != URLFetcher::HEAD)) {
- if (!request_->Read(buffer_.get(), kBufferSize, &bytes_read))
- bytes_read = -1; // Match OnReadCompleted() interface contract.
- }
+ if (request_type_ != URLFetcher::HEAD)
+ bytes_read = request_->Read(buffer_.get(), kBufferSize);
+
OnReadCompleted(request_.get(), bytes_read);
}

Powered by Google App Engine
This is Rietveld 408576698