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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // functionality in this base (when the functionaity can be provided). | 42 // functionality in this base (when the functionaity can be provided). |
43 class SdchFetcher { | 43 class SdchFetcher { |
44 public: | 44 public: |
45 SdchFetcher() {} | 45 SdchFetcher() {} |
46 virtual ~SdchFetcher() {} | 46 virtual ~SdchFetcher() {} |
47 | 47 |
48 // The Schedule() method is called when there is a need to get a dictionary | 48 // The Schedule() method is called when there is a need to get a dictionary |
49 // from a server. The callee is responsible for getting that dictionary_text, | 49 // from a server. The callee is responsible for getting that dictionary_text, |
50 // and then calling back to AddSdchDictionary() to the SdchManager instance. | 50 // and then calling back to AddSdchDictionary() to the SdchManager instance. |
51 virtual void Schedule(const GURL& dictionary_url) = 0; | 51 virtual void Schedule(const GURL& dictionary_url) = 0; |
52 | |
53 // The Cancel() method is called to cancel all pending dictionary fetches. | |
54 // This is used for implementation of ClearData() below. | |
55 virtual void Cancel() = 0; | |
56 | |
57 private: | 52 private: |
58 DISALLOW_COPY_AND_ASSIGN(SdchFetcher); | 53 DISALLOW_COPY_AND_ASSIGN(SdchFetcher); |
59 }; | 54 }; |
60 | 55 |
61 //------------------------------------------------------------------------------ | 56 //------------------------------------------------------------------------------ |
62 | 57 |
63 class NET_EXPORT SdchManager : public NON_EXPORTED_BASE(base::NonThreadSafe) { | 58 class NET_EXPORT SdchManager : public NON_EXPORTED_BASE(base::NonThreadSafe) { |
64 public: | 59 public: |
65 // A list of errors that appeared and were either resolved, or used to turn | 60 // A list of errors that appeared and were either resolved, or used to turn |
66 // off sdch encoding. | 61 // off sdch encoding. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 const std::string path_; | 227 const std::string path_; |
233 const base::Time expiration_; // Implied by max-age. | 228 const base::Time expiration_; // Implied by max-age. |
234 const std::set<int> ports_; | 229 const std::set<int> ports_; |
235 | 230 |
236 DISALLOW_COPY_AND_ASSIGN(Dictionary); | 231 DISALLOW_COPY_AND_ASSIGN(Dictionary); |
237 }; | 232 }; |
238 | 233 |
239 SdchManager(); | 234 SdchManager(); |
240 ~SdchManager(); | 235 ~SdchManager(); |
241 | 236 |
242 // Clear data (for browser data removal). | |
243 void ClearData(); | |
244 | |
245 // Record stats on various errors. | 237 // Record stats on various errors. |
246 static void SdchErrorRecovery(ProblemCodes problem); | 238 static void SdchErrorRecovery(ProblemCodes problem); |
247 | 239 |
248 // Register a fetcher that this class can use to obtain dictionaries. | 240 // Register a fetcher that this class can use to obtain dictionaries. |
249 void set_sdch_fetcher(SdchFetcher* fetcher); | 241 void set_sdch_fetcher(SdchFetcher* fetcher); |
250 | 242 |
251 // Enables or disables SDCH compression. | 243 // Enables or disables SDCH compression. |
252 static void EnableSdchSupport(bool enabled); | 244 static void EnableSdchSupport(bool enabled); |
253 | 245 |
254 static bool sdch_enabled() { return g_sdch_enabled_; } | 246 static bool sdch_enabled() { return g_sdch_enabled_; } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 351 |
360 // An instance that can fetch a dictionary given a URL. | 352 // An instance that can fetch a dictionary given a URL. |
361 scoped_ptr<SdchFetcher> fetcher_; | 353 scoped_ptr<SdchFetcher> fetcher_; |
362 | 354 |
363 // List domains where decode failures have required disabling sdch, along with | 355 // List domains where decode failures have required disabling sdch, along with |
364 // count of how many additonal uses should be blacklisted. | 356 // count of how many additonal uses should be blacklisted. |
365 DomainCounter blacklisted_domains_; | 357 DomainCounter blacklisted_domains_; |
366 | 358 |
367 // Support exponential backoff in number of domain accesses before | 359 // Support exponential backoff in number of domain accesses before |
368 // blacklisting expires. | 360 // blacklisting expires. |
369 DomainCounter exponential_blacklist_count_; | 361 DomainCounter exponential_blacklist_count; |
370 | 362 |
371 // List of hostnames for which a latency experiment is allowed (because a | 363 // List of hostnames for which a latency experiment is allowed (because a |
372 // round trip test has recently passed). | 364 // round trip test has recently passed). |
373 ExperimentSet allow_latency_experiment_; | 365 ExperimentSet allow_latency_experiment_; |
374 | 366 |
375 DISALLOW_COPY_AND_ASSIGN(SdchManager); | 367 DISALLOW_COPY_AND_ASSIGN(SdchManager); |
376 }; | 368 }; |
377 | 369 |
378 } // namespace net | 370 } // namespace net |
379 | 371 |
380 #endif // NET_BASE_SDCH_MANAGER_H_ | 372 #endif // NET_BASE_SDCH_MANAGER_H_ |
OLD | NEW |