#ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_PASSIVE_H_
#define NET_BASE_NETWORK_CHANGE_NOTIFIER_PASSIVE_H_
#include "base/gtest_prod_util.h"
#include "base/sequence_checker.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread.h"
#include "base/threading/thread_checker.h"
#include "net/base/net_export.h"
#include "net/base/network_change_notifier.h"
#if BUILDFLAG(IS_LINUX)
#include "net/base/address_map_cache_linux.h"
#endif
#if BUILDFLAG(IS_OHOS)
#include "ohos_adapter_helper.h"
#endif
namespace net {
class NET_EXPORT NetworkChangeNotifierPassive : public NetworkChangeNotifier {
public:
NetworkChangeNotifierPassive(
NetworkChangeNotifier::ConnectionType initial_connection_type,
NetworkChangeNotifier::ConnectionSubtype initial_connection_subtype);
NetworkChangeNotifierPassive(const NetworkChangeNotifierPassive&) = delete;
NetworkChangeNotifierPassive& operator=(const NetworkChangeNotifierPassive&) =
delete;
~NetworkChangeNotifierPassive() override;
void OnDNSChanged();
void OnIPAddressChanged();
void OnConnectionChanged(
NetworkChangeNotifier::ConnectionType connection_type);
void OnConnectionSubtypeChanged(
NetworkChangeNotifier::ConnectionType connection_type,
NetworkChangeNotifier::ConnectionSubtype connection_subtype);
#if BUILDFLAG(IS_OHOS) && defined(OHOS_EX_HTTP_DNS_FALLBACK)
const std::vector<std::string> GetCurrentDnsServers() override;
#endif
protected:
NetworkChangeNotifier::ConnectionType GetCurrentConnectionType()
const override;
void GetCurrentMaxBandwidthAndConnectionType(
double* max_bandwidth_mbps,
ConnectionType* connection_type) const override;
#if BUILDFLAG(IS_LINUX)
AddressMapOwnerLinux* GetAddressMapOwnerInternal() override;
#endif
private:
friend class NetworkChangeNotifierPassiveTest;
NetworkChangeNotifierPassive(
NetworkChangeNotifier::ConnectionType initial_connection_type,
NetworkChangeNotifier::ConnectionSubtype initial_connection_subtype,
SystemDnsConfigChangeNotifier* system_dns_config_notifier);
static NetworkChangeNotifier::NetworkChangeCalculatorParams
NetworkChangeCalculatorParamsPassive();
THREAD_CHECKER(thread_checker_);
#if BUILDFLAG(IS_LINUX)
AddressMapCacheLinux address_map_cache_;
#endif
mutable base::Lock lock_;
NetworkChangeNotifier::ConnectionType
connection_type_;
#if BUILDFLAG(IS_OHOS)
std::unique_ptr<OHOS::NWeb::NetConnectAdapter> ohos_net_conn_adapter_;
#endif
double max_bandwidth_mbps_;
};
#if BUILDFLAG(IS_OHOS) && defined(OHOS_EX_HTTP_DNS_FALLBACK)
mutable base::Lock dns_server_lock_;
std::vector<std::string> dns_servers_;
#endif
}
#endif