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

Unified Diff: net/base/sdch_manager.cc

Issue 380003002: Improve testing for SDCH. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to r288030. Created 6 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/base/sdch_manager.cc
diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc
index fee75e58f2fd11170213447a1fc911547e261ab4..38fc537a46b24c65d5a0168f15246adbea463d31 100644
--- a/net/base/sdch_manager.cc
+++ b/net/base/sdch_manager.cc
@@ -220,7 +220,8 @@ bool SdchManager::Dictionary::DomainMatch(const GURL& gurl,
}
//------------------------------------------------------------------------------
-SdchManager::SdchManager() {
+SdchManager::SdchManager()
+ : fetches_count_for_testing_(0) {
DCHECK(CalledOnValidThread());
}
@@ -251,9 +252,9 @@ void SdchManager::SdchErrorRecovery(ProblemCodes problem) {
UMA_HISTOGRAM_ENUMERATION("Sdch3.ProblemCodes_4", problem, MAX_PROBLEM_CODE);
}
-void SdchManager::set_sdch_fetcher(SdchFetcher* fetcher) {
+void SdchManager::set_sdch_fetcher(scoped_ptr<SdchFetcher> fetcher) {
DCHECK(CalledOnValidThread());
- fetcher_.reset(fetcher);
+ fetcher_ = fetcher.Pass();
}
// static
@@ -341,8 +342,10 @@ bool SdchManager::IsInSupportedDomain(const GURL& url) {
void SdchManager::FetchDictionary(const GURL& request_url,
const GURL& dictionary_url) {
DCHECK(CalledOnValidThread());
- if (CanFetchDictionary(request_url, dictionary_url) && fetcher_.get())
+ if (CanFetchDictionary(request_url, dictionary_url) && fetcher_.get()) {
+ ++fetches_count_for_testing_;
fetcher_->Schedule(dictionary_url);
+ }
}
bool SdchManager::CanFetchDictionary(const GURL& referring_url,
@@ -565,18 +568,8 @@ void SdchManager::UrlSafeBase64Encode(const std::string& input,
// Since this is only done during a dictionary load, and hashes are only 8
// characters, we just do the simple fixup, rather than rewriting the encoder.
base::Base64Encode(input, output);
- for (size_t i = 0; i < output->size(); ++i) {
- switch (output->data()[i]) {
- case '+':
- (*output)[i] = '-';
- continue;
- case '/':
- (*output)[i] = '_';
- continue;
- default:
- continue;
- }
- }
+ std::replace(output->begin(), output->end(), '+', '-');
+ std::replace(output->begin(), output->end(), '/', '_');
}
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698