| 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 "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 void HostCache::Set(const Key& key, | 40 void 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; |
| 48 | 48 |
| 49 entries_.Put(key, Entry(error, addrlist), now, ttl); | 49 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 10 matching lines...) Expand all Loading... |
| 70 return entries_; | 70 return entries_; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // static | 73 // static |
| 74 HostCache* HostCache::CreateDefaultCache() { | 74 HostCache* HostCache::CreateDefaultCache() { |
| 75 static const size_t kMaxHostCacheEntries = 100; | 75 static const size_t kMaxHostCacheEntries = 100; |
| 76 return new HostCache(kMaxHostCacheEntries); | 76 return new HostCache(kMaxHostCacheEntries); |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace net | 79 } // namespace net |
| OLD | NEW |