| 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/dns/host_cache.h" | 5 #include "net/dns/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_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/trace_event/trace_event.h" |
| 11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 12 | 13 |
| 13 namespace net { | 14 namespace net { |
| 14 | 15 |
| 15 //----------------------------------------------------------------------------- | 16 //----------------------------------------------------------------------------- |
| 16 | 17 |
| 17 HostCache::Entry::Entry(int error, const AddressList& addrlist, | 18 HostCache::Entry::Entry(int error, const AddressList& addrlist, |
| 18 base::TimeDelta ttl) | 19 base::TimeDelta ttl) |
| 19 : error(error), | 20 : error(error), |
| 20 addrlist(addrlist), | 21 addrlist(addrlist), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 46 if (caching_is_disabled()) | 47 if (caching_is_disabled()) |
| 47 return NULL; | 48 return NULL; |
| 48 | 49 |
| 49 return entries_.Get(key, now); | 50 return entries_.Get(key, now); |
| 50 } | 51 } |
| 51 | 52 |
| 52 void HostCache::Set(const Key& key, | 53 void HostCache::Set(const Key& key, |
| 53 const Entry& entry, | 54 const Entry& entry, |
| 54 base::TimeTicks now, | 55 base::TimeTicks now, |
| 55 base::TimeDelta ttl) { | 56 base::TimeDelta ttl) { |
| 57 TRACE_EVENT0("net", "HostCache::Set"); |
| 56 DCHECK(CalledOnValidThread()); | 58 DCHECK(CalledOnValidThread()); |
| 57 if (caching_is_disabled()) | 59 if (caching_is_disabled()) |
| 58 return; | 60 return; |
| 59 | 61 |
| 60 entries_.Put(key, entry, now, now + ttl); | 62 entries_.Put(key, entry, now, now + ttl); |
| 61 } | 63 } |
| 62 | 64 |
| 63 void HostCache::clear() { | 65 void HostCache::clear() { |
| 64 DCHECK(CalledOnValidThread()); | 66 DCHECK(CalledOnValidThread()); |
| 65 entries_.Clear(); | 67 entries_.Clear(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 if (expiration > now) { | 115 if (expiration > now) { |
| 114 UMA_HISTOGRAM_CUSTOM_TIMES("DNS.CacheEvicted", expiration - now, | 116 UMA_HISTOGRAM_CUSTOM_TIMES("DNS.CacheEvicted", expiration - now, |
| 115 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100); | 117 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100); |
| 116 } else { | 118 } else { |
| 117 UMA_HISTOGRAM_CUSTOM_TIMES("DNS.CacheExpired", now - expiration, | 119 UMA_HISTOGRAM_CUSTOM_TIMES("DNS.CacheExpired", now - expiration, |
| 118 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100); | 120 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100); |
| 119 } | 121 } |
| 120 } | 122 } |
| 121 | 123 |
| 122 } // namespace net | 124 } // namespace net |
| OLD | NEW |