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 #ifndef NET_BASE_SDCH_MANAGER_H_ | 5 #ifndef NET_BASE_SDCH_MANAGER_H_ |
6 #define NET_BASE_SDCH_MANAGER_H_ | 6 #define NET_BASE_SDCH_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | |
11 | 12 |
12 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
16 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
20 | 21 |
21 namespace net { | 22 namespace net { |
22 | 23 |
23 class SdchObserver; | 24 class SdchObserver; |
24 | 25 |
25 // Provides global database of differential decompression dictionaries for the | 26 // Provides global database of differential decompression dictionaries for the |
26 // SDCH filter (processes sdch enconded content). | 27 // SDCH filter (processes sdch enconded content). |
27 // | 28 // |
28 // The SdchManager maintains a collection of memory resident dictionaries. It | 29 // The SdchManager maintains a collection of memory resident dictionaries. It |
29 // can find a dictionary (based on a server specification of a hash), store a | 30 // can find a dictionary (based on a server specification of a hash), store a |
30 // dictionary, and make judgements about what URLs can use, set, etc. a | 31 // dictionary, and make judgements about what URLs can use, set, etc. a |
31 // dictionary. | 32 // dictionary. |
32 | 33 |
33 // These dictionaries are acquired over the net, and include a header | 34 // These dictionaries are acquired over the net, and include a header |
34 // (containing metadata) as well as a VCDIFF dictionary (for use by a VCDIFF | 35 // (containing metadata) as well as a VCDIFF dictionary (for use by a VCDIFF |
35 // module) to decompress data. | 36 // module) to decompress data. |
36 class NET_EXPORT SdchManager { | 37 class NET_EXPORT SdchManager { |
37 public: | 38 public: |
39 class DictionarySet; | |
40 | |
38 // A list of errors that appeared and were either resolved, or used to turn | 41 // A list of errors that appeared and were either resolved, or used to turn |
39 // off sdch encoding. | 42 // off sdch encoding. |
40 enum ProblemCodes { | 43 enum ProblemCodes { |
41 MIN_PROBLEM_CODE, | 44 OK, |
Ryan Sleevi
2014/11/14 03:21:25
NO_PROBLEM? (to avoid confusion with net::OK)
Randy Smith (Not in Mondays)
2014/11/17 17:04:22
I'm going to say that this issue will be moot by t
| |
42 | 45 |
43 // Content-encoding correction problems. | 46 // Content-encoding correction problems. |
44 ADDED_CONTENT_ENCODING = 1, | 47 ADDED_CONTENT_ENCODING = 1, |
45 FIXED_CONTENT_ENCODING = 2, | 48 FIXED_CONTENT_ENCODING = 2, |
46 FIXED_CONTENT_ENCODINGS = 3, | 49 FIXED_CONTENT_ENCODINGS = 3, |
47 | 50 |
48 // Content decoding errors. | 51 // Content decoding errors. |
49 DECODE_HEADER_ERROR = 4, | 52 DECODE_HEADER_ERROR = 4, |
50 DECODE_BODY_ERROR = 5, | 53 DECODE_BODY_ERROR = 5, |
51 | 54 |
(...skipping 30 matching lines...) Expand all Loading... | |
82 DICTIONARY_SELECTED_FROM_NON_HTTP = 33, | 85 DICTIONARY_SELECTED_FROM_NON_HTTP = 33, |
83 DICTIONARY_IS_TOO_LARGE= 34, | 86 DICTIONARY_IS_TOO_LARGE= 34, |
84 DICTIONARY_COUNT_EXCEEDED = 35, | 87 DICTIONARY_COUNT_EXCEEDED = 35, |
85 DICTIONARY_ALREADY_SCHEDULED_TO_DOWNLOAD = 36, | 88 DICTIONARY_ALREADY_SCHEDULED_TO_DOWNLOAD = 36, |
86 DICTIONARY_ALREADY_TRIED_TO_DOWNLOAD = 37, | 89 DICTIONARY_ALREADY_TRIED_TO_DOWNLOAD = 37, |
87 DICTIONARY_FETCH_READ_FAILED = 38, | 90 DICTIONARY_FETCH_READ_FAILED = 38, |
88 | 91 |
89 // Failsafe hack. | 92 // Failsafe hack. |
90 ATTEMPT_TO_DECODE_NON_HTTP_DATA = 40, | 93 ATTEMPT_TO_DECODE_NON_HTTP_DATA = 40, |
91 | 94 |
92 | |
93 // Content-Encoding problems detected, with no action taken. | 95 // Content-Encoding problems detected, with no action taken. |
94 MULTIENCODING_FOR_NON_SDCH_REQUEST = 50, | 96 MULTIENCODING_FOR_NON_SDCH_REQUEST = 50, |
95 SDCH_CONTENT_ENCODE_FOR_NON_SDCH_REQUEST = 51, | 97 SDCH_CONTENT_ENCODE_FOR_NON_SDCH_REQUEST = 51, |
96 | 98 |
99 // A dictionary that wasn't advertised is being used for decoding. | |
100 UNADVERTISED_SDCH_DICTIONARY_USED = 52, | |
101 UNADVERTISED_SDCH_DICTIONARY_USED_CACHED = 53, | |
102 | |
97 // Dictionary manager issues. | 103 // Dictionary manager issues. |
98 DOMAIN_BLACKLIST_INCLUDES_TARGET = 61, | 104 DOMAIN_BLACKLIST_INCLUDES_TARGET = 61, |
99 | 105 |
100 // Problematic decode recovery methods. | 106 // Problematic decode recovery methods. |
101 META_REFRESH_RECOVERY = 70, // Dictionary not found. | 107 META_REFRESH_RECOVERY = 70, // Dictionary not found. |
102 // defunct = 71, // Almost the same as META_REFRESH_UNSUPPORTED. | 108 // defunct = 71, // Almost the same as META_REFRESH_UNSUPPORTED. |
103 // defunct = 72, // Almost the same as CACHED_META_REFRESH_UNSUPPORTED. | 109 // defunct = 72, // Almost the same as CACHED_META_REFRESH_UNSUPPORTED. |
104 // defunct = 73, // PASSING_THROUGH_NON_SDCH plus | 110 // defunct = 73, // PASSING_THROUGH_NON_SDCH plus |
105 // RESPONSE_TENTATIVE_SDCH in ../filter/sdch_filter.cc. | 111 // RESPONSE_TENTATIVE_SDCH in ../filter/sdch_filter.cc. |
106 META_REFRESH_UNSUPPORTED = 74, // Unrecoverable error. | 112 META_REFRESH_UNSUPPORTED = 74, // Unrecoverable error. |
(...skipping 27 matching lines...) Expand all Loading... | |
134 | 140 |
135 MAX_PROBLEM_CODE // Used to bound histogram. | 141 MAX_PROBLEM_CODE // Used to bound histogram. |
136 }; | 142 }; |
137 | 143 |
138 // Use the following static limits to block DOS attacks until we implement | 144 // Use the following static limits to block DOS attacks until we implement |
139 // a cached dictionary evicition strategy. | 145 // a cached dictionary evicition strategy. |
140 static const size_t kMaxDictionarySize; | 146 static const size_t kMaxDictionarySize; |
141 static const size_t kMaxDictionaryCount; | 147 static const size_t kMaxDictionaryCount; |
142 | 148 |
143 // There is one instance of |Dictionary| for each memory-cached SDCH | 149 // There is one instance of |Dictionary| for each memory-cached SDCH |
144 // dictionary. | 150 // dictionary. |
Ryan Sleevi
2014/11/14 03:21:25
Is this still true? By making this public, you cre
Randy Smith (Not in Mondays)
2014/11/17 17:04:21
Completely fair; now consumers can create their ow
| |
145 class NET_EXPORT_PRIVATE Dictionary : public base::RefCounted<Dictionary> { | 151 class NET_EXPORT_PRIVATE Dictionary { |
146 public: | 152 public: |
147 // Sdch filters can get our text to use in decoding compressed data. | |
148 const std::string& text() const { return text_; } | |
149 | |
150 private: | |
151 friend class base::RefCounted<Dictionary>; | |
152 friend class SdchManager; // Only manager can construct an instance. | |
153 FRIEND_TEST_ALL_PREFIXES(SdchManagerTest, PathMatch); | |
154 | |
155 // Construct a vc-diff usable dictionary from the dictionary_text starting | 153 // Construct a vc-diff usable dictionary from the dictionary_text starting |
156 // at the given offset. The supplied client_hash should be used to | 154 // at the given offset. The supplied client_hash should be used to |
157 // advertise the dictionary's availability relative to the suppplied URL. | 155 // advertise the dictionary's availability relative to the suppplied URL. |
158 Dictionary(const std::string& dictionary_text, | 156 Dictionary(const std::string& dictionary_text, |
159 size_t offset, | 157 size_t offset, |
160 const std::string& client_hash, | 158 const std::string& client_hash, |
161 const GURL& url, | 159 const GURL& url, |
162 const std::string& domain, | 160 const std::string& domain, |
163 const std::string& path, | 161 const std::string& path, |
164 const base::Time& expiration, | 162 const base::Time& expiration, |
165 const std::set<int>& ports); | 163 const std::set<int>& ports); |
166 virtual ~Dictionary(); | 164 virtual ~Dictionary(); |
167 | 165 |
166 // Sdch filters can get our text to use in decoding compressed data. | |
167 const std::string& text() const { return text_; } | |
168 | |
168 const GURL& url() const { return url_; } | 169 const GURL& url() const { return url_; } |
169 const std::string& client_hash() const { return client_hash_; } | 170 const std::string& client_hash() const { return client_hash_; } |
170 | 171 |
171 // Security method to check if we can advertise this dictionary for use | |
172 // if the |target_url| returns SDCH compressed data. | |
173 bool CanAdvertise(const GURL& target_url); | |
174 | |
175 // Security methods to check if we can establish a new dictionary with the | 172 // Security methods to check if we can establish a new dictionary with the |
176 // given data, that arrived in response to get of dictionary_url. | 173 // given data, that arrived in response to get of dictionary_url. |
177 static bool CanSet(const std::string& domain, const std::string& path, | 174 static bool CanSet(const std::string& domain, const std::string& path, |
178 const std::set<int>& ports, const GURL& dictionary_url); | 175 const std::set<int>& ports, const GURL& dictionary_url); |
179 | 176 |
180 // Security method to check if we can use a dictionary to decompress a | 177 // Security method to check if a dictionary is appropriate to use |
181 // target that arrived with a reference to this dictionary. | 178 // with the given URL. Does not check expiration (it's appropriate to |
Ryan Sleevi
2014/11/14 03:21:25
single space
Randy Smith (Not in Mondays)
2014/11/17 17:04:22
:-}. Done (through file).
| |
182 bool CanUse(const GURL& referring_url); | 179 // use dictionaries that were expired while a request is outstanding). |
180 SdchManager::ProblemCodes CanUse(const GURL& target_url); | |
183 | 181 |
184 // Compare paths to see if they "match" for dictionary use. | 182 // Compare paths to see if they "match" for dictionary use. |
185 static bool PathMatch(const std::string& path, | 183 static bool PathMatch(const std::string& path, |
186 const std::string& restriction); | 184 const std::string& restriction); |
187 | 185 |
188 // Compare domains to see if the "match" for dictionary use. | 186 // Compare domains to see if the "match" for dictionary use. |
189 static bool DomainMatch(const GURL& url, const std::string& restriction); | 187 static bool DomainMatch(const GURL& url, const std::string& restriction); |
190 | 188 |
189 // Is this dictionary expired? | |
190 bool Expired() const; | |
191 | 191 |
192 private: | |
192 // The actual text of the dictionary. | 193 // The actual text of the dictionary. |
193 std::string text_; | 194 std::string text_; |
194 | 195 |
195 // Part of the hash of text_ that the client uses to advertise the fact that | 196 // Part of the hash of text_ that the client uses to advertise the fact that |
196 // it has a specific dictionary pre-cached. | 197 // it has a specific dictionary pre-cached. |
197 std::string client_hash_; | 198 std::string client_hash_; |
198 | 199 |
199 // The GURL that arrived with the text_ in a URL request to specify where | 200 // The GURL that arrived with the text_ in a URL request to specify where |
200 // this dictionary may be used. | 201 // this dictionary may be used. |
201 const GURL url_; | 202 const GURL url_; |
202 | 203 |
203 // Metadate "headers" in before dictionary text contained the following: | 204 // Metadate "headers" in before dictionary text contained the following: |
204 // Each dictionary payload consists of several headers, followed by the text | 205 // Each dictionary payload consists of several headers, followed by the text |
205 // of the dictionary. The following are the known headers. | 206 // of the dictionary. The following are the known headers. |
206 const std::string domain_; | 207 const std::string domain_; |
207 const std::string path_; | 208 const std::string path_; |
208 const base::Time expiration_; // Implied by max-age. | 209 const base::Time expiration_; // Implied by max-age. |
209 const std::set<int> ports_; | 210 const std::set<int> ports_; |
210 | 211 |
211 DISALLOW_COPY_AND_ASSIGN(Dictionary); | 212 DISALLOW_COPY_AND_ASSIGN(Dictionary); |
212 }; | 213 }; |
213 | 214 |
215 // Implementation type relevant for the private data members of | |
216 // DictionarySet and SdchManager. This class should not be used | |
217 // outside of sdch_manager.*. | |
218 class DictionaryWrapper : public base::RefCounted<DictionaryWrapper> { | |
Ryan Sleevi
2014/11/14 03:21:25
Why not just RefCountedData? https://code.google.c
Randy Smith (Not in Mondays)
2014/11/17 17:04:21
Cool; thanks for pointing that type out to me. Th
| |
219 public: | |
220 typedef std::map<std::string, scoped_refptr<DictionaryWrapper> > | |
221 DictionaryMap; | |
Ryan Sleevi
2014/11/14 03:21:25
Why is this a typedef on the Wrapper? Seems to be
Randy Smith (Not in Mondays)
2014/11/17 17:04:21
Yeah, that's fair. I was trying to avoid having t
| |
222 | |
223 explicit DictionaryWrapper(scoped_ptr<Dictionary> dictionary); | |
224 Dictionary* dictionary() { return dictionary_.get(); } | |
225 | |
226 private: | |
227 friend class base::RefCounted<DictionaryWrapper>; | |
228 ~DictionaryWrapper(); | |
229 | |
230 scoped_ptr<SdchManager::Dictionary> dictionary_; | |
231 | |
232 DISALLOW_COPY_AND_ASSIGN(DictionaryWrapper); | |
233 }; | |
234 | |
235 // A handle for one or more dictionaries which will keep the dictionaries | |
236 // alive and accessible for the handle's lifetime. | |
237 class NET_EXPORT_PRIVATE DictionarySet { | |
238 public: | |
239 ~DictionarySet(); | |
240 | |
241 // Append a comma separated list of client hashes onto the end | |
242 // of |client_hashes|. | |
243 void GetDictionaryClientHashList(std::string* client_hashes) const; | |
Ryan Sleevi
2014/11/14 03:21:25
Why do you append, rather than just returning the
Randy Smith (Not in Mondays)
2014/11/17 17:04:21
I think I was instinctively trying to avoid the pe
| |
244 | |
245 // Lookup a given dictionary based on server hash. Returned pointer | |
246 // is guaranteed to be valid for the lifetime of the DictionarySet. | |
247 // Returns NULL if hash is not a valid server hash for a dictionary | |
248 // named by DictionarySet. | |
249 const SdchManager::Dictionary* Dictionary(const std::string& hash) const; | |
Ryan Sleevi
2014/11/14 03:21:25
Should you return a const-ref then? That usually h
Randy Smith (Not in Mondays)
2014/11/17 17:04:22
I like that idea, and I agree that interface would
| |
250 | |
251 bool Empty() const; | |
252 | |
253 private: | |
254 // A DictionarySet may only be constructed by the SdchManager. | |
255 friend class SdchManager; | |
256 | |
257 static const char* kSdchDictionariesHandleDataKey; | |
Ryan Sleevi
2014/11/14 03:21:25
private static? seems unnecessary?
Randy Smith (Not in Mondays)
2014/11/17 17:04:22
Whoops; serious leftover. Gone.
| |
258 | |
259 DictionarySet(); | |
260 void AddDictionary(const std::string& server_hash, | |
261 scoped_refptr<DictionaryWrapper> dictionary); | |
262 | |
263 DictionaryWrapper::DictionaryMap dictionaries_; | |
264 | |
265 DISALLOW_COPY_AND_ASSIGN(DictionarySet); | |
266 }; | |
267 | |
214 SdchManager(); | 268 SdchManager(); |
215 ~SdchManager(); | 269 ~SdchManager(); |
216 | 270 |
217 // Clear data (for browser data removal). | 271 // Clear data (for browser data removal). |
218 void ClearData(); | 272 void ClearData(); |
219 | 273 |
220 // Record stats on various errors. | 274 // Record stats on various errors. |
221 static void SdchErrorRecovery(ProblemCodes problem); | 275 static void SdchErrorRecovery(ProblemCodes problem); |
222 | 276 |
223 // Enables or disables SDCH compression. | 277 // Enables or disables SDCH compression. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 // Check to see if SDCH is enabled (globally), and the given URL is in a | 313 // Check to see if SDCH is enabled (globally), and the given URL is in a |
260 // supported domain (i.e., not blacklisted, and either the specific supported | 314 // supported domain (i.e., not blacklisted, and either the specific supported |
261 // domain, or all domains were assumed supported). If it is blacklist, reduce | 315 // domain, or all domains were assumed supported). If it is blacklist, reduce |
262 // by 1 the number of times it will be reported as blacklisted. | 316 // by 1 the number of times it will be reported as blacklisted. |
263 bool IsInSupportedDomain(const GURL& url); | 317 bool IsInSupportedDomain(const GURL& url); |
264 | 318 |
265 // Send out appropriate events notifying observers that a Get-Dictionary | 319 // Send out appropriate events notifying observers that a Get-Dictionary |
266 // header has been seen. | 320 // header has been seen. |
267 void OnGetDictionary(const GURL& request_url, const GURL& dictionary_url); | 321 void OnGetDictionary(const GURL& request_url, const GURL& dictionary_url); |
268 | 322 |
269 // Find the vcdiff dictionary (the body of the sdch dictionary that appears | 323 // Get a handle to the available dictionaries that might be used |
270 // after the meta-data headers like Domain:...) with the given |server_hash| | 324 // for encoding responses for the given URL. The return set will not |
271 // to use to decompreses data that arrived as SDCH encoded content. Check to | 325 // include expired dictionaries. If no dictionaries |
272 // be sure the returned |dictionary| can be used for decoding content supplied | 326 // are appropriate to use with the target_url, NULL is returned. |
273 // in response to a request for |referring_url|. | 327 scoped_ptr<DictionarySet> GetDictionarySet(const GURL& target_url); |
274 // Return null in |dictionary| if there is no matching legal dictionary. | |
275 void GetVcdiffDictionary(const std::string& server_hash, | |
276 const GURL& referring_url, | |
277 scoped_refptr<Dictionary>* dictionary); | |
278 | 328 |
279 // Get list of available (pre-cached) dictionaries that we have already loaded | 329 // Get a handle to a specific dictionary, by its server hash, confirming |
280 // into memory. The list is a comma separated list of (client) hashes per | 330 // that that specific dictionary is appropriate to use with |target_url|. |
281 // the SDCH spec. | 331 // Expired dictionaries will be returned. If no dictionary with that |
282 void GetAvailDictionaryList(const GURL& target_url, std::string* list); | 332 // hash exists that is usable with |target_url|, NULL is returned. |
333 scoped_ptr<DictionarySet> GetDictionarySetByHash( | |
334 const GURL& target_url, | |
335 const std::string& server_hash); | |
283 | 336 |
284 // Construct the pair of hashes for client and server to identify an SDCH | 337 // Construct the pair of hashes for client and server to identify an SDCH |
285 // dictionary. This is only made public to facilitate unit testing, but is | 338 // dictionary. This is only made public to facilitate unit testing, but is |
286 // otherwise private | 339 // otherwise private |
287 static void GenerateHash(const std::string& dictionary_text, | 340 static void GenerateHash(const std::string& dictionary_text, |
288 std::string* client_hash, std::string* server_hash); | 341 std::string* client_hash, std::string* server_hash); |
289 | 342 |
290 // For Latency testing only, we need to know if we've succeeded in doing a | 343 // For Latency testing only, we need to know if we've succeeded in doing a |
291 // round trip before starting our comparative tests. If ever we encounter | 344 // round trip before starting our comparative tests. If ever we encounter |
292 // problems with SDCH, we opt-out of the test unless/until we perform a | 345 // problems with SDCH, we opt-out of the test unless/until we perform a |
293 // complete SDCH decoding. | 346 // complete SDCH decoding. |
294 bool AllowLatencyExperiment(const GURL& url) const; | 347 bool AllowLatencyExperiment(const GURL& url) const; |
295 | 348 |
296 void SetAllowLatencyExperiment(const GURL& url, bool enable); | 349 void SetAllowLatencyExperiment(const GURL& url, bool enable); |
297 | 350 |
298 // Add an SDCH dictionary to our list of availible | 351 // Add an SDCH dictionary to our list of availible |
299 // dictionaries. This addition will fail if addition is illegal | 352 // dictionaries. This addition will fail if addition is illegal |
300 // (data in the dictionary is not acceptable from the | 353 // (data in the dictionary is not acceptable from the |
301 // dictionary_url; dictionary already added, etc.). | 354 // dictionary_url; dictionary already added, etc.). |
302 void AddSdchDictionary(const std::string& dictionary_text, | 355 void AddSdchDictionary(const std::string& dictionary_text, |
303 const GURL& dictionary_url); | 356 const GURL& dictionary_url); |
304 | 357 |
305 // Registration for events generated by the SDCH subsystem. | 358 // Registration for events generated by the SDCH subsystem. |
306 void AddObserver(SdchObserver* observer); | 359 void AddObserver(SdchObserver* observer); |
307 void RemoveObserver(SdchObserver* observer); | 360 void RemoveObserver(SdchObserver* observer); |
308 | 361 |
362 static scoped_ptr<DictionarySet> CreateNullDictionarySetForTesting(); | |
Ryan Sleevi
2014/11/14 03:21:25
s/Null/Empty/ (as otherwise you'd just return a nu
Randy Smith (Not in Mondays)
2014/11/17 17:04:22
Done.
| |
363 | |
309 private: | 364 private: |
310 struct BlacklistInfo { | 365 struct BlacklistInfo { |
311 BlacklistInfo() | 366 BlacklistInfo() |
312 : count(0), | 367 : count(0), |
313 exponential_count(0), | 368 exponential_count(0), |
314 reason(MIN_PROBLEM_CODE) {} | 369 reason(OK) {} |
315 | 370 |
316 int count; // # of times to refuse SDCH advertisement. | 371 int count; // # of times to refuse SDCH advertisement. |
317 int exponential_count; // Current exponential backoff ratchet. | 372 int exponential_count; // Current exponential backoff ratchet. |
318 ProblemCodes reason; // Why domain was blacklisted. | 373 ProblemCodes reason; // Why domain was blacklisted. |
319 | 374 |
320 }; | 375 }; |
376 | |
321 typedef std::map<std::string, BlacklistInfo> DomainBlacklistInfo; | 377 typedef std::map<std::string, BlacklistInfo> DomainBlacklistInfo; |
322 typedef std::set<std::string> ExperimentSet; | 378 typedef std::set<std::string> ExperimentSet; |
323 | 379 |
324 // Determines whether a "Get-Dictionary" header is legal (dictionary | 380 // Determines whether a "Get-Dictionary" header is legal (dictionary |
325 // url has appropriate relationship to referrer url) in the SDCH | 381 // url has appropriate relationship to referrer url) in the SDCH |
326 // protocol. Return true if fetch is legal. | 382 // protocol. Return true if fetch is legal. |
327 bool CanFetchDictionary(const GURL& referring_url, | 383 bool CanFetchDictionary(const GURL& referring_url, |
328 const GURL& dictionary_url) const; | 384 const GURL& dictionary_url) const; |
329 | 385 |
330 // A map of dictionaries info indexed by the hash that the server provides. | |
331 typedef std::map<std::string, scoped_refptr<Dictionary> > DictionaryMap; | |
332 | |
333 // Support SDCH compression, by advertising in headers. | 386 // Support SDCH compression, by advertising in headers. |
334 static bool g_sdch_enabled_; | 387 static bool g_sdch_enabled_; |
335 | 388 |
336 // Support SDCH compression for HTTPS requests and responses. When supported, | 389 // Support SDCH compression for HTTPS requests and responses. When supported, |
337 // HTTPS applicable dictionaries MUST have been acquired securely via HTTPS. | 390 // HTTPS applicable dictionaries MUST have been acquired securely via HTTPS. |
338 static bool g_secure_scheme_supported_; | 391 static bool g_secure_scheme_supported_; |
339 | 392 |
340 // A simple implementation of a RFC 3548 "URL safe" base64 encoder. | 393 // A simple implementation of a RFC 3548 "URL safe" base64 encoder. |
341 static void UrlSafeBase64Encode(const std::string& input, | 394 static void UrlSafeBase64Encode(const std::string& input, |
342 std::string* output); | 395 std::string* output); |
343 DictionaryMap dictionaries_; | 396 |
397 DictionaryWrapper::DictionaryMap dictionaries_; | |
Ryan Sleevi
2014/11/14 03:21:25
see comment re: DictionaryMap typedef
Randy Smith (Not in Mondays)
2014/11/17 17:04:21
Moot.
| |
344 | 398 |
345 // List domains where decode failures have required disabling sdch. | 399 // List domains where decode failures have required disabling sdch. |
346 DomainBlacklistInfo blacklisted_domains_; | 400 DomainBlacklistInfo blacklisted_domains_; |
347 | 401 |
348 // List of hostnames for which a latency experiment is allowed (because a | 402 // List of hostnames for which a latency experiment is allowed (because a |
349 // round trip test has recently passed). | 403 // round trip test has recently passed). |
350 ExperimentSet allow_latency_experiment_; | 404 ExperimentSet allow_latency_experiment_; |
351 | 405 |
352 // Observers that want to be notified of SDCH events. | 406 // Observers that want to be notified of SDCH events. |
353 // Assert list is empty on destruction since if there is an observer | 407 // Assert list is empty on destruction since if there is an observer |
354 // that hasn't removed itself from the list, that observer probably | 408 // that hasn't removed itself from the list, that observer probably |
355 // has a reference to the SdchManager. | 409 // has a reference to the SdchManager. |
356 ObserverList<SdchObserver, true> observers_; | 410 ObserverList<SdchObserver, true> observers_; |
357 | 411 |
358 base::ThreadChecker thread_checker_; | 412 base::ThreadChecker thread_checker_; |
359 | 413 |
360 DISALLOW_COPY_AND_ASSIGN(SdchManager); | 414 DISALLOW_COPY_AND_ASSIGN(SdchManager); |
361 }; | 415 }; |
362 | 416 |
363 } // namespace net | 417 } // namespace net |
364 | 418 |
365 #endif // NET_BASE_SDCH_MANAGER_H_ | 419 #endif // NET_BASE_SDCH_MANAGER_H_ |
OLD | NEW |