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/field_trial.h" | |
9 #include "base/string_number_conversions.h" | |
8 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
9 | 11 |
10 namespace net { | 12 namespace net { |
11 | 13 |
12 //----------------------------------------------------------------------------- | 14 //----------------------------------------------------------------------------- |
13 | 15 |
14 HostCache::Entry::Entry(int error, const AddressList& addrlist, | 16 HostCache::Entry::Entry(int error, const AddressList& addrlist, |
15 base::TimeDelta ttl) | 17 base::TimeDelta ttl) |
16 : error(error), | 18 : error(error), |
17 addrlist(addrlist), | 19 addrlist(addrlist), |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 DCHECK(CalledOnValidThread()); | 79 DCHECK(CalledOnValidThread()); |
78 return entries_; | 80 return entries_; |
79 } | 81 } |
80 | 82 |
81 // static | 83 // static |
82 scoped_ptr<HostCache> HostCache::CreateDefaultCache() { | 84 scoped_ptr<HostCache> HostCache::CreateDefaultCache() { |
83 #if defined(OS_CHROMEOS) | 85 #if defined(OS_CHROMEOS) |
84 // Increase HostCache size for the duration of the async DNS field trial. | 86 // Increase HostCache size for the duration of the async DNS field trial. |
85 // http://crbug.com/143454 | 87 // http://crbug.com/143454 |
86 // TODO(szym): Determine the best size. http://crbug.com/114277 | 88 // TODO(szym): Determine the best size. http://crbug.com/114277 |
87 static const size_t kMaxHostCacheEntries = 1000; | 89 size_t max_entries = 1000; |
88 #else | 90 #else |
89 static const size_t kMaxHostCacheEntries = 100; | 91 const size_t kSaneMaxEntries = 1 << 20; |
92 size_t max_entries = 0; | |
93 if (!base::StringToSizeT(base::FieldTrialList::FindFullName("HostCacheSize"), | |
94 &max_entries) || max_entries > kSaneMaxEntries) { | |
mmenke
2012/11/07 16:11:00
How are we going to handle recording histograms on
szym
2012/11/07 16:22:42
My bad, I forgot to remove the #ifdef. There's no
| |
95 max_entries = 100; | |
96 } | |
90 #endif | 97 #endif |
91 return make_scoped_ptr(new HostCache(kMaxHostCacheEntries)); | 98 return make_scoped_ptr(new HostCache(max_entries)); |
92 } | 99 } |
93 | 100 |
94 } // namespace net | 101 } // namespace net |
OLD | NEW |