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

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 on top of URLRequest::Read CL Created 4 years, 3 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
« no previous file with comments | « net/url_request/url_fetcher_core.h ('k') | net/url_request/url_request_context_builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d4fc8990ef92eae791999ef4b97d2ede5d25ccbc 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();
@@ -452,10 +454,7 @@ void URLFetcherCore::OnReadCompleted(URLRequest* request,
if (throttler_manager)
url_throttler_entry_ = throttler_manager->RegisterRequestUrl(url_);
- do {
- if (!request_->status().is_success() || bytes_read <= 0)
- break;
-
+ while (bytes_read > 0) {
current_response_bytes_ += bytes_read;
InformDelegateDownloadProgress();
@@ -465,13 +464,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);
+ }
// 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 +884,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);
}
« no previous file with comments | « net/url_request/url_fetcher_core.h ('k') | net/url_request/url_request_context_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698