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

Unified Diff: net/cert_net/cert_net_fetcher_impl.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
« no previous file with comments | « no previous file | net/cert_net/nss_ocsp.cc » ('j') | net/cert_net/nss_ocsp.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert_net/cert_net_fetcher_impl.cc
diff --git a/net/cert_net/cert_net_fetcher_impl.cc b/net/cert_net/cert_net_fetcher_impl.cc
index 385948685df72149ba8758b8b47fbd419ef38b06..9163cc9880bf6e92c929101190a0bd252f9e16f7 100644
--- a/net/cert_net/cert_net_fetcher_impl.cc
+++ b/net/cert_net/cert_net_fetcher_impl.cc
@@ -178,7 +178,7 @@ class CertNetFetcherImpl::Job : public URLRequest::Delegate {
void OnReceivedRedirect(URLRequest* request,
const RedirectInfo& redirect_info,
bool* defer_redirect) override;
- void OnResponseStarted(URLRequest* request) override;
+ void OnResponseStarted(URLRequest* request, int net_error) override;
void OnReadCompleted(URLRequest* request, int bytes_read) override;
// Clears the URLRequest and timer. Helper for doing work common to
@@ -196,7 +196,7 @@ class CertNetFetcherImpl::Job : public URLRequest::Delegate {
void OnTimeout();
// Called when the URLRequest has completed (either success or failure).
- void OnUrlRequestCompleted(URLRequest* request);
+ void OnUrlRequestCompleted(URLRequest* request, int net_error);
// Called when the Job has completed. The job may finish in response to a
// timeout, an invalid URL, or the URLRequest completing. By the time this
@@ -311,24 +311,26 @@ void CertNetFetcherImpl::Job::OnReceivedRedirect(
// Ensure that the new URL matches the policy.
Error error = CanFetchUrl(redirect_info.new_url);
if (error != OK) {
- request->CancelWithError(error);
- OnUrlRequestCompleted(request);
+ int status = request->CancelWithError(error);
mmenke 2016/08/30 22:13:22 Can we call these results, instead? net:Errors ar
maksims (do not use this acc) 2016/09/01 12:22:29 Done.
+ OnUrlRequestCompleted(request, status);
return;
}
}
-void CertNetFetcherImpl::Job::OnResponseStarted(URLRequest* request) {
+void CertNetFetcherImpl::Job::OnResponseStarted(URLRequest* request,
+ int net_error) {
DCHECK_EQ(url_request_.get(), request);
+ DCHECK_NE(ERR_IO_PENDING, net_error);
- if (!request->status().is_success()) {
- OnUrlRequestCompleted(request);
+ if (net_error != OK) {
+ OnUrlRequestCompleted(request, net_error);
return;
}
if (request->GetResponseCode() != 200) {
// TODO(eroman): Use a more specific error code.
- request->CancelWithError(ERR_FAILED);
- OnUrlRequestCompleted(request);
+ int status = request->CancelWithError(ERR_FAILED);
+ OnUrlRequestCompleted(request, status);
return;
}
@@ -338,6 +340,7 @@ void CertNetFetcherImpl::Job::OnResponseStarted(URLRequest* request) {
void CertNetFetcherImpl::Job::OnReadCompleted(URLRequest* request,
int bytes_read) {
DCHECK_EQ(url_request_.get(), request);
+ DCHECK_NE(ERR_IO_PENDING, bytes_read);
// Keep reading the response body.
if (ConsumeBytesRead(request, bytes_read))
@@ -351,16 +354,16 @@ void CertNetFetcherImpl::Job::Stop() {
void CertNetFetcherImpl::Job::ReadBody(URLRequest* request) {
// Read as many bytes as are available synchronously.
- int num_bytes;
- while (
- request->Read(read_buffer_.get(), kReadBufferSizeInBytes, &num_bytes)) {
+ int num_bytes = 0;
+ while (num_bytes >= 0) {
+ num_bytes = request->Read(read_buffer_.get(), kReadBufferSizeInBytes);
if (!ConsumeBytesRead(request, num_bytes))
return;
}
// Check whether the read failed synchronously.
- if (!request->status().is_io_pending())
- OnUrlRequestCompleted(request);
+ if (num_bytes != ERR_IO_PENDING)
+ OnUrlRequestCompleted(request, num_bytes);
return;
}
@@ -368,14 +371,14 @@ bool CertNetFetcherImpl::Job::ConsumeBytesRead(URLRequest* request,
int num_bytes) {
if (num_bytes <= 0) {
// Error while reading, or EOF.
- OnUrlRequestCompleted(request);
+ OnUrlRequestCompleted(request, num_bytes);
return false;
}
// Enforce maximum size bound.
if (num_bytes + response_body_.size() > request_params_->max_response_bytes) {
- request->CancelWithError(ERR_FILE_TOO_BIG);
- OnUrlRequestCompleted(request);
+ int status = request->CancelWithError(ERR_FILE_TOO_BIG);
+ OnUrlRequestCompleted(request, status);
return false;
}
@@ -392,13 +395,14 @@ void CertNetFetcherImpl::Job::OnTimeout() {
OnJobCompleted();
}
-void CertNetFetcherImpl::Job::OnUrlRequestCompleted(URLRequest* request) {
+void CertNetFetcherImpl::Job::OnUrlRequestCompleted(URLRequest* request,
+ int net_error) {
DCHECK_EQ(request, url_request_.get());
- if (request->status().is_success())
+ if (net_error == OK)
result_net_error_ = OK;
else
- result_net_error_ = static_cast<Error>(request->status().error());
+ result_net_error_ = static_cast<Error>(net_error);
mmenke 2016/08/30 22:13:22 This whole thing is just: result_net_error_ = sta
maksims (do not use this acc) 2016/09/01 12:22:29 Done.
OnJobCompleted();
}
« no previous file with comments | « no previous file | net/cert_net/nss_ocsp.cc » ('j') | net/cert_net/nss_ocsp.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698