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 12 matching lines...) Expand all Loading... |
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 "googleurl/src/gurl.h" | 32 #include "googleurl/src/gurl.h" |
| 33 #include "net/base/net_api.h" |
33 | 34 |
34 namespace net { | 35 namespace net { |
35 | 36 |
36 //------------------------------------------------------------------------------ | 37 //------------------------------------------------------------------------------ |
37 // Create a public interface to help us load SDCH dictionaries. | 38 // Create a public interface to help us load SDCH dictionaries. |
38 // The SdchManager class allows registration to support this interface. | 39 // The SdchManager class allows registration to support this interface. |
39 // A browser may register a fetcher that is used by the dictionary managers to | 40 // A browser may register a fetcher that is used by the dictionary managers to |
40 // get data from a specified URL. This allows us to use very high level browser | 41 // get data from a specified URL. This allows us to use very high level browser |
41 // functionality in this base (when the functionaity can be provided). | 42 // functionality in this base (when the functionaity can be provided). |
42 class SdchFetcher { | 43 class SdchFetcher { |
43 public: | 44 public: |
44 SdchFetcher() {} | 45 SdchFetcher() {} |
45 virtual ~SdchFetcher() {} | 46 virtual ~SdchFetcher() {} |
46 | 47 |
47 // 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 |
48 // 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, |
49 // and then calling back to AddSdchDictionary() to the SdchManager instance. | 50 // and then calling back to AddSdchDictionary() to the SdchManager instance. |
50 virtual void Schedule(const GURL& dictionary_url) = 0; | 51 virtual void Schedule(const GURL& dictionary_url) = 0; |
51 private: | 52 private: |
52 DISALLOW_COPY_AND_ASSIGN(SdchFetcher); | 53 DISALLOW_COPY_AND_ASSIGN(SdchFetcher); |
53 }; | 54 }; |
54 | 55 |
55 //------------------------------------------------------------------------------ | 56 //------------------------------------------------------------------------------ |
56 | 57 |
57 class SdchManager { | 58 class NET_API SdchManager { |
58 public: | 59 public: |
59 // 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 |
60 // off sdch encoding. | 61 // off sdch encoding. |
61 enum ProblemCodes { | 62 enum ProblemCodes { |
62 MIN_PROBLEM_CODE, | 63 MIN_PROBLEM_CODE, |
63 | 64 |
64 // Content-encoding correction problems. | 65 // Content-encoding correction problems. |
65 ADDED_CONTENT_ENCODING = 1, | 66 ADDED_CONTENT_ENCODING = 1, |
66 FIXED_CONTENT_ENCODING = 2, | 67 FIXED_CONTENT_ENCODING = 2, |
67 FIXED_CONTENT_ENCODINGS = 3, | 68 FIXED_CONTENT_ENCODINGS = 3, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 MAX_PROBLEM_CODE // Used to bound histogram. | 155 MAX_PROBLEM_CODE // Used to bound histogram. |
155 }; | 156 }; |
156 | 157 |
157 // Use the following static limits to block DOS attacks until we implement | 158 // Use the following static limits to block DOS attacks until we implement |
158 // a cached dictionary evicition strategy. | 159 // a cached dictionary evicition strategy. |
159 static const size_t kMaxDictionarySize; | 160 static const size_t kMaxDictionarySize; |
160 static const size_t kMaxDictionaryCount; | 161 static const size_t kMaxDictionaryCount; |
161 | 162 |
162 // There is one instance of |Dictionary| for each memory-cached SDCH | 163 // There is one instance of |Dictionary| for each memory-cached SDCH |
163 // dictionary. | 164 // dictionary. |
164 class Dictionary : public base::RefCounted<Dictionary> { | 165 class NET_TEST Dictionary : public base::RefCounted<Dictionary> { |
165 public: | 166 public: |
166 // Sdch filters can get our text to use in decoding compressed data. | 167 // Sdch filters can get our text to use in decoding compressed data. |
167 const std::string& text() const { return text_; } | 168 const std::string& text() const { return text_; } |
168 | 169 |
169 private: | 170 private: |
170 friend class base::RefCounted<Dictionary>; | 171 friend class base::RefCounted<Dictionary>; |
171 friend class SdchManager; // Only manager can construct an instance. | 172 friend class SdchManager; // Only manager can construct an instance. |
172 FRIEND_TEST_ALL_PREFIXES(SdchFilterTest, PathMatch); | 173 FRIEND_TEST_ALL_PREFIXES(SdchFilterTest, PathMatch); |
173 | 174 |
174 // Construct a vc-diff usable dictionary from the dictionary_text starting | 175 // Construct a vc-diff usable dictionary from the dictionary_text starting |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 // List of hostnames for which a latency experiment is allowed (because a | 369 // List of hostnames for which a latency experiment is allowed (because a |
369 // round trip test has recently passed). | 370 // round trip test has recently passed). |
370 ExperimentSet allow_latency_experiment_; | 371 ExperimentSet allow_latency_experiment_; |
371 | 372 |
372 DISALLOW_COPY_AND_ASSIGN(SdchManager); | 373 DISALLOW_COPY_AND_ASSIGN(SdchManager); |
373 }; | 374 }; |
374 | 375 |
375 } // namespace net | 376 } // namespace net |
376 | 377 |
377 #endif // NET_BASE_SDCH_MANAGER_H_ | 378 #endif // NET_BASE_SDCH_MANAGER_H_ |
OLD | NEW |