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 |
52 private: | 57 private: |
53 DISALLOW_COPY_AND_ASSIGN(SdchFetcher); | 58 DISALLOW_COPY_AND_ASSIGN(SdchFetcher); |
54 }; | 59 }; |
55 | 60 |
56 //------------------------------------------------------------------------------ | 61 //------------------------------------------------------------------------------ |
57 | 62 |
58 class NET_EXPORT SdchManager : public NON_EXPORTED_BASE(base::NonThreadSafe) { | 63 class NET_EXPORT SdchManager : public NON_EXPORTED_BASE(base::NonThreadSafe) { |
59 public: | 64 public: |
60 // A list of errors that appeared and were either resolved, or used to turn | 65 // A list of errors that appeared and were either resolved, or used to turn |
61 // off sdch encoding. | 66 // off sdch encoding. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 const std::string path_; | 232 const std::string path_; |
228 const base::Time expiration_; // Implied by max-age. | 233 const base::Time expiration_; // Implied by max-age. |
229 const std::set<int> ports_; | 234 const std::set<int> ports_; |
230 | 235 |
231 DISALLOW_COPY_AND_ASSIGN(Dictionary); | 236 DISALLOW_COPY_AND_ASSIGN(Dictionary); |
232 }; | 237 }; |
233 | 238 |
234 SdchManager(); | 239 SdchManager(); |
235 ~SdchManager(); | 240 ~SdchManager(); |
236 | 241 |
| 242 // Clear data (for browser data removal). |
| 243 void ClearData(); |
| 244 |
237 // Record stats on various errors. | 245 // Record stats on various errors. |
238 static void SdchErrorRecovery(ProblemCodes problem); | 246 static void SdchErrorRecovery(ProblemCodes problem); |
239 | 247 |
240 // Register a fetcher that this class can use to obtain dictionaries. | 248 // Register a fetcher that this class can use to obtain dictionaries. |
241 void set_sdch_fetcher(SdchFetcher* fetcher); | 249 void set_sdch_fetcher(SdchFetcher* fetcher); |
242 | 250 |
243 // Enables or disables SDCH compression. | 251 // Enables or disables SDCH compression. |
244 static void EnableSdchSupport(bool enabled); | 252 static void EnableSdchSupport(bool enabled); |
245 | 253 |
246 static bool sdch_enabled() { return g_sdch_enabled_; } | 254 static bool sdch_enabled() { return g_sdch_enabled_; } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // complete SDCH decoding. | 336 // complete SDCH decoding. |
329 bool AllowLatencyExperiment(const GURL& url) const; | 337 bool AllowLatencyExperiment(const GURL& url) const; |
330 | 338 |
331 void SetAllowLatencyExperiment(const GURL& url, bool enable); | 339 void SetAllowLatencyExperiment(const GURL& url, bool enable); |
332 | 340 |
333 private: | 341 private: |
334 typedef std::map<std::string, int> DomainCounter; | 342 typedef std::map<std::string, int> DomainCounter; |
335 typedef std::set<std::string> ExperimentSet; | 343 typedef std::set<std::string> ExperimentSet; |
336 | 344 |
337 // A map of dictionaries info indexed by the hash that the server provides. | 345 // A map of dictionaries info indexed by the hash that the server provides. |
338 typedef std::map<std::string, Dictionary*> DictionaryMap; | 346 typedef std::map<std::string, scoped_refptr<Dictionary> > DictionaryMap; |
339 | 347 |
340 // Support SDCH compression, by advertising in headers. | 348 // Support SDCH compression, by advertising in headers. |
341 static bool g_sdch_enabled_; | 349 static bool g_sdch_enabled_; |
342 | 350 |
343 // Support SDCH compression for HTTPS requests and responses. When supported, | 351 // Support SDCH compression for HTTPS requests and responses. When supported, |
344 // HTTPS applicable dictionaries MUST have been acquired securely via HTTPS. | 352 // HTTPS applicable dictionaries MUST have been acquired securely via HTTPS. |
345 static bool g_secure_scheme_supported_; | 353 static bool g_secure_scheme_supported_; |
346 | 354 |
347 // A simple implementation of a RFC 3548 "URL safe" base64 encoder. | 355 // A simple implementation of a RFC 3548 "URL safe" base64 encoder. |
348 static void UrlSafeBase64Encode(const std::string& input, | 356 static void UrlSafeBase64Encode(const std::string& input, |
349 std::string* output); | 357 std::string* output); |
350 DictionaryMap dictionaries_; | 358 DictionaryMap dictionaries_; |
351 | 359 |
352 // An instance that can fetch a dictionary given a URL. | 360 // An instance that can fetch a dictionary given a URL. |
353 scoped_ptr<SdchFetcher> fetcher_; | 361 scoped_ptr<SdchFetcher> fetcher_; |
354 | 362 |
355 // List domains where decode failures have required disabling sdch, along with | 363 // List domains where decode failures have required disabling sdch, along with |
356 // count of how many additonal uses should be blacklisted. | 364 // count of how many additonal uses should be blacklisted. |
357 DomainCounter blacklisted_domains_; | 365 DomainCounter blacklisted_domains_; |
358 | 366 |
359 // Support exponential backoff in number of domain accesses before | 367 // Support exponential backoff in number of domain accesses before |
360 // blacklisting expires. | 368 // blacklisting expires. |
361 DomainCounter exponential_blacklist_count; | 369 DomainCounter exponential_blacklist_count_; |
362 | 370 |
363 // List of hostnames for which a latency experiment is allowed (because a | 371 // List of hostnames for which a latency experiment is allowed (because a |
364 // round trip test has recently passed). | 372 // round trip test has recently passed). |
365 ExperimentSet allow_latency_experiment_; | 373 ExperimentSet allow_latency_experiment_; |
366 | 374 |
367 DISALLOW_COPY_AND_ASSIGN(SdchManager); | 375 DISALLOW_COPY_AND_ASSIGN(SdchManager); |
368 }; | 376 }; |
369 | 377 |
370 } // namespace net | 378 } // namespace net |
371 | 379 |
372 #endif // NET_BASE_SDCH_MANAGER_H_ | 380 #endif // NET_BASE_SDCH_MANAGER_H_ |
OLD | NEW |