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

Side by Side Diff: net/base/host_cache.cc

Issue 11366201: [net] Fix parsing of HostCacheSize field trial group name. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 1 month 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 | « no previous file | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/base/host_cache.h" 5 #include "net/base/host_cache.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 const HostCache::EntryMap& HostCache::entries() const { 79 const HostCache::EntryMap& HostCache::entries() const {
80 DCHECK(CalledOnValidThread()); 80 DCHECK(CalledOnValidThread());
81 return entries_; 81 return entries_;
82 } 82 }
83 83
84 // static 84 // static
85 scoped_ptr<HostCache> HostCache::CreateDefaultCache() { 85 scoped_ptr<HostCache> HostCache::CreateDefaultCache() {
86 // Cache capacity is determined by the field trial. 86 // Cache capacity is determined by the field trial.
87 const size_t kSaneMaxEntries = 1 << 20; 87 const size_t kSaneMaxEntries = 1 << 20;
88 size_t max_entries = 0; 88 size_t max_entries = 0;
89 if (!base::StringToSizeT(base::FieldTrialList::FindFullName("HostCacheSize"), 89 base::StringToSizeT(base::FieldTrialList::FindFullName("HostCacheSize"),
90 &max_entries) || max_entries > kSaneMaxEntries) { 90 &max_entries);
91 if ((max_entries == 0) || (max_entries > kSaneMaxEntries))
91 max_entries = 100; 92 max_entries = 100;
92 }
93 return make_scoped_ptr(new HostCache(max_entries)); 93 return make_scoped_ptr(new HostCache(max_entries));
94 } 94 }
95 95
96 void HostCache::EvictionHandler::Handle( 96 void HostCache::EvictionHandler::Handle(
97 const Key& key, 97 const Key& key,
98 const Entry& entry, 98 const Entry& entry,
99 const base::TimeTicks& expiration, 99 const base::TimeTicks& expiration,
100 const base::TimeTicks& now, 100 const base::TimeTicks& now,
101 bool on_get) const { 101 bool on_get) const {
102 if (on_get) { 102 if (on_get) {
103 DCHECK(now >= expiration); 103 DCHECK(now >= expiration);
104 UMA_HISTOGRAM_CUSTOM_TIMES("DNS.CacheExpiredOnGet", now - expiration, 104 UMA_HISTOGRAM_CUSTOM_TIMES("DNS.CacheExpiredOnGet", now - expiration,
105 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100); 105 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100);
106 return; 106 return;
107 } 107 }
108 if (expiration > now) { 108 if (expiration > now) {
109 UMA_HISTOGRAM_CUSTOM_TIMES("DNS.CacheEvicted", expiration - now, 109 UMA_HISTOGRAM_CUSTOM_TIMES("DNS.CacheEvicted", expiration - now,
110 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100); 110 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100);
111 } else { 111 } else {
112 UMA_HISTOGRAM_CUSTOM_TIMES("DNS.CacheExpired", now - expiration, 112 UMA_HISTOGRAM_CUSTOM_TIMES("DNS.CacheExpired", now - expiration,
113 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100); 113 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100);
114 } 114 }
115 } 115 }
116 116
117 } // namespace net 117 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698