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 11 matching lines...) Expand all Loading... |
22 #pragma once | 22 #pragma once |
23 | 23 |
24 #include <map> | 24 #include <map> |
25 #include <set> | 25 #include <set> |
26 #include <string> | 26 #include <string> |
27 | 27 |
28 #include "base/gtest_prod_util.h" | 28 #include "base/gtest_prod_util.h" |
29 #include "base/memory/ref_counted.h" | 29 #include "base/memory/ref_counted.h" |
30 #include "base/memory/scoped_ptr.h" | 30 #include "base/memory/scoped_ptr.h" |
31 #include "base/time.h" | 31 #include "base/time.h" |
| 32 #include "base/threading/non_thread_safe.h" |
32 #include "googleurl/src/gurl.h" | 33 #include "googleurl/src/gurl.h" |
33 #include "net/base/net_export.h" | 34 #include "net/base/net_export.h" |
34 | 35 |
35 namespace net { | 36 namespace net { |
36 | 37 |
37 //------------------------------------------------------------------------------ | 38 //------------------------------------------------------------------------------ |
38 // Create a public interface to help us load SDCH dictionaries. | 39 // Create a public interface to help us load SDCH dictionaries. |
39 // The SdchManager class allows registration to support this interface. | 40 // The SdchManager class allows registration to support this interface. |
40 // A browser may register a fetcher that is used by the dictionary managers to | 41 // A browser may register a fetcher that is used by the dictionary managers to |
41 // get data from a specified URL. This allows us to use very high level browser | 42 // get data from a specified URL. This allows us to use very high level browser |
42 // functionality in this base (when the functionaity can be provided). | 43 // functionality in this base (when the functionaity can be provided). |
43 class SdchFetcher { | 44 class SdchFetcher { |
44 public: | 45 public: |
45 SdchFetcher() {} | 46 SdchFetcher() {} |
46 virtual ~SdchFetcher() {} | 47 virtual ~SdchFetcher() {} |
47 | 48 |
48 // The Schedule() method is called when there is a need to get a dictionary | 49 // 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, | 50 // from a server. The callee is responsible for getting that dictionary_text, |
50 // and then calling back to AddSdchDictionary() to the SdchManager instance. | 51 // and then calling back to AddSdchDictionary() to the SdchManager instance. |
51 virtual void Schedule(const GURL& dictionary_url) = 0; | 52 virtual void Schedule(const GURL& dictionary_url) = 0; |
52 private: | 53 private: |
53 DISALLOW_COPY_AND_ASSIGN(SdchFetcher); | 54 DISALLOW_COPY_AND_ASSIGN(SdchFetcher); |
54 }; | 55 }; |
55 | 56 |
56 //------------------------------------------------------------------------------ | 57 //------------------------------------------------------------------------------ |
57 | 58 |
58 class NET_EXPORT SdchManager { | 59 class NET_EXPORT SdchManager : public NON_EXPORTED_BASE(base::NonThreadSafe) { |
59 public: | 60 public: |
60 // A list of errors that appeared and were either resolved, or used to turn | 61 // A list of errors that appeared and were either resolved, or used to turn |
61 // off sdch encoding. | 62 // off sdch encoding. |
62 enum ProblemCodes { | 63 enum ProblemCodes { |
63 MIN_PROBLEM_CODE, | 64 MIN_PROBLEM_CODE, |
64 | 65 |
65 // Content-encoding correction problems. | 66 // Content-encoding correction problems. |
66 ADDED_CONTENT_ENCODING = 1, | 67 ADDED_CONTENT_ENCODING = 1, |
67 FIXED_CONTENT_ENCODING = 2, | 68 FIXED_CONTENT_ENCODING = 2, |
68 FIXED_CONTENT_ENCODINGS = 3, | 69 FIXED_CONTENT_ENCODINGS = 3, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // Discontinue fetching of dictionaries, as we're now shutting down. | 238 // Discontinue fetching of dictionaries, as we're now shutting down. |
238 static void Shutdown(); | 239 static void Shutdown(); |
239 | 240 |
240 // Provide access to the single instance of this class. | 241 // Provide access to the single instance of this class. |
241 static SdchManager* Global(); | 242 static SdchManager* Global(); |
242 | 243 |
243 // Record stats on various errors. | 244 // Record stats on various errors. |
244 static void SdchErrorRecovery(ProblemCodes problem); | 245 static void SdchErrorRecovery(ProblemCodes problem); |
245 | 246 |
246 // Register a fetcher that this class can use to obtain dictionaries. | 247 // Register a fetcher that this class can use to obtain dictionaries. |
247 void set_sdch_fetcher(SdchFetcher* fetcher) { fetcher_.reset(fetcher); } | 248 void set_sdch_fetcher(SdchFetcher* fetcher); |
248 | 249 |
249 // Enables or disables SDCH compression. | 250 // Enables or disables SDCH compression. |
250 static void EnableSdchSupport(bool enabled); | 251 static void EnableSdchSupport(bool enabled); |
251 | 252 |
252 static bool sdch_enabled() { return g_sdch_enabled_; } | 253 static bool sdch_enabled() { return g_sdch_enabled_; } |
253 | 254 |
254 // Briefly prevent further advertising of SDCH on this domain (if SDCH is | 255 // Briefly prevent further advertising of SDCH on this domain (if SDCH is |
255 // enabled). After enough calls to IsInSupportedDomain() the blacklisting | 256 // enabled). After enough calls to IsInSupportedDomain() the blacklisting |
256 // will be removed. Additional blacklists take exponentially more calls | 257 // will be removed. Additional blacklists take exponentially more calls |
257 // to IsInSupportedDomain() before the blacklisting is undone. | 258 // to IsInSupportedDomain() before the blacklisting is undone. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 // List of hostnames for which a latency experiment is allowed (because a | 364 // List of hostnames for which a latency experiment is allowed (because a |
364 // round trip test has recently passed). | 365 // round trip test has recently passed). |
365 ExperimentSet allow_latency_experiment_; | 366 ExperimentSet allow_latency_experiment_; |
366 | 367 |
367 DISALLOW_COPY_AND_ASSIGN(SdchManager); | 368 DISALLOW_COPY_AND_ASSIGN(SdchManager); |
368 }; | 369 }; |
369 | 370 |
370 } // namespace net | 371 } // namespace net |
371 | 372 |
372 #endif // NET_BASE_SDCH_MANAGER_H_ | 373 #endif // NET_BASE_SDCH_MANAGER_H_ |
OLD | NEW |