summaryrefslogtreecommitdiff
path: root/chromium/net/base/network_change_notifier.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-08-30 10:22:43 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-08-30 12:36:28 +0000
commit271a6c3487a14599023a9106329505597638d793 (patch)
treee040d58ffc86c1480b79ca8528020ca9ec919bf8 /chromium/net/base/network_change_notifier.h
parent7b2ffa587235a47d4094787d72f38102089f402a (diff)
downloadqtwebengine-chromium-271a6c3487a14599023a9106329505597638d793.tar.gz
BASELINE: Update Chromium to 77.0.3865.59
Change-Id: I1e89a5f3b009a9519a6705102ad65c92fe736f21 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/net/base/network_change_notifier.h')
-rw-r--r--chromium/net/base/network_change_notifier.h31
1 files changed, 23 insertions, 8 deletions
diff --git a/chromium/net/base/network_change_notifier.h b/chromium/net/base/network_change_notifier.h
index 9cf4f6f240b..e6d06cf0dcd 100644
--- a/chromium/net/base/network_change_notifier.h
+++ b/chromium/net/base/network_change_notifier.h
@@ -21,6 +21,7 @@ namespace net {
struct DnsConfig;
class NetworkChangeNotifierFactory;
struct NetworkInterface;
+class SystemDnsConfigChangeNotifier;
typedef std::vector<NetworkInterface> NetworkInterfaceList;
#if defined(OS_LINUX)
@@ -293,7 +294,7 @@ class NET_EXPORT NetworkChangeNotifier {
// monitored), but if you do create it, you must do so before any other
// threads try to access the API below, and it must outlive all other threads
// which might try to use it.
- static NetworkChangeNotifier* Create();
+ static std::unique_ptr<NetworkChangeNotifier> Create();
// Returns whether the process-wide, platform-specific NetworkChangeNotifier
// has been created.
@@ -369,6 +370,9 @@ class NET_EXPORT NetworkChangeNotifier {
// Retrieve the last read DnsConfig. This could be expensive if the system has
// a large HOSTS file.
+ //
+ // TODO(crbug.com/971411): Remove once HostResolverManager converted to
+ // directly use SystemDnsConfigChangeNotifier.
static void GetDnsConfig(DnsConfig* config);
#if defined(OS_LINUX)
@@ -402,7 +406,7 @@ class NET_EXPORT NetworkChangeNotifier {
// Like Create(), but for use in tests. The mock object doesn't monitor any
// events, it merely rebroadcasts notifications when requested.
- static NetworkChangeNotifier* CreateMock();
+ static std::unique_ptr<NetworkChangeNotifier> CreateMock();
// Registers |observer| to receive notifications of network changes. The
// thread on which this is called is the thread on which |observer| will be
@@ -509,9 +513,12 @@ class NET_EXPORT NetworkChangeNotifier {
base::TimeDelta connection_type_online_delay_;
};
- explicit NetworkChangeNotifier(
+ // If |system_dns_config_notifier| is null (the default), a shared singleton
+ // will be used that will be leaked on shutdown.
+ NetworkChangeNotifier(
const NetworkChangeCalculatorParams& params =
- NetworkChangeCalculatorParams());
+ NetworkChangeCalculatorParams(),
+ SystemDnsConfigChangeNotifier* system_dns_config_notifier = nullptr);
#if defined(OS_LINUX)
// Returns the AddressTrackerLinux if present.
@@ -550,7 +557,7 @@ class NET_EXPORT NetworkChangeNotifier {
// Stores |config| in NetworkState and notifies observers. The first
// notification will be OnInitialDNSConfigRead, and after that OnDNSChanged.
- static void SetDnsConfig(const DnsConfig& config);
+ static void SetDnsConfigForTesting(const DnsConfig& config);
// Clears previous DnsConfig, if any, to simulate the first one being set.
static void ClearDnsConfigForTesting();
@@ -559,6 +566,14 @@ class NET_EXPORT NetworkChangeNotifier {
// have the same type, return it, otherwise return CONNECTION_UNKNOWN.
static ConnectionType ConnectionTypeFromInterfaces();
+ SystemDnsConfigChangeNotifier* system_dns_config_notifier() {
+ DCHECK(system_dns_config_notifier_);
+ return system_dns_config_notifier_;
+ }
+ // Unregisters and clears |system_dns_config_notifier_|. Useful if a subclass
+ // owns the notifier and is destroying it before |this|'s destructor is called
+ void StopSystemDnsConfigNotifier();
+
// Clears the global NetworkChangeNotifier pointer. This should be called
// as early as possible in the destructor to prevent races.
void ClearGlobalPointer();
@@ -569,8 +584,8 @@ class NET_EXPORT NetworkChangeNotifier {
friend class NetworkChangeNotifierLinuxTest;
friend class NetworkChangeNotifierWinTest;
- class NetworkState;
class NetworkChangeCalculator;
+ class SystemDnsConfigObserver;
void NotifyObserversOfIPAddressChangeImpl();
void NotifyObserversOfConnectionTypeChangeImpl(ConnectionType type);
@@ -595,8 +610,8 @@ class NET_EXPORT NetworkChangeNotifier {
const scoped_refptr<base::ObserverListThreadSafe<NetworkObserver>>
network_observer_list_;
- // The current network state. Hosts DnsConfig, exposed via GetDnsConfig.
- scoped_refptr<NetworkState> network_state_;
+ SystemDnsConfigChangeNotifier* system_dns_config_notifier_;
+ std::unique_ptr<SystemDnsConfigObserver> system_dns_config_observer_;
// Computes NetworkChange signal from IPAddress and ConnectionType signals.
std::unique_ptr<NetworkChangeCalculator> network_change_calculator_;