Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

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

Issue 11359053: [net] Measure DNS.CacheEvicted and DNS.CacheExpired. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: distinguish evictions on Get and Put 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
« net/base/expiring_cache.h ('K') | « net/base/host_cache.h ('k') | 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/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
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
OLDNEW
« net/base/expiring_cache.h ('K') | « net/base/host_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698