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

Unified Diff: net/url_request/sdch_dictionary_fetcher.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/sdch_dictionary_fetcher.h ('k') | net/url_request/url_fetcher_core.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/sdch_dictionary_fetcher.cc
diff --git a/net/url_request/sdch_dictionary_fetcher.cc b/net/url_request/sdch_dictionary_fetcher.cc
index 8d90f5f0ea2c433697b65cb4b860c757ff0ef5eb..eae6440ffc597c48f2272376efacd96a453d2cfc 100644
--- a/net/url_request/sdch_dictionary_fetcher.cc
+++ b/net/url_request/sdch_dictionary_fetcher.cc
@@ -31,17 +31,15 @@ const int kBufferSize = 4096;
// Map the bytes_read result from a read attempt and a URLRequest's
// status into a single net return value.
-int GetReadResult(int bytes_read, const URLRequest* request) {
- int rv = request->status().error();
- if (request->status().is_success() && bytes_read < 0) {
+int GetReadResult(int rv, const URLRequest* request) {
+ DCHECK_NE(ERR_IO_PENDING, rv);
+
+ if (rv < 0) {
rv = ERR_FAILED;
request->net_log().AddEventWithNetErrorCode(
NetLog::TYPE_SDCH_DICTIONARY_FETCH_IMPLIED_ERROR, rv);
}
- if (rv == OK)
- rv = bytes_read;
-
return rv;
}
@@ -155,28 +153,29 @@ void SdchDictionaryFetcher::OnReceivedRedirect(
DoLoop(OK);
}
-void SdchDictionaryFetcher::OnResponseStarted(URLRequest* request) {
+void SdchDictionaryFetcher::OnResponseStarted(URLRequest* request,
+ int net_error) {
DCHECK(CalledOnValidThread());
DCHECK_EQ(request, current_request_.get());
DCHECK_EQ(next_state_, STATE_SEND_REQUEST_PENDING);
DCHECK(!in_loop_);
+ DCHECK_NE(ERR_IO_PENDING, net_error);
// Confirm that the response isn't a stale read from the cache (as
// may happen in the reload case). If the response was not retrieved over
// HTTP, it is presumed to be fresh.
HttpResponseHeaders* response_headers = request->response_headers();
- int result = request->status().error();
- if (result == OK && response_headers) {
+ if (net_error == OK && response_headers) {
ValidationType validation_type = response_headers->RequiresValidation(
request->response_info().request_time,
request->response_info().response_time, base::Time::Now());
// TODO(rdsmith): Maybe handle VALIDATION_ASYNCHRONOUS by queueing
// a non-reload request for the dictionary.
if (validation_type != VALIDATION_NONE)
- result = ERR_FAILED;
+ net_error = ERR_FAILED;
}
- DoLoop(result);
+ DoLoop(net_error);
}
void SdchDictionaryFetcher::OnReadCompleted(URLRequest* request,
@@ -185,6 +184,7 @@ void SdchDictionaryFetcher::OnReadCompleted(URLRequest* request,
DCHECK_EQ(request, current_request_.get());
DCHECK_EQ(next_state_, STATE_READ_BODY_COMPLETE);
DCHECK(!in_loop_);
+ DCHECK_NE(ERR_IO_PENDING, bytes_read);
DoLoop(GetReadResult(bytes_read, current_request_.get()));
}
@@ -329,9 +329,8 @@ int SdchDictionaryFetcher::DoReadBody(int rv) {
}
next_state_ = STATE_READ_BODY_COMPLETE;
- int bytes_read = 0;
- current_request_->Read(buffer_.get(), kBufferSize, &bytes_read);
- if (current_request_->status().is_io_pending())
+ int bytes_read = current_request_->Read(buffer_.get(), kBufferSize);
+ if (bytes_read == ERR_IO_PENDING)
return ERR_IO_PENDING;
return GetReadResult(bytes_read, current_request_.get());
@@ -347,7 +346,7 @@ int SdchDictionaryFetcher::DoReadBodyComplete(int rv) {
return OK;
}
- DCHECK(current_request_->status().is_success());
+ DCHECK_GE(rv, 0);
// Data; append to the dictionary and look for more data.
if (rv > 0) {
« no previous file with comments | « net/url_request/sdch_dictionary_fetcher.h ('k') | net/url_request/url_fetcher_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698