| Index: net/base/sdch_dictionary_fetcher.cc
|
| diff --git a/net/base/sdch_dictionary_fetcher.cc b/net/base/sdch_dictionary_fetcher.cc
|
| index 8d08b9a678afabacd828ee0b8efb70989362fabf..7dd70bb72cc21702a2db60009b512740714d1d61 100644
|
| --- a/net/base/sdch_dictionary_fetcher.cc
|
| +++ b/net/base/sdch_dictionary_fetcher.cc
|
| @@ -11,6 +11,7 @@
|
| #include "base/compiler_specific.h"
|
| #include "base/thread_task_runner_handle.h"
|
| #include "net/base/load_flags.h"
|
| +#include "net/base/sdch_net_log_params.h"
|
| #include "net/url_request/url_request_context.h"
|
| #include "net/url_request/url_request_status.h"
|
| #include "net/url_request/url_request_throttler_manager.h"
|
| @@ -40,22 +41,18 @@ SdchDictionaryFetcher::~SdchDictionaryFetcher() {
|
| DCHECK(CalledOnValidThread());
|
| }
|
|
|
| -void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) {
|
| +bool SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) {
|
| DCHECK(CalledOnValidThread());
|
|
|
| // Avoid pushing duplicate copy onto queue. We may fetch this url again later
|
| // and get a different dictionary, but there is no reason to have it in the
|
| // queue twice at one time.
|
| - if (!fetch_queue_.empty() && fetch_queue_.back() == dictionary_url) {
|
| - SdchManager::SdchErrorRecovery(
|
| - SdchManager::DICTIONARY_ALREADY_SCHEDULED_TO_DOWNLOAD);
|
| - return;
|
| - }
|
| - if (attempted_load_.find(dictionary_url) != attempted_load_.end()) {
|
| - SdchManager::SdchErrorRecovery(
|
| - SdchManager::DICTIONARY_ALREADY_TRIED_TO_DOWNLOAD);
|
| - return;
|
| - }
|
| + if (!fetch_queue_.empty() && fetch_queue_.back() == dictionary_url)
|
| + return false;
|
| +
|
| + if (attempted_load_.find(dictionary_url) != attempted_load_.end())
|
| + return false;
|
| +
|
| attempted_load_.insert(dictionary_url);
|
| fetch_queue_.push(dictionary_url);
|
|
|
| @@ -65,6 +62,8 @@ void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) {
|
| // and Schedule() is only called from user code, so this call to DoLoop()
|
| // does not require an |if (in_loop_) return;| guard.
|
| DoLoop(OK);
|
| +
|
| + return true;
|
| }
|
|
|
| void SdchDictionaryFetcher::Cancel() {
|
| @@ -162,6 +161,7 @@ int SdchDictionaryFetcher::DoDispatchRequest(int rv) {
|
| fetch_queue_.front(), IDLE, this, NULL);
|
| current_request_->SetLoadFlags(LOAD_DO_NOT_SEND_COOKIES |
|
| LOAD_DO_NOT_SAVE_COOKIES);
|
| + current_request_->net_log().AddEvent(NetLog::TYPE_SDCH_DICTIONARY_FETCH);
|
| buffer_ = new IOBuffer(kBufferSize);
|
| fetch_queue_.pop();
|
|
|
| @@ -208,7 +208,7 @@ int SdchDictionaryFetcher::DoRead(int rv) {
|
| // 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(SdchManager::DICTIONARY_FETCH_READ_FAILED);
|
| + LogDictionaryFetchError(SDCH_DICTIONARY_FETCH_READ_FAILED);
|
| DLOG(FATAL) <<
|
| "URLRequest::Read() returned false without IO pending or error!";
|
| return ERR_FAILED;
|
| @@ -229,8 +229,12 @@ int SdchDictionaryFetcher::DoCompleteRequest(int rv) {
|
| DCHECK(CalledOnValidThread());
|
|
|
| // If the dictionary was successfully fetched, add it to the manager.
|
| - if (rv == OK)
|
| - consumer_->AddSdchDictionary(dictionary_, current_request_->url());
|
| + if (rv == OK) {
|
| + SdchProblemCode problem =
|
| + consumer_->AddSdchDictionary(dictionary_, current_request_->url());
|
| + if (problem != SDCH_OK)
|
| + LogDictionaryFetchError(problem);
|
| + }
|
|
|
| current_request_.reset();
|
| buffer_ = NULL;
|
| @@ -241,4 +245,15 @@ int SdchDictionaryFetcher::DoCompleteRequest(int rv) {
|
| return OK;
|
| }
|
|
|
| +void SdchDictionaryFetcher::LogDictionaryFetchError(SdchProblemCode error) {
|
| + CHECK(current_request_.get());
|
| + SdchManager::SdchErrorRecovery(error);
|
| + current_request_->net_log().AddEvent(
|
| + NetLog::TYPE_SDCH_DICTIONARY_ERROR,
|
| + base::Bind(&NetLogSdchDictionaryFetchProblemCallback,
|
| + error,
|
| + current_request_->url(),
|
| + true));
|
| +}
|
| +
|
| } // namespace net
|
|
|