| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/mock_host_resolver.h" | 5 #include "net/base/mock_host_resolver.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/platform_thread.h" | 8 #include "base/platform_thread.h" |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "googleurl/src/url_canon_ip.h" | 10 #include "googleurl/src/url_canon_ip.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 rules_ = new RuleBasedHostResolverProc(catchall); | 86 rules_ = new RuleBasedHostResolverProc(catchall); |
| 87 | 87 |
| 88 HostResolverProc* proc = rules_; | 88 HostResolverProc* proc = rules_; |
| 89 | 89 |
| 90 // Lastly add the provided interceptor to the front of the chain. | 90 // Lastly add the provided interceptor to the front of the chain. |
| 91 if (interceptor) { | 91 if (interceptor) { |
| 92 interceptor->set_previous_proc(proc); | 92 interceptor->set_previous_proc(proc); |
| 93 proc = interceptor; | 93 proc = interceptor; |
| 94 } | 94 } |
| 95 | 95 |
| 96 int max_cache_entries = use_caching_ ? 100 : 0; | 96 HostCache* cache = NULL; |
| 97 int max_cache_age_ms = use_caching_ ? 60000 : 0; | |
| 98 | 97 |
| 99 impl_ = new HostResolverImpl(proc, max_cache_entries, max_cache_age_ms); | 98 if (use_caching_) { |
| 99 cache = new HostCache( |
| 100 100, // max entries. |
| 101 base::TimeDelta::FromMinutes(1), |
| 102 base::TimeDelta::FromSeconds(0)); |
| 103 } |
| 104 |
| 105 impl_ = new HostResolverImpl(proc, cache); |
| 100 } | 106 } |
| 101 | 107 |
| 102 //----------------------------------------------------------------------------- | 108 //----------------------------------------------------------------------------- |
| 103 | 109 |
| 104 struct RuleBasedHostResolverProc::Rule { | 110 struct RuleBasedHostResolverProc::Rule { |
| 105 enum ResolverType { | 111 enum ResolverType { |
| 106 kResolverTypeFail, | 112 kResolverTypeFail, |
| 107 kResolverTypeSystem, | 113 kResolverTypeSystem, |
| 108 kResolverTypeIPV6Literal, | 114 kResolverTypeIPV6Literal, |
| 109 }; | 115 }; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 CHECK(old_proc == current_proc_); | 236 CHECK(old_proc == current_proc_); |
| 231 } | 237 } |
| 232 | 238 |
| 233 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { | 239 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { |
| 234 current_proc_ = proc; | 240 current_proc_ = proc; |
| 235 previous_proc_ = HostResolverProc::SetDefault(current_proc_); | 241 previous_proc_ = HostResolverProc::SetDefault(current_proc_); |
| 236 current_proc_->set_previous_proc(previous_proc_); | 242 current_proc_->set_previous_proc(previous_proc_); |
| 237 } | 243 } |
| 238 | 244 |
| 239 } // namespace net | 245 } // namespace net |
| OLD | NEW |