Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: components/cronet/stale_host_resolver_unittest.cc

Issue 2785563002: Expire but don't clear HostCache on DNS config change (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/base/network_change_notifier.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/cronet/stale_host_resolver.h" 5 #include "components/cronet/stale_host_resolver.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 base::TimeDelta ttl(base::TimeDelta::FromSeconds(kCacheEntryTTLSec)); 156 base::TimeDelta ttl(base::TimeDelta::FromSeconds(kCacheEntryTTLSec));
157 net::HostCache::Key key(kHostname, net::ADDRESS_FAMILY_IPV4, 0); 157 net::HostCache::Key key(kHostname, net::ADDRESS_FAMILY_IPV4, 0);
158 net::HostCache::Entry entry(net::OK, MakeAddressList(kCacheAddress), ttl); 158 net::HostCache::Entry entry(net::OK, MakeAddressList(kCacheAddress), ttl);
159 base::TimeDelta age = base::TimeDelta::FromSeconds(age_sec); 159 base::TimeDelta age = base::TimeDelta::FromSeconds(age_sec);
160 base::TimeTicks then = base::TimeTicks::Now() - age; 160 base::TimeTicks then = base::TimeTicks::Now() - age;
161 resolver_->GetHostCache()->Set(key, entry, then, ttl); 161 resolver_->GetHostCache()->Set(key, entry, then, ttl);
162 } 162 }
163 163
164 void OnNetworkChange() { 164 void OnNetworkChange() {
165 // Real network changes on Android will send both notifications.
165 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); 166 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
167 net::NetworkChangeNotifier::NotifyObserversOfDNSChangeForTests();
166 base::RunLoop().RunUntilIdle(); // Wait for notification. 168 base::RunLoop().RunUntilIdle(); // Wait for notification.
167 } 169 }
168 170
169 void LookupStale() { 171 void LookupStale() {
170 DCHECK(resolver_); 172 DCHECK(resolver_);
171 DCHECK(resolver_->GetHostCache()); 173 DCHECK(resolver_->GetHostCache());
172 174
173 net::HostCache::Key key(kHostname, net::ADDRESS_FAMILY_IPV4, 0); 175 net::HostCache::Key key(kHostname, net::ADDRESS_FAMILY_IPV4, 0);
174 base::TimeTicks now = base::TimeTicks::Now(); 176 base::TimeTicks now = base::TimeTicks::Now();
175 const net::HostCache::Entry* entry; 177 const net::HostCache::Entry* entry;
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 505
504 EXPECT_TRUE(resolve_complete()); 506 EXPECT_TRUE(resolve_complete());
505 EXPECT_EQ(net::OK, resolve_error()); 507 EXPECT_EQ(net::OK, resolve_error());
506 EXPECT_EQ(1u, resolve_addresses().size()); 508 EXPECT_EQ(1u, resolve_addresses().size());
507 EXPECT_EQ(kCacheAddress, resolve_addresses()[0].ToStringWithoutPort()); 509 EXPECT_EQ(kCacheAddress, resolve_addresses()[0].ToStringWithoutPort());
508 } 510 }
509 511
510 } // namespace 512 } // namespace
511 513
512 } // namespace cronet 514 } // namespace cronet
OLDNEW
« no previous file with comments | « no previous file | net/base/network_change_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698