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/mock_host_resolver.h" | 5 #include "net/base/mock_host_resolver.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 &addr, | 164 &addr, |
165 NULL); | 165 NULL); |
166 if (cache_.get()) { | 166 if (cache_.get()) { |
167 HostCache::Key key(info.hostname(), | 167 HostCache::Key key(info.hostname(), |
168 info.address_family(), | 168 info.address_family(), |
169 info.host_resolver_flags()); | 169 info.host_resolver_flags()); |
170 // Storing a failure with TTL 0 so that it overwrites previous value. | 170 // Storing a failure with TTL 0 so that it overwrites previous value. |
171 base::TimeDelta ttl; | 171 base::TimeDelta ttl; |
172 if (rv == OK) | 172 if (rv == OK) |
173 ttl = base::TimeDelta::FromSeconds(kCacheEntryTTLSeconds); | 173 ttl = base::TimeDelta::FromSeconds(kCacheEntryTTLSeconds); |
174 cache_->Set(key, rv, addr, base::TimeTicks::Now(), ttl); | 174 cache_->Set(key, HostCache::Entry(rv, addr), base::TimeTicks::Now(), ttl); |
175 } | 175 } |
176 if (rv == OK) { | 176 if (rv == OK) { |
177 *addresses = addr; | 177 *addresses = addr; |
178 SetPortOnAddressList(info.port(), addresses); | 178 SetPortOnAddressList(info.port(), addresses); |
179 } | 179 } |
180 return rv; | 180 return rv; |
181 } | 181 } |
182 | 182 |
183 void MockHostResolverBase::ResolveNow(size_t id) { | 183 void MockHostResolverBase::ResolveNow(size_t id) { |
184 RequestMap::iterator it = requests_.find(id); | 184 RequestMap::iterator it = requests_.find(id); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 CHECK_EQ(old_proc, current_proc_); | 390 CHECK_EQ(old_proc, current_proc_); |
391 } | 391 } |
392 | 392 |
393 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { | 393 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { |
394 current_proc_ = proc; | 394 current_proc_ = proc; |
395 previous_proc_ = HostResolverProc::SetDefault(current_proc_); | 395 previous_proc_ = HostResolverProc::SetDefault(current_proc_); |
396 current_proc_->SetLastProc(previous_proc_); | 396 current_proc_->SetLastProc(previous_proc_); |
397 } | 397 } |
398 | 398 |
399 } // namespace net | 399 } // namespace net |
OLD | NEW |