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

Unified Diff: net/url_request/sdch_dictionary_fetcher.cc

Issue 737943002: Update from https://crrev.com/304715 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/proxy/proxy_script_fetcher_impl.cc ('k') | net/url_request/url_fetcher_core.cc » ('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 5ac65efc96df2813918c298a7c41d1919d54d015..9aeed9a6237ef1624f10fb5cff5b0823d7d2fc4e 100644
--- a/net/url_request/sdch_dictionary_fetcher.cc
+++ b/net/url_request/sdch_dictionary_fetcher.cc
@@ -9,6 +9,7 @@
#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/compiler_specific.h"
+#include "base/profiler/scoped_tracker.h"
#include "base/thread_task_runner_handle.h"
#include "net/base/load_flags.h"
#include "net/base/sdch_net_log_params.h"
@@ -81,6 +82,11 @@ void SdchDictionaryFetcher::Cancel() {
}
void SdchDictionaryFetcher::OnResponseStarted(URLRequest* request) {
+ // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
+ tracked_objects::ScopedTracker tracking_profile(
+ FROM_HERE_WITH_EXPLICIT_FUNCTION(
+ "423948 SdchDictionaryFetcher::OnResponseStarted"));
+
DCHECK(CalledOnValidThread());
DCHECK_EQ(request, current_request_.get());
DCHECK_EQ(next_state_, STATE_REQUEST_STARTED);
@@ -99,6 +105,11 @@ void SdchDictionaryFetcher::OnResponseStarted(URLRequest* request) {
void SdchDictionaryFetcher::OnReadCompleted(URLRequest* request,
int bytes_read) {
+ // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
+ tracked_objects::ScopedTracker tracking_profile(
+ FROM_HERE_WITH_EXPLICIT_FUNCTION(
+ "423948 SdchDictionaryFetcher::OnReadCompleted"));
+
DCHECK(CalledOnValidThread());
DCHECK_EQ(request, current_request_.get());
DCHECK_EQ(next_state_, STATE_REQUEST_READING);
@@ -199,33 +210,29 @@ int SdchDictionaryFetcher::DoRead(int rv) {
next_state_ = STATE_REQUEST_READING;
int bytes_read = 0;
- if (!current_request_->Read(buffer_.get(), kBufferSize, &bytes_read)) {
- if (current_request_->status().is_io_pending())
- return ERR_IO_PENDING;
-
- if (current_request_->status().error() == OK) {
- // This "should never happen", but if it does the result will be
- // an infinite loop. It's not clear how to handle a read failure
- // without a promise to invoke the callback at some point in the future,
- // so the request is failed.
- SdchManager::SdchErrorRecovery(SDCH_DICTIONARY_FETCH_READ_FAILED);
- current_request_->net_log().AddEvent(
- NetLog::TYPE_SDCH_DICTIONARY_ERROR,
- base::Bind(&NetLogSdchDictionaryFetchProblemCallback,
- SDCH_DICTIONARY_FETCH_READ_FAILED, current_request_->url(),
- true));
- DLOG(FATAL)
- << "URLRequest::Read() returned false without IO pending or error!";
- return ERR_FAILED;
- }
-
- return current_request_->status().error();
+ current_request_->Read(buffer_.get(), kBufferSize, &bytes_read);
+ if (current_request_->status().is_io_pending())
+ return ERR_IO_PENDING;
+
+ if (bytes_read < 0 || !current_request_->status().is_success()) {
+ if (current_request_->status().error() != OK)
+ return current_request_->status().error();
+
+ // An error with request status of OK should not happen,
+ // but there's enough machinery underneath URLRequest::Read()
+ // that this routine checks for that case.
+ net::Error error =
+ current_request_->status().status() == URLRequestStatus::CANCELED ?
+ ERR_ABORTED : ERR_FAILED;
+ current_request_->net_log().AddEventWithNetErrorCode(
+ NetLog::TYPE_SDCH_DICTIONARY_FETCH_IMPLIED_ERROR, error);
+ return error;
}
- if (bytes_read != 0)
- dictionary_.append(buffer_->data(), bytes_read);
- else
+ if (bytes_read == 0)
next_state_ = STATE_REQUEST_COMPLETE;
+ else
+ dictionary_.append(buffer_->data(), bytes_read);
return OK;
}
« no previous file with comments | « net/proxy/proxy_script_fetcher_impl.cc ('k') | net/url_request/url_fetcher_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698