OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "base/field_trial.h" | 5 #include "base/field_trial.h" |
6 #include "base/histogram.h" | 6 #include "base/histogram.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/sha2.h" | 8 #include "base/sha2.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "net/base/base64.h" | 10 #include "net/base/base64.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // static | 25 // static |
26 SdchManager* SdchManager::global_; | 26 SdchManager* SdchManager::global_; |
27 | 27 |
28 // static | 28 // static |
29 SdchManager* SdchManager::Global() { | 29 SdchManager* SdchManager::Global() { |
30 return global_; | 30 return global_; |
31 } | 31 } |
32 | 32 |
33 // static | 33 // static |
34 void SdchManager::SdchErrorRecovery(ProblemCodes problem) { | 34 void SdchManager::SdchErrorRecovery(ProblemCodes problem) { |
35 static LinearHistogram histogram(L"Sdch.ProblemCodes_2", MIN_PROBLEM_CODE, | 35 static LinearHistogram histogram("Sdch.ProblemCodes_2", MIN_PROBLEM_CODE, |
36 MAX_PROBLEM_CODE - 1, MAX_PROBLEM_CODE); | 36 MAX_PROBLEM_CODE - 1, MAX_PROBLEM_CODE); |
37 histogram.SetFlags(kUmaTargetedHistogramFlag); | 37 histogram.SetFlags(kUmaTargetedHistogramFlag); |
38 histogram.Add(problem); | 38 histogram.Add(problem); |
39 } | 39 } |
40 | 40 |
41 // static | 41 // static |
42 void SdchManager::ClearBlacklistings() { | 42 void SdchManager::ClearBlacklistings() { |
43 Global()->blacklisted_domains_.clear(); | 43 Global()->blacklisted_domains_.clear(); |
44 Global()->exponential_blacklist_count.clear(); | 44 Global()->exponential_blacklist_count.clear(); |
45 } | 45 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // is probably not worth doing eviction handling. | 256 // is probably not worth doing eviction handling. |
257 if (kMaxDictionarySize < dictionary_text.size()) { | 257 if (kMaxDictionarySize < dictionary_text.size()) { |
258 SdchErrorRecovery(DICTIONARY_IS_TOO_LARGE); | 258 SdchErrorRecovery(DICTIONARY_IS_TOO_LARGE); |
259 return false; | 259 return false; |
260 } | 260 } |
261 if (kMaxDictionaryCount <= dictionaries_.size()) { | 261 if (kMaxDictionaryCount <= dictionaries_.size()) { |
262 SdchErrorRecovery(DICTIONARY_COUNT_EXCEEDED); | 262 SdchErrorRecovery(DICTIONARY_COUNT_EXCEEDED); |
263 return false; | 263 return false; |
264 } | 264 } |
265 | 265 |
266 UMA_HISTOGRAM_COUNTS(L"Sdch.Dictionary size loaded", dictionary_text.size()); | 266 UMA_HISTOGRAM_COUNTS("Sdch.Dictionary size loaded", dictionary_text.size()); |
267 DLOG(INFO) << "Loaded dictionary with client hash " << client_hash << | 267 DLOG(INFO) << "Loaded dictionary with client hash " << client_hash << |
268 " and server hash " << server_hash; | 268 " and server hash " << server_hash; |
269 Dictionary* dictionary = | 269 Dictionary* dictionary = |
270 new Dictionary(dictionary_text, header_end + 2, client_hash, | 270 new Dictionary(dictionary_text, header_end + 2, client_hash, |
271 dictionary_url, domain, path, expiration, ports); | 271 dictionary_url, domain, path, expiration, ports); |
272 dictionary->AddRef(); | 272 dictionary->AddRef(); |
273 dictionaries_[server_hash] = dictionary; | 273 dictionaries_[server_hash] = dictionary; |
274 return true; | 274 return true; |
275 } | 275 } |
276 | 276 |
(...skipping 20 matching lines...) Expand all Loading... |
297 it != dictionaries_.end(); ++it) { | 297 it != dictionaries_.end(); ++it) { |
298 if (!it->second->CanAdvertise(target_url)) | 298 if (!it->second->CanAdvertise(target_url)) |
299 continue; | 299 continue; |
300 ++count; | 300 ++count; |
301 if (!list->empty()) | 301 if (!list->empty()) |
302 list->append(","); | 302 list->append(","); |
303 list->append(it->second->client_hash()); | 303 list->append(it->second->client_hash()); |
304 } | 304 } |
305 // Watch to see if we have corrupt or numerous dictionaries. | 305 // Watch to see if we have corrupt or numerous dictionaries. |
306 if (count > 0) | 306 if (count > 0) |
307 UMA_HISTOGRAM_COUNTS(L"Sdch.Advertisement_Count", count); | 307 UMA_HISTOGRAM_COUNTS("Sdch.Advertisement_Count", count); |
308 } | 308 } |
309 | 309 |
310 SdchManager::Dictionary::Dictionary(const std::string& dictionary_text, | 310 SdchManager::Dictionary::Dictionary(const std::string& dictionary_text, |
311 size_t offset, const std::string& client_hash, const GURL& gurl, | 311 size_t offset, const std::string& client_hash, const GURL& gurl, |
312 const std::string& domain, const std::string& path, const Time& expiration, | 312 const std::string& domain, const std::string& path, const Time& expiration, |
313 const std::set<int> ports) | 313 const std::set<int> ports) |
314 : text_(dictionary_text, offset), | 314 : text_(dictionary_text, offset), |
315 client_hash_(client_hash), | 315 client_hash_(client_hash), |
316 url_(gurl), | 316 url_(gurl), |
317 domain_(domain), | 317 domain_(domain), |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 return false; | 500 return false; |
501 return restriction[prefix_length - 1] == '/' || path[prefix_length] == '/'; | 501 return restriction[prefix_length - 1] == '/' || path[prefix_length] == '/'; |
502 } | 502 } |
503 | 503 |
504 // static | 504 // static |
505 bool SdchManager::Dictionary::DomainMatch(const GURL& gurl, | 505 bool SdchManager::Dictionary::DomainMatch(const GURL& gurl, |
506 const std::string& restriction) { | 506 const std::string& restriction) { |
507 // TODO(jar): This is not precisely a domain match definition. | 507 // TODO(jar): This is not precisely a domain match definition. |
508 return gurl.DomainIs(restriction.data(), restriction.size()); | 508 return gurl.DomainIs(restriction.data(), restriction.size()); |
509 } | 509 } |
OLD | NEW |