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

Unified Diff: net/base/sdch_dictionary_fetcher.cc

Issue 423813002: Sdch view for net-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change comments and netlog field name Created 6 years, 5 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/base/sdch_dictionary_fetcher.cc
diff --git a/net/base/sdch_dictionary_fetcher.cc b/net/base/sdch_dictionary_fetcher.cc
index aa2061eba8e1da490096104b492020374e1b4439..b949a544023091e67e602b481d49ae42ccb7e244 100644
--- a/net/base/sdch_dictionary_fetcher.cc
+++ b/net/base/sdch_dictionary_fetcher.cc
@@ -8,19 +8,22 @@
#include "base/compiler_specific.h"
#include "base/message_loop/message_loop.h"
#include "net/base/load_flags.h"
+#include "net/base/sdch_net_log_params.h"
#include "net/url_request/url_fetcher.h"
+#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_status.h"
namespace net {
-SdchDictionaryFetcher::SdchDictionaryFetcher(
- SdchManager* manager,
- URLRequestContextGetter* context)
+SdchDictionaryFetcher::SdchDictionaryFetcher(SdchManager* manager,
+ URLRequestContextGetter* context)
: manager_(manager),
weak_factory_(this),
task_is_pending_(false),
- context_(context) {
+ context_(context),
+ net_log_(BoundNetLog::Make(context_->GetURLRequestContext()->net_log(),
+ NetLog::SOURCE_SDCH_DICTIONARY_FETCHER)) {
DCHECK(CalledOnValidThread());
DCHECK(manager);
}
@@ -36,13 +39,13 @@ void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) {
// 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);
+ LogSdchProblem(SdchManager::DICTIONARY_ALREADY_SCHEDULED_TO_DOWNLOAD,
+ dictionary_url);
return;
}
if (attempted_load_.find(dictionary_url) != attempted_load_.end()) {
- SdchManager::SdchErrorRecovery(
- SdchManager::DICTIONARY_ALREADY_TRIED_TO_DOWNLOAD);
+ LogSdchProblem(SdchManager::DICTIONARY_ALREADY_TRIED_TO_DOWNLOAD,
+ dictionary_url);
return;
}
attempted_load_.insert(dictionary_url);
@@ -96,10 +99,21 @@ void SdchDictionaryFetcher::OnURLFetchComplete(
(source->GetStatus().status() == URLRequestStatus::SUCCESS)) {
std::string data;
source->GetResponseAsString(&data);
- manager_->AddSdchDictionary(data, source->GetURL());
+ SdchManager::AddResult rv =
+ manager_->AddSdchDictionary(data, source->GetURL());
+ if (rv.problem != SdchManager::PROBLEM_CODE_OK)
+ LogSdchProblem(rv.problem, source->GetURL());
}
current_fetch_.reset(NULL);
ScheduleDelayedRun();
}
+void SdchDictionaryFetcher::LogSdchProblem(SdchManager::ProblemCodes problem,
+ GURL url) const {
+ SdchManager::SdchErrorRecovery(problem);
+ net_log_.AddEvent(
+ NetLog::TYPE_SDCH_DICTIONARY_FETCH_ERROR,
+ base::Bind(&NetLogSdchDictionaryFetchProblemCallback, problem, &url));
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698