Chromium Code Reviews| Index: net/base/sdch_manager.cc |
| diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc |
| index 0f31d5cee8ad84e4ea2acacd8c06a52b786847b2..6c4250b6eabed3e0fa011a45e0ad349f600040a6 100644 |
| --- a/net/base/sdch_manager.cc |
| +++ b/net/base/sdch_manager.cc |
| @@ -139,8 +139,8 @@ bool SdchManager::Dictionary::CanSet(const std::string& domain, |
| return false; // Domain is required. |
| } |
| if (registry_controlled_domains::GetDomainAndRegistry( |
| - domain, |
| - registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES).empty()) { |
| + domain, registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES) |
| + .empty()) { |
|
Ryan Sleevi
2014/10/11 02:04:47
Bug in clang-format
It prioritized keeping a para
jkarlin
2014/10/16 00:19:32
Is that in the style guide anywhere? I can't seem
mmenke
2014/10/16 00:25:54
Technically no, but preferring not to split an arg
Peter Kasting
2014/10/30 20:20:59
I would phrase this as "breaking at whitespace is
jkarlin
2014/10/30 23:44:47
Filed https://code.google.com/p/chromium/issues/de
jkarlin
2014/11/11 19:01:44
Still waiting on this one.
|
| SdchErrorRecovery(DICTIONARY_SPECIFIES_TOP_LEVEL_DOMAIN); |
| return false; // domain was a TLD. |
| } |
| @@ -155,15 +155,14 @@ bool SdchManager::Dictionary::CanSet(const std::string& domain, |
| if (referrer_url_host.size() == postfix_domain_index + domain.size()) { |
| // It is a postfix... so check to see if there's a dot in the prefix. |
| size_t end_of_host_index = referrer_url_host.find_first_of('.'); |
| - if (referrer_url_host.npos != end_of_host_index && |
| + if (referrer_url_host.npos != end_of_host_index && |
| end_of_host_index < postfix_domain_index) { |
| SdchErrorRecovery(DICTIONARY_REFERER_URL_HAS_DOT_IN_PREFIX); |
| return false; |
| } |
| } |
| - if (!ports.empty() |
| - && 0 == ports.count(dictionary_url.EffectiveIntPort())) { |
| + if (!ports.empty() && 0 == ports.count(dictionary_url.EffectiveIntPort())) { |
| SdchErrorRecovery(DICTIONARY_PORT_NOT_MATCHING_SOURCE_URL); |
| return false; |
| } |
| @@ -187,8 +186,7 @@ bool SdchManager::Dictionary::CanUse(const GURL& referring_url) { |
| SdchErrorRecovery(DICTIONARY_FOUND_HAS_WRONG_DOMAIN); |
| return false; |
| } |
| - if (!ports_.empty() |
| - && 0 == ports_.count(referring_url.EffectiveIntPort())) { |
| + if (!ports_.empty() && 0 == ports_.count(referring_url.EffectiveIntPort())) { |
| SdchErrorRecovery(DICTIONARY_FOUND_HAS_WRONG_PORT_LIST); |
| return false; |
| } |
| @@ -241,8 +239,7 @@ bool SdchManager::Dictionary::DomainMatch(const GURL& gurl, |
| } |
| //------------------------------------------------------------------------------ |
| -SdchManager::SdchManager() |
| - : fetches_count_for_testing_(0) { |
| +SdchManager::SdchManager() : fetches_count_for_testing_(0) { |
| DCHECK(CalledOnValidThread()); |
| } |
| @@ -324,8 +321,8 @@ void SdchManager::ClearBlacklistings() { |
| } |
| void SdchManager::ClearDomainBlacklisting(const std::string& domain) { |
| - BlacklistInfo* blacklist_info = &blacklisted_domains_[ |
| - base::StringToLowerASCII(domain)]; |
| + BlacklistInfo* blacklist_info = |
| + &blacklisted_domains_[base::StringToLowerASCII(domain)]; |
| blacklist_info->count = 0; |
| blacklist_info->reason = MIN_PROBLEM_CODE; |
| } |
| @@ -348,7 +345,7 @@ int SdchManager::BlacklistDomainExponential(const std::string& domain) { |
| bool SdchManager::IsInSupportedDomain(const GURL& url) { |
| DCHECK(CalledOnValidThread()); |
| - if (!g_sdch_enabled_ ) |
| + if (!g_sdch_enabled_) |
| return false; |
| if (!secure_scheme_supported() && url.SchemeIsSecure()) |
| @@ -362,8 +359,8 @@ bool SdchManager::IsInSupportedDomain(const GURL& url) { |
| if (blacklisted_domains_.end() == it || it->second.count == 0) |
| return true; |
| - UMA_HISTOGRAM_ENUMERATION("Sdch3.BlacklistReason", it->second.reason, |
| - MAX_PROBLEM_CODE); |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Sdch3.BlacklistReason", it->second.reason, MAX_PROBLEM_CODE); |
| SdchErrorRecovery(DOMAIN_BLACKLIST_INCLUDES_TARGET); |
| int count = it->second.count - 1; |
| @@ -421,10 +418,9 @@ bool SdchManager::CanFetchDictionary(const GURL& referring_url, |
| return true; |
| } |
| -void SdchManager::GetVcdiffDictionary( |
| - const std::string& server_hash, |
| - const GURL& referring_url, |
| - scoped_refptr<Dictionary>* dictionary) { |
| +void SdchManager::GetVcdiffDictionary(const std::string& server_hash, |
| + const GURL& referring_url, |
| + scoped_refptr<Dictionary>* dictionary) { |
| DCHECK(CalledOnValidThread()); |
| *dictionary = NULL; |
| DictionaryMap::iterator it = dictionaries_.find(server_hash); |
| @@ -447,7 +443,8 @@ void SdchManager::GetAvailDictionaryList(const GURL& target_url, |
| DCHECK(CalledOnValidThread()); |
| int count = 0; |
| for (DictionaryMap::iterator it = dictionaries_.begin(); |
| - it != dictionaries_.end(); ++it) { |
| + it != dictionaries_.end(); |
| + ++it) { |
| if (!IsInSupportedDomain(target_url)) |
| continue; |
| if (!it->second->CanAdvertise(target_url)) |
| @@ -464,7 +461,8 @@ void SdchManager::GetAvailDictionaryList(const GURL& target_url, |
| // static |
| void SdchManager::GenerateHash(const std::string& dictionary_text, |
| - std::string* client_hash, std::string* server_hash) { |
| + std::string* client_hash, |
| + std::string* server_hash) { |
| char binary_hash[32]; |
| crypto::SHA256HashString(dictionary_text, binary_hash, sizeof(binary_hash)); |
| @@ -483,7 +481,7 @@ void SdchManager::GenerateHash(const std::string& dictionary_text, |
| bool SdchManager::AllowLatencyExperiment(const GURL& url) const { |
| DCHECK(CalledOnValidThread()); |
| return allow_latency_experiment_.end() != |
| - allow_latency_experiment_.find(url.host()); |
| + allow_latency_experiment_.find(url.host()); |
| } |
| void SdchManager::SetAllowLatencyExperiment(const GURL& url, bool enable) { |
| @@ -500,14 +498,14 @@ void SdchManager::SetAllowLatencyExperiment(const GURL& url, bool enable) { |
| } |
| void SdchManager::AddSdchDictionary(const std::string& dictionary_text, |
| - const GURL& dictionary_url) { |
| + const GURL& dictionary_url) { |
| DCHECK(CalledOnValidThread()); |
| std::string client_hash; |
| std::string server_hash; |
| GenerateHash(dictionary_text, &client_hash, &server_hash); |
| if (dictionaries_.find(server_hash) != dictionaries_.end()) { |
| SdchErrorRecovery(DICTIONARY_ALREADY_LOADED); |
| - return; // Already loaded. |
| + return; // Already loaded. |
| } |
| std::string domain, path; |
| @@ -516,13 +514,13 @@ void SdchManager::AddSdchDictionary(const std::string& dictionary_text, |
| if (dictionary_text.empty()) { |
| SdchErrorRecovery(DICTIONARY_HAS_NO_TEXT); |
| - return; // Missing header. |
| + return; // Missing header. |
| } |
| size_t header_end = dictionary_text.find("\n\n"); |
| if (std::string::npos == header_end) { |
| SdchErrorRecovery(DICTIONARY_HAS_NO_HEADER); |
| - return; // Missing header. |
| + return; // Missing header. |
| } |
| size_t line_start = 0; // Start of line being parsed. |
| while (1) { |
| @@ -533,14 +531,14 @@ void SdchManager::AddSdchDictionary(const std::string& dictionary_text, |
| size_t colon_index = dictionary_text.find(':', line_start); |
| if (std::string::npos == colon_index) { |
| SdchErrorRecovery(DICTIONARY_HEADER_LINE_MISSING_COLON); |
| - return; // Illegal line missing a colon. |
| + return; // Illegal line missing a colon. |
| } |
| if (colon_index > line_end) |
| break; |
| - size_t value_start = dictionary_text.find_first_not_of(" \t", |
| - colon_index + 1); |
| + size_t value_start = |
| + dictionary_text.find_first_not_of(" \t", colon_index + 1); |
| if (std::string::npos != value_start) { |
| if (value_start >= line_end) |
| break; |
| @@ -597,10 +595,14 @@ void SdchManager::AddSdchDictionary(const std::string& dictionary_text, |
| UMA_HISTOGRAM_COUNTS("Sdch3.Dictionary size loaded", dictionary_text.size()); |
| DVLOG(1) << "Loaded dictionary with client hash " << client_hash |
| << " and server hash " << server_hash; |
| - Dictionary* dictionary = |
| - new Dictionary(dictionary_text, header_end + 2, client_hash, |
| - dictionary_url_normalized, domain, |
| - path, expiration, ports); |
| + Dictionary* dictionary = new Dictionary(dictionary_text, |
| + header_end + 2, |
| + client_hash, |
| + dictionary_url_normalized, |
| + domain, |
| + path, |
| + expiration, |
| + ports); |
| dictionaries_[server_hash] = dictionary; |
| return; |
| } |