Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: net/base/sdch_manager.h

Issue 298063006: Make SdchManager per-profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated comments and changed test name. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/profiles/profile_impl_io_data.cc ('k') | net/base/sdch_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 const std::string path_; 227 const std::string path_;
228 const base::Time expiration_; // Implied by max-age. 228 const base::Time expiration_; // Implied by max-age.
229 const std::set<int> ports_; 229 const std::set<int> ports_;
230 230
231 DISALLOW_COPY_AND_ASSIGN(Dictionary); 231 DISALLOW_COPY_AND_ASSIGN(Dictionary);
232 }; 232 };
233 233
234 SdchManager(); 234 SdchManager();
235 ~SdchManager(); 235 ~SdchManager();
236 236
237 // Discontinue fetching of dictionaries, as we're now shutting down.
238 static void Shutdown();
239
240 // Provide access to the single instance of this class.
241 static SdchManager* Global();
242
243 // Record stats on various errors. 237 // Record stats on various errors.
244 static void SdchErrorRecovery(ProblemCodes problem); 238 static void SdchErrorRecovery(ProblemCodes problem);
245 239
246 // Register a fetcher that this class can use to obtain dictionaries. 240 // Register a fetcher that this class can use to obtain dictionaries.
247 void set_sdch_fetcher(SdchFetcher* fetcher); 241 void set_sdch_fetcher(SdchFetcher* fetcher);
248 242
249 // Enables or disables SDCH compression. 243 // Enables or disables SDCH compression.
250 static void EnableSdchSupport(bool enabled); 244 static void EnableSdchSupport(bool enabled);
251 245
252 static bool sdch_enabled() { return g_sdch_enabled_; } 246 static bool sdch_enabled() { return g_sdch_enabled_; }
253 247
254 // Enables or disables SDCH compression over secure connection. 248 // Enables or disables SDCH compression over secure connection.
255 static void EnableSecureSchemeSupport(bool enabled); 249 static void EnableSecureSchemeSupport(bool enabled);
256 250
257 static bool secure_scheme_supported() { return g_secure_scheme_supported_; } 251 static bool secure_scheme_supported() { return g_secure_scheme_supported_; }
258 252
259 // Briefly prevent further advertising of SDCH on this domain (if SDCH is 253 // Briefly prevent further advertising of SDCH on this domain (if SDCH is
260 // enabled). After enough calls to IsInSupportedDomain() the blacklisting 254 // enabled). After enough calls to IsInSupportedDomain() the blacklisting
261 // will be removed. Additional blacklists take exponentially more calls 255 // will be removed. Additional blacklists take exponentially more calls
262 // to IsInSupportedDomain() before the blacklisting is undone. 256 // to IsInSupportedDomain() before the blacklisting is undone.
263 // Used when filter errors are found from a given domain, but it is plausible 257 // Used when filter errors are found from a given domain, but it is plausible
264 // that the cause is temporary (such as application startup, where cached 258 // that the cause is temporary (such as application startup, where cached
265 // entries are used, but a dictionary is not yet loaded). 259 // entries are used, but a dictionary is not yet loaded).
266 static void BlacklistDomain(const GURL& url); 260 void BlacklistDomain(const GURL& url);
267 261
268 // Used when SEVERE filter errors are found from a given domain, to prevent 262 // Used when SEVERE filter errors are found from a given domain, to prevent
269 // further use of SDCH on that domain. 263 // further use of SDCH on that domain.
270 static void BlacklistDomainForever(const GURL& url); 264 void BlacklistDomainForever(const GURL& url);
271 265
272 // Unit test only, this function resets enabling of sdch, and clears the 266 // Unit test only, this function resets enabling of sdch, and clears the
273 // blacklist. 267 // blacklist.
274 static void ClearBlacklistings(); 268 void ClearBlacklistings();
275 269
276 // Unit test only, this function resets the blacklisting count for a domain. 270 // Unit test only, this function resets the blacklisting count for a domain.
277 static void ClearDomainBlacklisting(const std::string& domain); 271 void ClearDomainBlacklisting(const std::string& domain);
278 272
279 // Unit test only: indicate how many more times a domain will be blacklisted. 273 // Unit test only: indicate how many more times a domain will be blacklisted.
280 static int BlackListDomainCount(const std::string& domain); 274 int BlackListDomainCount(const std::string& domain);
281 275
282 // Unit test only: Indicate what current blacklist increment is for a domain. 276 // Unit test only: Indicate what current blacklist increment is for a domain.
283 static int BlacklistDomainExponential(const std::string& domain); 277 int BlacklistDomainExponential(const std::string& domain);
284 278
285 // Check to see if SDCH is enabled (globally), and the given URL is in a 279 // Check to see if SDCH is enabled (globally), and the given URL is in a
286 // supported domain (i.e., not blacklisted, and either the specific supported 280 // supported domain (i.e., not blacklisted, and either the specific supported
287 // domain, or all domains were assumed supported). If it is blacklist, reduce 281 // domain, or all domains were assumed supported). If it is blacklist, reduce
288 // by 1 the number of times it will be reported as blacklisted. 282 // by 1 the number of times it will be reported as blacklisted.
289 bool IsInSupportedDomain(const GURL& url); 283 bool IsInSupportedDomain(const GURL& url);
290 284
291 // Schedule the URL fetching to load a dictionary. This will always return 285 // Schedule the URL fetching to load a dictionary. This will always return
292 // before the dictionary is actually loaded and added. 286 // before the dictionary is actually loaded and added.
293 // After the implied task does completes, the dictionary will have been 287 // After the implied task does completes, the dictionary will have been
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 330
337 void SetAllowLatencyExperiment(const GURL& url, bool enable); 331 void SetAllowLatencyExperiment(const GURL& url, bool enable);
338 332
339 private: 333 private:
340 typedef std::map<std::string, int> DomainCounter; 334 typedef std::map<std::string, int> DomainCounter;
341 typedef std::set<std::string> ExperimentSet; 335 typedef std::set<std::string> ExperimentSet;
342 336
343 // A map of dictionaries info indexed by the hash that the server provides. 337 // A map of dictionaries info indexed by the hash that the server provides.
344 typedef std::map<std::string, Dictionary*> DictionaryMap; 338 typedef std::map<std::string, Dictionary*> DictionaryMap;
345 339
346 // The one global instance of that holds all the data.
347 static SdchManager* global_;
348
349 // Support SDCH compression, by advertising in headers. 340 // Support SDCH compression, by advertising in headers.
350 static bool g_sdch_enabled_; 341 static bool g_sdch_enabled_;
351 342
352 // Support SDCH compression for HTTPS requests and responses. When supported, 343 // Support SDCH compression for HTTPS requests and responses. When supported,
353 // HTTPS applicable dictionaries MUST have been acquired securely via HTTPS. 344 // HTTPS applicable dictionaries MUST have been acquired securely via HTTPS.
354 static bool g_secure_scheme_supported_; 345 static bool g_secure_scheme_supported_;
355 346
356 // A simple implementation of a RFC 3548 "URL safe" base64 encoder. 347 // A simple implementation of a RFC 3548 "URL safe" base64 encoder.
357 static void UrlSafeBase64Encode(const std::string& input, 348 static void UrlSafeBase64Encode(const std::string& input,
358 std::string* output); 349 std::string* output);
(...skipping 13 matching lines...) Expand all
372 // 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
373 // round trip test has recently passed). 364 // round trip test has recently passed).
374 ExperimentSet allow_latency_experiment_; 365 ExperimentSet allow_latency_experiment_;
375 366
376 DISALLOW_COPY_AND_ASSIGN(SdchManager); 367 DISALLOW_COPY_AND_ASSIGN(SdchManager);
377 }; 368 };
378 369
379 } // namespace net 370 } // namespace net
380 371
381 #endif // NET_BASE_SDCH_MANAGER_H_ 372 #endif // NET_BASE_SDCH_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl_io_data.cc ('k') | net/base/sdch_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698