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

Unified Diff: net/url_request/sdch_dictionary_fetcher.cc

Issue 2329903002: Make net/sdch to use new URLRequest::Read and its modified delegate methods. (Closed)
Patch Set: 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') | no next file » | 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 c632d85059e4b9a289fdc256c6df342991d99672..75ab2afcc3d7c5f777d76c90fb23835d6b3262e3 100644
--- a/net/url_request/sdch_dictionary_fetcher.cc
+++ b/net/url_request/sdch_dictionary_fetcher.cc
@@ -32,17 +32,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(
NetLogEventType::SDCH_DICTIONARY_FETCH_IMPLIED_ERROR, rv);
}
- if (rv == OK)
- rv = bytes_read;
-
return rv;
}
@@ -156,28 +154,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,
@@ -186,6 +185,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()));
}
@@ -330,9 +330,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());
@@ -348,7 +347,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') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698