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 11065052: [net] Add AsyncDNS.TTL histogram. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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
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 "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 19 matching lines...) Expand all
30 30
31 const HostCache::Entry* HostCache::Lookup(const Key& key, 31 const HostCache::Entry* HostCache::Lookup(const Key& key,
32 base::TimeTicks now) { 32 base::TimeTicks now) {
33 DCHECK(CalledOnValidThread()); 33 DCHECK(CalledOnValidThread());
34 if (caching_is_disabled()) 34 if (caching_is_disabled())
35 return NULL; 35 return NULL;
36 36
37 return entries_.Get(key, now); 37 return entries_.Get(key, now);
38 } 38 }
39 39
40 void HostCache::Set(const Key& key, 40 HostCache::Entry* HostCache::Set(const Key& key,
41 int error, 41 int error,
42 const AddressList& addrlist, 42 const AddressList& addrlist,
43 base::TimeTicks now, 43 base::TimeTicks now,
44 base::TimeDelta ttl) { 44 base::TimeDelta ttl) {
45 DCHECK(CalledOnValidThread()); 45 DCHECK(CalledOnValidThread());
46 if (caching_is_disabled()) 46 if (caching_is_disabled())
47 return; 47 return NULL;
48 48
49 entries_.Put(key, Entry(error, addrlist), now, now + ttl); 49 return entries_.Put(key, Entry(error, addrlist), now, now + ttl);
50 } 50 }
51 51
52 void HostCache::clear() { 52 void HostCache::clear() {
53 DCHECK(CalledOnValidThread()); 53 DCHECK(CalledOnValidThread());
54 entries_.Clear(); 54 entries_.Clear();
55 } 55 }
56 56
57 size_t HostCache::size() const { 57 size_t HostCache::size() const {
58 DCHECK(CalledOnValidThread()); 58 DCHECK(CalledOnValidThread());
59 return entries_.size(); 59 return entries_.size();
(...skipping 17 matching lines...) Expand all
77 // http://crbug.com/143454 77 // http://crbug.com/143454
78 // TODO(szym): Determine the best size. http://crbug.com/114277 78 // TODO(szym): Determine the best size. http://crbug.com/114277
79 static const size_t kMaxHostCacheEntries = 1000; 79 static const size_t kMaxHostCacheEntries = 1000;
80 #else 80 #else
81 static const size_t kMaxHostCacheEntries = 100; 81 static const size_t kMaxHostCacheEntries = 100;
82 #endif 82 #endif
83 return new HostCache(kMaxHostCacheEntries); 83 return new HostCache(kMaxHostCacheEntries);
84 } 84 }
85 85
86 } // namespace net 86 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698