| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 | 124 |
| 125 // Common decoded recovery methods. | 125 // Common decoded recovery methods. |
| 126 META_REFRESH_CACHED_RECOVERY = 80, // Probably startup tab loading. | 126 META_REFRESH_CACHED_RECOVERY = 80, // Probably startup tab loading. |
| 127 DISCARD_TENTATIVE_SDCH = 81, // Server decided not to use sdch. | 127 DISCARD_TENTATIVE_SDCH = 81, // Server decided not to use sdch. |
| 128 | 128 |
| 129 // Non SDCH problems, only accounted for to make stat counting complete | 129 // Non SDCH problems, only accounted for to make stat counting complete |
| 130 // (i.e., be able to be sure all dictionary advertisements are accounted | 130 // (i.e., be able to be sure all dictionary advertisements are accounted |
| 131 // for). | 131 // for). |
| 132 | 132 |
| 133 UNFLUSHED_CONTENT = 90, // Possible error in filter chaining. | 133 UNFLUSHED_CONTENT = 90, // Possible error in filter chaining. |
| 134 MISSING_TIME_STATS = 91, // Should never happen. | 134 // defunct = 91, // MISSING_TIME_STATS (Should never happen.) |
| 135 CACHE_DECODED = 92, // No timing stats recorded. | 135 CACHE_DECODED = 92, // No timing stats recorded. |
| 136 OVER_10_MINUTES = 93, // No timing stats will be recorded. | 136 // defunct = 93, // OVER_10_MINUTES (No timing stats recorded.) |
| 137 UNINITIALIZED = 94, // Filter never even got initialized. | 137 UNINITIALIZED = 94, // Filter never even got initialized. |
| 138 PRIOR_TO_DICTIONARY = 95, // We hadn't even parsed a dictionary selector. | 138 PRIOR_TO_DICTIONARY = 95, // We hadn't even parsed a dictionary selector. |
| 139 DECODE_ERROR = 96, // Something went wrong during decode. | 139 DECODE_ERROR = 96, // Something went wrong during decode. |
| 140 |
| 141 // Problem during the latency test. |
| 142 LATENCY_TEST_DISALLOWED = 100, // SDCH now failing, but it worked before! |
| 140 | 143 |
| 141 MAX_PROBLEM_CODE // Used to bound histogram. | 144 MAX_PROBLEM_CODE // Used to bound histogram. |
| 142 }; | 145 }; |
| 143 | 146 |
| 144 // Use the following static limits to block DOS attacks until we implement | 147 // Use the following static limits to block DOS attacks until we implement |
| 145 // a cached dictionary evicition strategy. | 148 // a cached dictionary evicition strategy. |
| 146 static const size_t kMaxDictionarySize; | 149 static const size_t kMaxDictionarySize; |
| 147 static const size_t kMaxDictionaryCount; | 150 static const size_t kMaxDictionaryCount; |
| 148 | 151 |
| 149 // There is one instance of |Dictionary| for each memory-cached SDCH | 152 // There is one instance of |Dictionary| for each memory-cached SDCH |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 // into memory. The list is a comma separated list of (client) hashes per | 298 // into memory. The list is a comma separated list of (client) hashes per |
| 296 // the SDCH spec. | 299 // the SDCH spec. |
| 297 void GetAvailDictionaryList(const GURL& target_url, std::string* list); | 300 void GetAvailDictionaryList(const GURL& target_url, std::string* list); |
| 298 | 301 |
| 299 // Construct the pair of hashes for client and server to identify an SDCH | 302 // Construct the pair of hashes for client and server to identify an SDCH |
| 300 // dictionary. This is only made public to facilitate unit testing, but is | 303 // dictionary. This is only made public to facilitate unit testing, but is |
| 301 // otherwise private | 304 // otherwise private |
| 302 static void GenerateHash(const std::string& dictionary_text, | 305 static void GenerateHash(const std::string& dictionary_text, |
| 303 std::string* client_hash, std::string* server_hash); | 306 std::string* client_hash, std::string* server_hash); |
| 304 | 307 |
| 308 // For Latency testing only, we need to know if we've succeeded in doing a |
| 309 // round trip before starting our comparative tests. If ever we encounter |
| 310 // problems with SDCH, we opt-out of the test unless/until we perform a |
| 311 // complete SDCH decoding. |
| 312 bool AllowLatencyExperiment(const GURL& url) const; |
| 313 |
| 314 void SetAllowLatencyExperiment(const GURL& url, bool enable); |
| 315 |
| 305 private: | 316 private: |
| 306 typedef std::map<const std::string, int> DomainCounter; | 317 typedef std::map<std::string, int> DomainCounter; |
| 318 typedef std::set<std::string> ExperimentSet; |
| 307 | 319 |
| 308 // A map of dictionaries info indexed by the hash that the server provides. | 320 // A map of dictionaries info indexed by the hash that the server provides. |
| 309 typedef std::map<std::string, Dictionary*> DictionaryMap; | 321 typedef std::map<std::string, Dictionary*> DictionaryMap; |
| 310 | 322 |
| 311 // The one global instance of that holds all the data. | 323 // The one global instance of that holds all the data. |
| 312 static SdchManager* global_; | 324 static SdchManager* global_; |
| 313 | 325 |
| 314 // A simple implementation of a RFC 3548 "URL safe" base64 encoder. | 326 // A simple implementation of a RFC 3548 "URL safe" base64 encoder. |
| 315 static void UrlSafeBase64Encode(const std::string& input, | 327 static void UrlSafeBase64Encode(const std::string& input, |
| 316 std::string* output); | 328 std::string* output); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 327 std::string supported_domain_; | 339 std::string supported_domain_; |
| 328 | 340 |
| 329 // List domains where decode failures have required disabling sdch, along with | 341 // List domains where decode failures have required disabling sdch, along with |
| 330 // count of how many additonal uses should be blacklisted. | 342 // count of how many additonal uses should be blacklisted. |
| 331 DomainCounter blacklisted_domains_; | 343 DomainCounter blacklisted_domains_; |
| 332 | 344 |
| 333 // Support exponential backoff in number of domain accesses before | 345 // Support exponential backoff in number of domain accesses before |
| 334 // blacklisting expires. | 346 // blacklisting expires. |
| 335 DomainCounter exponential_blacklist_count; | 347 DomainCounter exponential_blacklist_count; |
| 336 | 348 |
| 349 // List of hostnames for which a latency experiment is allowed (because a |
| 350 // round trip test has recently passed). |
| 351 ExperimentSet allow_latency_experiment_; |
| 352 |
| 337 DISALLOW_COPY_AND_ASSIGN(SdchManager); | 353 DISALLOW_COPY_AND_ASSIGN(SdchManager); |
| 338 }; | 354 }; |
| 339 | 355 |
| 340 #endif // NET_BASE_SDCH_MANAGER_H_ | 356 #endif // NET_BASE_SDCH_MANAGER_H_ |
| OLD | NEW |