Make NetworkIsolationKey a mandatory HostCache::Key constructor argument
It has been optional, but now that all the calls that need a meaningful
NetworkIsolationKey argument have one, can make it mandatory and fill in
the remaining callsites with an empty NIK.
Bug: 997049
Change-Id: I9cc2809a0d67fe4298b122642bf1a502759f6871
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1913270
Reviewed-by: Eric Orth <ericorth@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715863}
diff --git a/components/cronet/android/test/experimental_options_test.cc b/components/cronet/android/test/experimental_options_test.cc
index bbc877e..3c388eb 100644
--- a/components/cronet/android/test/experimental_options_test.cc
+++ b/components/cronet/android/test/experimental_options_test.cc
@@ -13,6 +13,7 @@
#include "components/cronet/android/test/cronet_test_util.h"
#include "net/base/address_family.h"
#include "net/base/net_errors.h"
+#include "net/base/network_isolation_key.h"
#include "net/dns/host_cache.h"
#include "net/dns/host_resolver.h"
#include "net/dns/host_resolver_source.h"
@@ -34,10 +35,12 @@
// Create multiple keys to ensure the test works in a variety of network
// conditions.
net::HostCache::Key key1(hostname, net::DnsQueryType::UNSPECIFIED, 0,
- net::HostResolverSource::ANY);
+ net::HostResolverSource::ANY,
+ net::NetworkIsolationKey());
net::HostCache::Key key2(hostname, net::DnsQueryType::A,
net::HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6,
- net::HostResolverSource::ANY);
+ net::HostResolverSource::ANY,
+ net::NetworkIsolationKey());
net::IPAddress address;
CHECK(address.AssignFromIPLiteral(address_string));
diff --git a/components/cronet/host_cache_persistence_manager_unittest.cc b/components/cronet/host_cache_persistence_manager_unittest.cc
index 6464ba6e..58032d2 100644
--- a/components/cronet/host_cache_persistence_manager_unittest.cc
+++ b/components/cronet/host_cache_persistence_manager_unittest.cc
@@ -10,6 +10,7 @@
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "net/base/net_errors.h"
+#include "net/base/network_isolation_key.h"
#include "net/dns/host_cache.h"
#include "net/dns/host_resolver_source.h"
#include "net/dns/public/dns_query_type.h"
@@ -36,7 +37,8 @@
// assumed to work (it's tested in net/dns/host_cache_unittest.cc).
void WriteToCache(const std::string& host) {
net::HostCache::Key key(host, net::DnsQueryType::UNSPECIFIED, 0,
- net::HostResolverSource::ANY);
+ net::HostResolverSource::ANY,
+ net::NetworkIsolationKey());
net::HostCache::Entry entry(net::OK, net::AddressList(),
net::HostCache::Entry::SOURCE_UNKNOWN);
cache_->Set(key, entry, base::TimeTicks::Now(),
@@ -64,11 +66,14 @@
net::HostCache temp_cache(10);
net::HostCache::Key key1("1", net::DnsQueryType::UNSPECIFIED, 0,
- net::HostResolverSource::ANY);
+ net::HostResolverSource::ANY,
+ net::NetworkIsolationKey());
net::HostCache::Key key2("2", net::DnsQueryType::UNSPECIFIED, 0,
- net::HostResolverSource::ANY);
+ net::HostResolverSource::ANY,
+ net::NetworkIsolationKey());
net::HostCache::Key key3("3", net::DnsQueryType::UNSPECIFIED, 0,
- net::HostResolverSource::ANY);
+ net::HostResolverSource::ANY,
+ net::NetworkIsolationKey());
net::HostCache::Entry entry(net::OK, net::AddressList(),
net::HostCache::Entry::SOURCE_UNKNOWN);
diff --git a/components/cronet/stale_host_resolver_unittest.cc b/components/cronet/stale_host_resolver_unittest.cc
index a6f1cba2..e469923 100644
--- a/components/cronet/stale_host_resolver_unittest.cc
+++ b/components/cronet/stale_host_resolver_unittest.cc
@@ -27,6 +27,7 @@
#include "net/base/mock_network_change_notifier.h"
#include "net/base/net_errors.h"
#include "net/base/network_change_notifier.h"
+#include "net/base/network_isolation_key.h"
#include "net/cert/cert_verifier.h"
#include "net/dns/context_host_resolver.h"
#include "net/dns/dns_config.h"
@@ -229,7 +230,8 @@
base::TimeDelta ttl(base::TimeDelta::FromSeconds(kCacheEntryTTLSec));
net::HostCache::Key key(kHostname, net::DnsQueryType::UNSPECIFIED, 0,
- net::HostResolverSource::ANY);
+ net::HostResolverSource::ANY,
+ net::NetworkIsolationKey());
net::HostCache::Entry entry(
error,
error == net::OK ? MakeAddressList(kCacheAddress) : net::AddressList(),
@@ -251,7 +253,8 @@
DCHECK(resolver_->GetHostCache());
net::HostCache::Key key(kHostname, net::DnsQueryType::UNSPECIFIED, 0,
- net::HostResolverSource::ANY);
+ net::HostResolverSource::ANY,
+ net::NetworkIsolationKey());
base::TimeTicks now = tick_clock_.NowTicks();
net::HostCache::EntryStaleness stale;
EXPECT_TRUE(resolver_->GetHostCache()->LookupStale(key, now, &stale));
diff --git a/net/dns/host_cache.h b/net/dns/host_cache.h
index f838025d0..f0f3c03 100644
--- a/net/dns/host_cache.h
+++ b/net/dns/host_cache.h
@@ -48,13 +48,11 @@
class NET_EXPORT HostCache {
public:
struct NET_EXPORT Key {
- // TODO(mmenke): Make |network_isolation_key| mandatory.
Key(const std::string& hostname,
DnsQueryType dns_query_type,
HostResolverFlags host_resolver_flags,
HostResolverSource host_resolver_source,
- const NetworkIsolationKey& network_isolation_key =
- NetworkIsolationKey());
+ const NetworkIsolationKey& network_isolation_key);
Key();
Key(const Key& key);
Key(Key&& key);
diff --git a/net/dns/host_cache_unittest.cc b/net/dns/host_cache_unittest.cc
index b66fd635..cf366914 100644
--- a/net/dns/host_cache_unittest.cc
+++ b/net/dns/host_cache_unittest.cc
@@ -15,6 +15,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
+#include "net/base/network_isolation_key.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -1068,8 +1069,8 @@
base::TimeTicks now;
base::TimeDelta ttl = base::TimeDelta::FromSeconds(99);
- HostCache::Key key("example.com", DnsQueryType::A, 0,
- HostResolverSource::DNS);
+ HostCache::Key key("example.com", DnsQueryType::A, 0, HostResolverSource::DNS,
+ NetworkIsolationKey());
key.secure = true;
const std::string kEsniKey = "a";
@@ -1117,7 +1118,7 @@
base::TimeDelta ttl = base::TimeDelta::FromSeconds(99);
HostCache::Key key("example.com", DnsQueryType::A, 0,
- HostResolverSource::DNS);
+ HostResolverSource::DNS, NetworkIsolationKey());
key.secure = true;
const std::string esni_key = "a";
diff --git a/services/network/network_context_unittest.cc b/services/network/network_context_unittest.cc
index d0cff17..9b6e7bbf 100644
--- a/services/network/network_context_unittest.cc
+++ b/services/network/network_context_unittest.cc
@@ -1516,7 +1516,8 @@
for (const auto* domain : kDomains) {
host_cache->Set(
net::HostCache::Key(domain, net::DnsQueryType::UNSPECIFIED, 0,
- net::HostResolverSource::ANY),
+ net::HostResolverSource::ANY,
+ net::NetworkIsolationKey()),
net::HostCache::Entry(net::OK, net::AddressList(),
net::HostCache::Entry::SOURCE_UNKNOWN),
base::TimeTicks::Now(), base::TimeDelta::FromDays(1));