| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/base/sdch_manager.h" | 5 #include "net/base/sdch_manager.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 // TODO(jar): Redirects in dictionary fetches might plausibly be problematic, | 111 // TODO(jar): Redirects in dictionary fetches might plausibly be problematic, |
| 112 // and hence the conservative approach is to not allow any redirects (if there | 112 // and hence the conservative approach is to not allow any redirects (if there |
| 113 // were any... then don't allow the dictionary to be set). | 113 // were any... then don't allow the dictionary to be set). |
| 114 | 114 |
| 115 if (domain.empty()) { | 115 if (domain.empty()) { |
| 116 SdchErrorRecovery(DICTIONARY_MISSING_DOMAIN_SPECIFIER); | 116 SdchErrorRecovery(DICTIONARY_MISSING_DOMAIN_SPECIFIER); |
| 117 return false; // Domain is required. | 117 return false; // Domain is required. |
| 118 } | 118 } |
| 119 if (registry_controlled_domains::GetDomainAndRegistry( | 119 if (registry_controlled_domains::GetDomainAndRegistry( |
| 120 domain, | 120 domain, registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES) |
| 121 registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES).empty()) { | 121 .empty()) { |
| 122 SdchErrorRecovery(DICTIONARY_SPECIFIES_TOP_LEVEL_DOMAIN); | 122 SdchErrorRecovery(DICTIONARY_SPECIFIES_TOP_LEVEL_DOMAIN); |
| 123 return false; // domain was a TLD. | 123 return false; // domain was a TLD. |
| 124 } | 124 } |
| 125 if (!Dictionary::DomainMatch(dictionary_url, domain)) { | 125 if (!Dictionary::DomainMatch(dictionary_url, domain)) { |
| 126 SdchErrorRecovery(DICTIONARY_DOMAIN_NOT_MATCHING_SOURCE_URL); | 126 SdchErrorRecovery(DICTIONARY_DOMAIN_NOT_MATCHING_SOURCE_URL); |
| 127 return false; | 127 return false; |
| 128 } | 128 } |
| 129 | 129 |
| 130 std::string referrer_url_host = dictionary_url.host(); | 130 std::string referrer_url_host = dictionary_url.host(); |
| 131 size_t postfix_domain_index = referrer_url_host.rfind(domain); | 131 size_t postfix_domain_index = referrer_url_host.rfind(domain); |
| 132 // See if it is indeed a postfix, or just an internal string. | 132 // See if it is indeed a postfix, or just an internal string. |
| 133 if (referrer_url_host.size() == postfix_domain_index + domain.size()) { | 133 if (referrer_url_host.size() == postfix_domain_index + domain.size()) { |
| 134 // It is a postfix... so check to see if there's a dot in the prefix. | 134 // It is a postfix... so check to see if there's a dot in the prefix. |
| 135 size_t end_of_host_index = referrer_url_host.find_first_of('.'); | 135 size_t end_of_host_index = referrer_url_host.find_first_of('.'); |
| 136 if (referrer_url_host.npos != end_of_host_index && | 136 if (referrer_url_host.npos != end_of_host_index && |
| 137 end_of_host_index < postfix_domain_index) { | 137 end_of_host_index < postfix_domain_index) { |
| 138 SdchErrorRecovery(DICTIONARY_REFERER_URL_HAS_DOT_IN_PREFIX); | 138 SdchErrorRecovery(DICTIONARY_REFERER_URL_HAS_DOT_IN_PREFIX); |
| 139 return false; | 139 return false; |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 if (!ports.empty() | 143 if (!ports.empty() && 0 == ports.count(dictionary_url.EffectiveIntPort())) { |
| 144 && 0 == ports.count(dictionary_url.EffectiveIntPort())) { | |
| 145 SdchErrorRecovery(DICTIONARY_PORT_NOT_MATCHING_SOURCE_URL); | 144 SdchErrorRecovery(DICTIONARY_PORT_NOT_MATCHING_SOURCE_URL); |
| 146 return false; | 145 return false; |
| 147 } | 146 } |
| 148 return true; | 147 return true; |
| 149 } | 148 } |
| 150 | 149 |
| 151 // static | 150 // static |
| 152 bool SdchManager::Dictionary::CanUse(const GURL& referring_url) { | 151 bool SdchManager::Dictionary::CanUse(const GURL& referring_url) { |
| 153 if (!SdchManager::Global()->IsInSupportedDomain(referring_url)) | 152 if (!SdchManager::Global()->IsInSupportedDomain(referring_url)) |
| 154 return false; | 153 return false; |
| 155 /* | 154 /* |
| 156 1. The request URL's host name domain-matches the Domain attribute of the | 155 1. The request URL's host name domain-matches the Domain attribute of the |
| 157 dictionary. | 156 dictionary. |
| 158 2. If the dictionary has a Port attribute, the request port is one of the | 157 2. If the dictionary has a Port attribute, the request port is one of the |
| 159 ports listed in the Port attribute. | 158 ports listed in the Port attribute. |
| 160 3. The request URL path-matches the path attribute of the dictionary. | 159 3. The request URL path-matches the path attribute of the dictionary. |
| 161 4. The request is not an HTTPS request. | 160 4. The request is not an HTTPS request. |
| 162 We can override (ignore) item (4) only when we have explicitly enabled | 161 We can override (ignore) item (4) only when we have explicitly enabled |
| 163 HTTPS support AND dictionary has been acquired over HTTPS. | 162 HTTPS support AND dictionary has been acquired over HTTPS. |
| 164 */ | 163 */ |
| 165 if (!DomainMatch(referring_url, domain_)) { | 164 if (!DomainMatch(referring_url, domain_)) { |
| 166 SdchErrorRecovery(DICTIONARY_FOUND_HAS_WRONG_DOMAIN); | 165 SdchErrorRecovery(DICTIONARY_FOUND_HAS_WRONG_DOMAIN); |
| 167 return false; | 166 return false; |
| 168 } | 167 } |
| 169 if (!ports_.empty() | 168 if (!ports_.empty() && 0 == ports_.count(referring_url.EffectiveIntPort())) { |
| 170 && 0 == ports_.count(referring_url.EffectiveIntPort())) { | |
| 171 SdchErrorRecovery(DICTIONARY_FOUND_HAS_WRONG_PORT_LIST); | 169 SdchErrorRecovery(DICTIONARY_FOUND_HAS_WRONG_PORT_LIST); |
| 172 return false; | 170 return false; |
| 173 } | 171 } |
| 174 if (path_.size() && !PathMatch(referring_url.path(), path_)) { | 172 if (path_.size() && !PathMatch(referring_url.path(), path_)) { |
| 175 SdchErrorRecovery(DICTIONARY_FOUND_HAS_WRONG_PATH); | 173 SdchErrorRecovery(DICTIONARY_FOUND_HAS_WRONG_PATH); |
| 176 return false; | 174 return false; |
| 177 } | 175 } |
| 178 if (!SdchManager::secure_scheme_supported() && | 176 if (!SdchManager::secure_scheme_supported() && |
| 179 referring_url.SchemeIsSecure()) { | 177 referring_url.SchemeIsSecure()) { |
| 180 SdchErrorRecovery(DICTIONARY_FOUND_HAS_WRONG_SCHEME); | 178 SdchErrorRecovery(DICTIONARY_FOUND_HAS_WRONG_SCHEME); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 DictionaryMap::iterator it = dictionaries_.begin(); | 231 DictionaryMap::iterator it = dictionaries_.begin(); |
| 234 it->second->Release(); | 232 it->second->Release(); |
| 235 dictionaries_.erase(it->first); | 233 dictionaries_.erase(it->first); |
| 236 } | 234 } |
| 237 global_ = NULL; | 235 global_ = NULL; |
| 238 } | 236 } |
| 239 | 237 |
| 240 // static | 238 // static |
| 241 void SdchManager::Shutdown() { | 239 void SdchManager::Shutdown() { |
| 242 EnableSdchSupport(false); | 240 EnableSdchSupport(false); |
| 243 if (!global_ ) | 241 if (!global_) |
| 244 return; | 242 return; |
| 245 global_->set_sdch_fetcher(NULL); | 243 global_->set_sdch_fetcher(NULL); |
| 246 } | 244 } |
| 247 | 245 |
| 248 // static | 246 // static |
| 249 SdchManager* SdchManager::Global() { | 247 SdchManager* SdchManager::Global() { |
| 250 return global_; | 248 return global_; |
| 251 } | 249 } |
| 252 | 250 |
| 253 // static | 251 // static |
| (...skipping 11 matching lines...) Expand all Loading... |
| 265 g_sdch_enabled_ = enabled; | 263 g_sdch_enabled_ = enabled; |
| 266 } | 264 } |
| 267 | 265 |
| 268 // static | 266 // static |
| 269 void SdchManager::EnableSecureSchemeSupport(bool enabled) { | 267 void SdchManager::EnableSecureSchemeSupport(bool enabled) { |
| 270 g_secure_scheme_supported_ = enabled; | 268 g_secure_scheme_supported_ = enabled; |
| 271 } | 269 } |
| 272 | 270 |
| 273 // static | 271 // static |
| 274 void SdchManager::BlacklistDomain(const GURL& url) { | 272 void SdchManager::BlacklistDomain(const GURL& url) { |
| 275 if (!global_ ) | 273 if (!global_) |
| 276 return; | 274 return; |
| 277 global_->SetAllowLatencyExperiment(url, false); | 275 global_->SetAllowLatencyExperiment(url, false); |
| 278 | 276 |
| 279 std::string domain(StringToLowerASCII(url.host())); | 277 std::string domain(StringToLowerASCII(url.host())); |
| 280 int count = global_->blacklisted_domains_[domain]; | 278 int count = global_->blacklisted_domains_[domain]; |
| 281 if (count > 0) | 279 if (count > 0) |
| 282 return; // Domain is already blacklisted. | 280 return; // Domain is already blacklisted. |
| 283 | 281 |
| 284 count = 1 + 2 * global_->exponential_blacklist_count[domain]; | 282 count = 1 + 2 * global_->exponential_blacklist_count[domain]; |
| 285 if (count > 0) | 283 if (count > 0) |
| 286 global_->exponential_blacklist_count[domain] = count; | 284 global_->exponential_blacklist_count[domain] = count; |
| 287 else | 285 else |
| 288 count = INT_MAX; | 286 count = INT_MAX; |
| 289 | 287 |
| 290 global_->blacklisted_domains_[domain] = count; | 288 global_->blacklisted_domains_[domain] = count; |
| 291 } | 289 } |
| 292 | 290 |
| 293 // static | 291 // static |
| 294 void SdchManager::BlacklistDomainForever(const GURL& url) { | 292 void SdchManager::BlacklistDomainForever(const GURL& url) { |
| 295 if (!global_ ) | 293 if (!global_) |
| 296 return; | 294 return; |
| 297 global_->SetAllowLatencyExperiment(url, false); | 295 global_->SetAllowLatencyExperiment(url, false); |
| 298 | 296 |
| 299 std::string domain(StringToLowerASCII(url.host())); | 297 std::string domain(StringToLowerASCII(url.host())); |
| 300 global_->exponential_blacklist_count[domain] = INT_MAX; | 298 global_->exponential_blacklist_count[domain] = INT_MAX; |
| 301 global_->blacklisted_domains_[domain] = INT_MAX; | 299 global_->blacklisted_domains_[domain] = INT_MAX; |
| 302 } | 300 } |
| 303 | 301 |
| 304 // static | 302 // static |
| 305 void SdchManager::ClearBlacklistings() { | 303 void SdchManager::ClearBlacklistings() { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 323 // static | 321 // static |
| 324 int SdchManager::BlacklistDomainExponential(const std::string& domain) { | 322 int SdchManager::BlacklistDomainExponential(const std::string& domain) { |
| 325 if (Global()->exponential_blacklist_count.end() == | 323 if (Global()->exponential_blacklist_count.end() == |
| 326 Global()->exponential_blacklist_count.find(domain)) | 324 Global()->exponential_blacklist_count.find(domain)) |
| 327 return 0; | 325 return 0; |
| 328 return Global()->exponential_blacklist_count[StringToLowerASCII(domain)]; | 326 return Global()->exponential_blacklist_count[StringToLowerASCII(domain)]; |
| 329 } | 327 } |
| 330 | 328 |
| 331 bool SdchManager::IsInSupportedDomain(const GURL& url) { | 329 bool SdchManager::IsInSupportedDomain(const GURL& url) { |
| 332 DCHECK(CalledOnValidThread()); | 330 DCHECK(CalledOnValidThread()); |
| 333 if (!g_sdch_enabled_ ) | 331 if (!g_sdch_enabled_) |
| 334 return false; | 332 return false; |
| 335 | 333 |
| 336 if (blacklisted_domains_.empty()) | 334 if (blacklisted_domains_.empty()) |
| 337 return true; | 335 return true; |
| 338 | 336 |
| 339 std::string domain(StringToLowerASCII(url.host())); | 337 std::string domain(StringToLowerASCII(url.host())); |
| 340 DomainCounter::iterator it = blacklisted_domains_.find(domain); | 338 DomainCounter::iterator it = blacklisted_domains_.find(domain); |
| 341 if (blacklisted_domains_.end() == it) | 339 if (blacklisted_domains_.end() == it) |
| 342 return true; | 340 return true; |
| 343 | 341 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 // than current SDCH spec when needed, and justified by security audit. | 385 // than current SDCH spec when needed, and justified by security audit. |
| 388 if (!referring_url.SchemeIsHTTPOrHTTPS()) { | 386 if (!referring_url.SchemeIsHTTPOrHTTPS()) { |
| 389 SdchErrorRecovery(DICTIONARY_SELECTED_FROM_NON_HTTP); | 387 SdchErrorRecovery(DICTIONARY_SELECTED_FROM_NON_HTTP); |
| 390 return false; | 388 return false; |
| 391 } | 389 } |
| 392 | 390 |
| 393 return true; | 391 return true; |
| 394 } | 392 } |
| 395 | 393 |
| 396 bool SdchManager::AddSdchDictionary(const std::string& dictionary_text, | 394 bool SdchManager::AddSdchDictionary(const std::string& dictionary_text, |
| 397 const GURL& dictionary_url) { | 395 const GURL& dictionary_url) { |
| 398 DCHECK(CalledOnValidThread()); | 396 DCHECK(CalledOnValidThread()); |
| 399 std::string client_hash; | 397 std::string client_hash; |
| 400 std::string server_hash; | 398 std::string server_hash; |
| 401 GenerateHash(dictionary_text, &client_hash, &server_hash); | 399 GenerateHash(dictionary_text, &client_hash, &server_hash); |
| 402 if (dictionaries_.find(server_hash) != dictionaries_.end()) { | 400 if (dictionaries_.find(server_hash) != dictionaries_.end()) { |
| 403 SdchErrorRecovery(DICTIONARY_ALREADY_LOADED); | 401 SdchErrorRecovery(DICTIONARY_ALREADY_LOADED); |
| 404 return false; // Already loaded. | 402 return false; // Already loaded. |
| 405 } | 403 } |
| 406 | 404 |
| 407 std::string domain, path; | 405 std::string domain, path; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 426 | 424 |
| 427 size_t colon_index = dictionary_text.find(':', line_start); | 425 size_t colon_index = dictionary_text.find(':', line_start); |
| 428 if (std::string::npos == colon_index) { | 426 if (std::string::npos == colon_index) { |
| 429 SdchErrorRecovery(DICTIONARY_HEADER_LINE_MISSING_COLON); | 427 SdchErrorRecovery(DICTIONARY_HEADER_LINE_MISSING_COLON); |
| 430 return false; // Illegal line missing a colon. | 428 return false; // Illegal line missing a colon. |
| 431 } | 429 } |
| 432 | 430 |
| 433 if (colon_index > line_end) | 431 if (colon_index > line_end) |
| 434 break; | 432 break; |
| 435 | 433 |
| 436 size_t value_start = dictionary_text.find_first_not_of(" \t", | 434 size_t value_start = |
| 437 colon_index + 1); | 435 dictionary_text.find_first_not_of(" \t", colon_index + 1); |
| 438 if (std::string::npos != value_start) { | 436 if (std::string::npos != value_start) { |
| 439 if (value_start >= line_end) | 437 if (value_start >= line_end) |
| 440 break; | 438 break; |
| 441 std::string name(dictionary_text, line_start, colon_index - line_start); | 439 std::string name(dictionary_text, line_start, colon_index - line_start); |
| 442 std::string value(dictionary_text, value_start, line_end - value_start); | 440 std::string value(dictionary_text, value_start, line_end - value_start); |
| 443 name = StringToLowerASCII(name); | 441 name = StringToLowerASCII(name); |
| 444 if (name == "domain") { | 442 if (name == "domain") { |
| 445 domain = value; | 443 domain = value; |
| 446 } else if (name == "path") { | 444 } else if (name == "path") { |
| 447 path = value; | 445 path = value; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 477 return false; | 475 return false; |
| 478 } | 476 } |
| 479 if (kMaxDictionaryCount <= dictionaries_.size()) { | 477 if (kMaxDictionaryCount <= dictionaries_.size()) { |
| 480 SdchErrorRecovery(DICTIONARY_COUNT_EXCEEDED); | 478 SdchErrorRecovery(DICTIONARY_COUNT_EXCEEDED); |
| 481 return false; | 479 return false; |
| 482 } | 480 } |
| 483 | 481 |
| 484 UMA_HISTOGRAM_COUNTS("Sdch3.Dictionary size loaded", dictionary_text.size()); | 482 UMA_HISTOGRAM_COUNTS("Sdch3.Dictionary size loaded", dictionary_text.size()); |
| 485 DVLOG(1) << "Loaded dictionary with client hash " << client_hash | 483 DVLOG(1) << "Loaded dictionary with client hash " << client_hash |
| 486 << " and server hash " << server_hash; | 484 << " and server hash " << server_hash; |
| 487 Dictionary* dictionary = | 485 Dictionary* dictionary = new Dictionary(dictionary_text, |
| 488 new Dictionary(dictionary_text, header_end + 2, client_hash, | 486 header_end + 2, |
| 489 dictionary_url, domain, path, expiration, ports); | 487 client_hash, |
| 488 dictionary_url, |
| 489 domain, |
| 490 path, |
| 491 expiration, |
| 492 ports); |
| 490 dictionary->AddRef(); | 493 dictionary->AddRef(); |
| 491 dictionaries_[server_hash] = dictionary; | 494 dictionaries_[server_hash] = dictionary; |
| 492 return true; | 495 return true; |
| 493 } | 496 } |
| 494 | 497 |
| 495 void SdchManager::GetVcdiffDictionary(const std::string& server_hash, | 498 void SdchManager::GetVcdiffDictionary(const std::string& server_hash, |
| 496 const GURL& referring_url, Dictionary** dictionary) { | 499 const GURL& referring_url, |
| 500 Dictionary** dictionary) { |
| 497 DCHECK(CalledOnValidThread()); | 501 DCHECK(CalledOnValidThread()); |
| 498 *dictionary = NULL; | 502 *dictionary = NULL; |
| 499 DictionaryMap::iterator it = dictionaries_.find(server_hash); | 503 DictionaryMap::iterator it = dictionaries_.find(server_hash); |
| 500 if (it == dictionaries_.end()) { | 504 if (it == dictionaries_.end()) { |
| 501 return; | 505 return; |
| 502 } | 506 } |
| 503 Dictionary* matching_dictionary = it->second; | 507 Dictionary* matching_dictionary = it->second; |
| 504 if (!matching_dictionary->CanUse(referring_url)) | 508 if (!matching_dictionary->CanUse(referring_url)) |
| 505 return; | 509 return; |
| 506 *dictionary = matching_dictionary; | 510 *dictionary = matching_dictionary; |
| 507 } | 511 } |
| 508 | 512 |
| 509 // TODO(jar): If we have evictions from the dictionaries_, then we need to | 513 // TODO(jar): If we have evictions from the dictionaries_, then we need to |
| 510 // change this interface to return a list of reference counted Dictionary | 514 // change this interface to return a list of reference counted Dictionary |
| 511 // instances that can be used if/when a server specifies one. | 515 // instances that can be used if/when a server specifies one. |
| 512 void SdchManager::GetAvailDictionaryList(const GURL& target_url, | 516 void SdchManager::GetAvailDictionaryList(const GURL& target_url, |
| 513 std::string* list) { | 517 std::string* list) { |
| 514 DCHECK(CalledOnValidThread()); | 518 DCHECK(CalledOnValidThread()); |
| 515 int count = 0; | 519 int count = 0; |
| 516 for (DictionaryMap::iterator it = dictionaries_.begin(); | 520 for (DictionaryMap::iterator it = dictionaries_.begin(); |
| 517 it != dictionaries_.end(); ++it) { | 521 it != dictionaries_.end(); |
| 522 ++it) { |
| 518 if (!it->second->CanAdvertise(target_url)) | 523 if (!it->second->CanAdvertise(target_url)) |
| 519 continue; | 524 continue; |
| 520 ++count; | 525 ++count; |
| 521 if (!list->empty()) | 526 if (!list->empty()) |
| 522 list->append(","); | 527 list->append(","); |
| 523 list->append(it->second->client_hash()); | 528 list->append(it->second->client_hash()); |
| 524 } | 529 } |
| 525 // Watch to see if we have corrupt or numerous dictionaries. | 530 // Watch to see if we have corrupt or numerous dictionaries. |
| 526 if (count > 0) | 531 if (count > 0) |
| 527 UMA_HISTOGRAM_COUNTS("Sdch3.Advertisement_Count", count); | 532 UMA_HISTOGRAM_COUNTS("Sdch3.Advertisement_Count", count); |
| 528 } | 533 } |
| 529 | 534 |
| 530 // static | 535 // static |
| 531 void SdchManager::GenerateHash(const std::string& dictionary_text, | 536 void SdchManager::GenerateHash(const std::string& dictionary_text, |
| 532 std::string* client_hash, std::string* server_hash) { | 537 std::string* client_hash, |
| 538 std::string* server_hash) { |
| 533 char binary_hash[32]; | 539 char binary_hash[32]; |
| 534 crypto::SHA256HashString(dictionary_text, binary_hash, sizeof(binary_hash)); | 540 crypto::SHA256HashString(dictionary_text, binary_hash, sizeof(binary_hash)); |
| 535 | 541 |
| 536 std::string first_48_bits(&binary_hash[0], 6); | 542 std::string first_48_bits(&binary_hash[0], 6); |
| 537 std::string second_48_bits(&binary_hash[6], 6); | 543 std::string second_48_bits(&binary_hash[6], 6); |
| 538 UrlSafeBase64Encode(first_48_bits, client_hash); | 544 UrlSafeBase64Encode(first_48_bits, client_hash); |
| 539 UrlSafeBase64Encode(second_48_bits, server_hash); | 545 UrlSafeBase64Encode(second_48_bits, server_hash); |
| 540 | 546 |
| 541 DCHECK_EQ(server_hash->length(), 8u); | 547 DCHECK_EQ(server_hash->length(), 8u); |
| 542 DCHECK_EQ(client_hash->length(), 8u); | 548 DCHECK_EQ(client_hash->length(), 8u); |
| 543 } | 549 } |
| 544 | 550 |
| 545 //------------------------------------------------------------------------------ | 551 //------------------------------------------------------------------------------ |
| 546 // Methods for supporting latency experiments. | 552 // Methods for supporting latency experiments. |
| 547 | 553 |
| 548 bool SdchManager::AllowLatencyExperiment(const GURL& url) const { | 554 bool SdchManager::AllowLatencyExperiment(const GURL& url) const { |
| 549 DCHECK(CalledOnValidThread()); | 555 DCHECK(CalledOnValidThread()); |
| 550 return allow_latency_experiment_.end() != | 556 return allow_latency_experiment_.end() != |
| 551 allow_latency_experiment_.find(url.host()); | 557 allow_latency_experiment_.find(url.host()); |
| 552 } | 558 } |
| 553 | 559 |
| 554 void SdchManager::SetAllowLatencyExperiment(const GURL& url, bool enable) { | 560 void SdchManager::SetAllowLatencyExperiment(const GURL& url, bool enable) { |
| 555 DCHECK(CalledOnValidThread()); | 561 DCHECK(CalledOnValidThread()); |
| 556 if (enable) { | 562 if (enable) { |
| 557 allow_latency_experiment_.insert(url.host()); | 563 allow_latency_experiment_.insert(url.host()); |
| 558 return; | 564 return; |
| 559 } | 565 } |
| 560 ExperimentSet::iterator it = allow_latency_experiment_.find(url.host()); | 566 ExperimentSet::iterator it = allow_latency_experiment_.find(url.host()); |
| 561 if (allow_latency_experiment_.end() == it) | 567 if (allow_latency_experiment_.end() == it) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 578 case '/': | 584 case '/': |
| 579 (*output)[i] = '_'; | 585 (*output)[i] = '_'; |
| 580 continue; | 586 continue; |
| 581 default: | 587 default: |
| 582 continue; | 588 continue; |
| 583 } | 589 } |
| 584 } | 590 } |
| 585 } | 591 } |
| 586 | 592 |
| 587 } // namespace net | 593 } // namespace net |
| OLD | NEW |