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

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: Fixed Isolation test for ChromeOS. 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
« no previous file with comments | « net/base/sdch_manager.h ('k') | net/filter/mock_filter_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/sdch_manager.cc
diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc
index 19b1d76fdadb55a9022742a5d36c589d29ca3cc2..bd687970297c6642a8d8598e62a4e6773cff84d7 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());
}
@@ -250,9 +251,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
@@ -358,8 +359,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,
@@ -582,18 +585,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
« no previous file with comments | « net/base/sdch_manager.h ('k') | net/filter/mock_filter_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698