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

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 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/sdch_dictionary_fetcher.cc
diff --git a/net/url_request/sdch_dictionary_fetcher.cc b/net/url_request/sdch_dictionary_fetcher.cc
index 8d90f5f0ea2c433697b65cb4b860c757ff0ef5eb..70cf01b9b0a1b7ed6bc5f851cec0762dddafa3dc 100644
--- a/net/url_request/sdch_dictionary_fetcher.cc
+++ b/net/url_request/sdch_dictionary_fetcher.cc
@@ -32,8 +32,10 @@ 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) {
+ DCHECK_NE(ERR_IO_PENDING, bytes_read);
+
+ int rv = bytes_read;
+ if (rv < 0) {
rv = ERR_FAILED;
request->net_log().AddEventWithNetErrorCode(
NetLog::TYPE_SDCH_DICTIONARY_FETCH_IMPLIED_ERROR, rv);
@@ -155,28 +157,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 +188,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 +333,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 +350,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) {

Powered by Google App Engine
This is Rietveld 408576698