OLD | NEW |
---|---|
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/histogram.h" | |
8 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
9 | 10 |
10 namespace net { | 11 namespace net { |
11 | 12 |
12 //----------------------------------------------------------------------------- | 13 //----------------------------------------------------------------------------- |
13 | 14 |
14 HostCache::Entry::Entry(int error, const AddressList& addrlist, | 15 HostCache::Entry::Entry(int error, const AddressList& addrlist, |
15 base::TimeDelta ttl) | 16 base::TimeDelta ttl) |
16 : error(error), | 17 : error(error), |
17 addrlist(addrlist), | 18 addrlist(addrlist), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 // Increase HostCache size for the duration of the async DNS field trial. | 85 // Increase HostCache size for the duration of the async DNS field trial. |
85 // http://crbug.com/143454 | 86 // http://crbug.com/143454 |
86 // TODO(szym): Determine the best size. http://crbug.com/114277 | 87 // TODO(szym): Determine the best size. http://crbug.com/114277 |
87 static const size_t kMaxHostCacheEntries = 1000; | 88 static const size_t kMaxHostCacheEntries = 1000; |
88 #else | 89 #else |
89 static const size_t kMaxHostCacheEntries = 100; | 90 static const size_t kMaxHostCacheEntries = 100; |
90 #endif | 91 #endif |
91 return make_scoped_ptr(new HostCache(kMaxHostCacheEntries)); | 92 return make_scoped_ptr(new HostCache(kMaxHostCacheEntries)); |
92 } | 93 } |
93 | 94 |
95 void HostCache::EvictionHandler::handle( | |
96 const Key& key, | |
97 const Entry& entry, | |
98 const base::TimeTicks& expiration, | |
99 const base::TimeTicks& now, | |
100 bool onGet) const { | |
101 if (onGet) { | |
102 DCHECK(now >= expiration); | |
103 UMA_HISTOGRAM_CUSTOM_TIMES("DNS.CacheExpiredOnGet", now - expiration, | |
104 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100); | |
jar (doing other things)
2012/11/05 17:44:56
nit: early returns tend to make this sort of code
| |
105 } else if (expiration > now) { | |
106 UMA_HISTOGRAM_CUSTOM_TIMES("DNS.CacheEvicted", expiration - now, | |
107 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100); | |
108 } else { | |
109 UMA_HISTOGRAM_CUSTOM_TIMES("DNS.CacheExpired", now - expiration, | |
110 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100); | |
111 } | |
112 } | |
113 | |
94 } // namespace net | 114 } // namespace net |
OLD | NEW |