Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Provides global database of differential decompression dictionaries for the | 5 // Provides global database of differential decompression dictionaries for the |
| 6 // SDCH filter (processes sdch enconded content). | 6 // SDCH filter (processes sdch enconded content). |
| 7 | 7 |
| 8 // Exactly one instance of SdchManager is built, and all references are made | 8 // Exactly one instance of SdchManager is built, and all references are made |
| 9 // into that collection. | 9 // into that collection. |
| 10 // | 10 // |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 | 258 |
| 259 static bool secure_scheme_supported() { return g_secure_scheme_supported_; } | 259 static bool secure_scheme_supported() { return g_secure_scheme_supported_; } |
| 260 | 260 |
| 261 // Briefly prevent further advertising of SDCH on this domain (if SDCH is | 261 // Briefly prevent further advertising of SDCH on this domain (if SDCH is |
| 262 // enabled). After enough calls to IsInSupportedDomain() the blacklisting | 262 // enabled). After enough calls to IsInSupportedDomain() the blacklisting |
| 263 // will be removed. Additional blacklists take exponentially more calls | 263 // will be removed. Additional blacklists take exponentially more calls |
| 264 // to IsInSupportedDomain() before the blacklisting is undone. | 264 // to IsInSupportedDomain() before the blacklisting is undone. |
| 265 // Used when filter errors are found from a given domain, but it is plausible | 265 // Used when filter errors are found from a given domain, but it is plausible |
| 266 // that the cause is temporary (such as application startup, where cached | 266 // that the cause is temporary (such as application startup, where cached |
| 267 // entries are used, but a dictionary is not yet loaded). | 267 // entries are used, but a dictionary is not yet loaded). |
| 268 void BlacklistDomain(const GURL& url); | 268 void BlacklistDomain(const GURL& url, ProblemCodes blacklist_reason); |
| 269 | 269 |
| 270 // Used when SEVERE filter errors are found from a given domain, to prevent | 270 // Used when SEVERE filter errors are found from a given domain, to prevent |
| 271 // further use of SDCH on that domain. | 271 // further use of SDCH on that domain. |
| 272 void BlacklistDomainForever(const GURL& url); | 272 void BlacklistDomainForever(const GURL& url, ProblemCodes blacklist_reason); |
| 273 | 273 |
| 274 // Unit test only, this function resets enabling of sdch, and clears the | 274 // Unit test only, this function resets enabling of sdch, and clears the |
| 275 // blacklist. | 275 // blacklist. |
| 276 void ClearBlacklistings(); | 276 void ClearBlacklistings(); |
| 277 | 277 |
| 278 // Unit test only, this function resets the blacklisting count for a domain. | 278 // Unit test only, this function resets the blacklisting count for a domain. |
| 279 void ClearDomainBlacklisting(const std::string& domain); | 279 void ClearDomainBlacklisting(const std::string& domain); |
| 280 | 280 |
| 281 // Unit test only: indicate how many more times a domain will be blacklisted. | 281 // Unit test only: indicate how many more times a domain will be blacklisted. |
| 282 int BlackListDomainCount(const std::string& domain); | 282 int BlackListDomainCount(const std::string& domain); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 | 330 |
| 331 // For Latency testing only, we need to know if we've succeeded in doing a | 331 // For Latency testing only, we need to know if we've succeeded in doing a |
| 332 // round trip before starting our comparative tests. If ever we encounter | 332 // round trip before starting our comparative tests. If ever we encounter |
| 333 // problems with SDCH, we opt-out of the test unless/until we perform a | 333 // problems with SDCH, we opt-out of the test unless/until we perform a |
| 334 // complete SDCH decoding. | 334 // complete SDCH decoding. |
| 335 bool AllowLatencyExperiment(const GURL& url) const; | 335 bool AllowLatencyExperiment(const GURL& url) const; |
| 336 | 336 |
| 337 void SetAllowLatencyExperiment(const GURL& url, bool enable); | 337 void SetAllowLatencyExperiment(const GURL& url, bool enable); |
| 338 | 338 |
| 339 private: | 339 private: |
| 340 typedef std::map<std::string, int> DomainCounter; | 340 struct BlacklistInfo { |
| 341 int count; // # of times to refuse SDCH advertisement. | |
| 342 int exponential_count; // Current exponential backoff ratchet. | |
| 343 ProblemCodes reason; // Why domain was blacklisted. | |
| 344 | |
| 345 BlacklistInfo() | |
|
jar (doing other things)
2014/07/23 14:02:53
nit: constuctor should be listed before members.
Randy Smith (Not in Mondays)
2014/08/11 20:46:39
Done.
| |
| 346 : count(0), | |
| 347 exponential_count(0), | |
| 348 reason(MIN_PROBLEM_CODE) {} | |
| 349 }; | |
| 350 typedef std::map<std::string, BlacklistInfo> DomainBlacklistInfo; | |
| 341 typedef std::set<std::string> ExperimentSet; | 351 typedef std::set<std::string> ExperimentSet; |
| 342 | 352 |
| 343 // A map of dictionaries info indexed by the hash that the server provides. | 353 // A map of dictionaries info indexed by the hash that the server provides. |
| 344 typedef std::map<std::string, scoped_refptr<Dictionary> > DictionaryMap; | 354 typedef std::map<std::string, scoped_refptr<Dictionary> > DictionaryMap; |
| 345 | 355 |
| 346 // Support SDCH compression, by advertising in headers. | 356 // Support SDCH compression, by advertising in headers. |
| 347 static bool g_sdch_enabled_; | 357 static bool g_sdch_enabled_; |
| 348 | 358 |
| 349 // Support SDCH compression for HTTPS requests and responses. When supported, | 359 // Support SDCH compression for HTTPS requests and responses. When supported, |
| 350 // HTTPS applicable dictionaries MUST have been acquired securely via HTTPS. | 360 // HTTPS applicable dictionaries MUST have been acquired securely via HTTPS. |
| 351 static bool g_secure_scheme_supported_; | 361 static bool g_secure_scheme_supported_; |
| 352 | 362 |
| 353 // A simple implementation of a RFC 3548 "URL safe" base64 encoder. | 363 // A simple implementation of a RFC 3548 "URL safe" base64 encoder. |
| 354 static void UrlSafeBase64Encode(const std::string& input, | 364 static void UrlSafeBase64Encode(const std::string& input, |
| 355 std::string* output); | 365 std::string* output); |
| 356 DictionaryMap dictionaries_; | 366 DictionaryMap dictionaries_; |
| 357 | 367 |
| 358 // An instance that can fetch a dictionary given a URL. | 368 // An instance that can fetch a dictionary given a URL. |
| 359 scoped_ptr<SdchFetcher> fetcher_; | 369 scoped_ptr<SdchFetcher> fetcher_; |
| 360 | 370 |
| 361 // List domains where decode failures have required disabling sdch, along with | 371 // List domains where decode failures have required disabling sdch. |
| 362 // count of how many additonal uses should be blacklisted. | 372 DomainBlacklistInfo blacklisted_domains_; |
| 363 DomainCounter blacklisted_domains_; | |
| 364 | |
| 365 // Support exponential backoff in number of domain accesses before | |
| 366 // blacklisting expires. | |
| 367 DomainCounter exponential_blacklist_count_; | |
| 368 | 373 |
| 369 // List of hostnames for which a latency experiment is allowed (because a | 374 // List of hostnames for which a latency experiment is allowed (because a |
| 370 // round trip test has recently passed). | 375 // round trip test has recently passed). |
| 371 ExperimentSet allow_latency_experiment_; | 376 ExperimentSet allow_latency_experiment_; |
| 372 | 377 |
| 373 DISALLOW_COPY_AND_ASSIGN(SdchManager); | 378 DISALLOW_COPY_AND_ASSIGN(SdchManager); |
| 374 }; | 379 }; |
| 375 | 380 |
| 376 } // namespace net | 381 } // namespace net |
| 377 | 382 |
| 378 #endif // NET_BASE_SDCH_MANAGER_H_ | 383 #endif // NET_BASE_SDCH_MANAGER_H_ |
| OLD | NEW |