Revert "Reland "Pass NetworkMonitorFactory through PeerConnectionFactory.""

This reverts commit 7ded73351870bfb45160fa6b9db71a94fe49397b.

Reason for revert: Found more code calling NetworkMonitorFactory::SetFactory...

Original change's description:
> Reland "Pass NetworkMonitorFactory through PeerConnectionFactory."
> 
> This is a reland of 003c9be817817ed0e3aef3f50c78ae5cb31bc0ff
> 
> Original change's description:
> > Pass NetworkMonitorFactory through PeerConnectionFactory.
> >
> > Previously the instance was set through a static method, which was
> > really only done because it was difficult to add new
> > PeerConnectionFactory construction arguments at the time.
> >
> > Now that we have PeerConnectionFactoryDependencies it's easy to clean
> > this up.
> >
> > I'm doing this because I plan to add a NetworkMonitor implementation
> > for iOS, and don't want to inherit this ugliness.
> >
> > Bug: webrtc:9883
> > Change-Id: Id94dc061ab1c7186b81af8547393a6e336ff04c2
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180241
> > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> > Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
> > Commit-Queue: Taylor <deadbeef@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#31815}
> 
> TBR=hta@webrtc.org, sakal@webrtc.org
> 
> Bug: webrtc:9883
> Change-Id: Ibf69a22e8f94226908636c7d50ff9eda65bd4129
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180720
> Reviewed-by: Taylor <deadbeef@webrtc.org>
> Commit-Queue: Taylor <deadbeef@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31822}

TBR=deadbeef@webrtc.org,sakal@webrtc.org,hta@webrtc.org

Change-Id: Iae51b94072cec9abc021eed4e51d1fbeee998adc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9883
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180721
Reviewed-by: Taylor <deadbeef@webrtc.org>
Commit-Queue: Taylor <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31823}
This commit is contained in:
Taylor
2020-07-31 22:39:26 +00:00
committed by Commit Bot
parent 7ded733518
commit cfba4ffe31
21 changed files with 155 additions and 176 deletions

View File

@ -23,11 +23,8 @@
#include "rtc_base/mdns_responder_interface.h"
#include "rtc_base/message_handler.h"
#include "rtc_base/network_monitor.h"
#include "rtc_base/network_monitor_factory.h"
#include "rtc_base/synchronization/sequence_checker.h"
#include "rtc_base/system/rtc_export.h"
#include "rtc_base/third_party/sigslot/sigslot.h"
#include "rtc_base/thread_annotations.h"
#if defined(WEBRTC_POSIX)
struct ifaddrs;
@ -224,7 +221,6 @@ class RTC_EXPORT BasicNetworkManager : public NetworkManagerBase,
public sigslot::has_slots<> {
public:
BasicNetworkManager();
explicit BasicNetworkManager(NetworkMonitorFactory* network_monitor_factory);
~BasicNetworkManager() override;
void StartUpdating() override;
@ -238,9 +234,7 @@ class RTC_EXPORT BasicNetworkManager : public NetworkManagerBase,
// Sets the network ignore list, which is empty by default. Any network on the
// ignore list will be filtered from network enumeration results.
// Should be called only before initialization.
void set_network_ignore_list(const std::vector<std::string>& list) {
RTC_DCHECK(thread_ == nullptr);
network_ignore_list_ = list;
}
@ -250,45 +244,41 @@ class RTC_EXPORT BasicNetworkManager : public NetworkManagerBase,
void ConvertIfAddrs(ifaddrs* interfaces,
IfAddrsConverter* converter,
bool include_ignored,
NetworkList* networks) const RTC_RUN_ON(thread_);
NetworkList* networks) const;
#endif // defined(WEBRTC_POSIX)
// Creates a network object for each network available on the machine.
bool CreateNetworks(bool include_ignored, NetworkList* networks) const
RTC_RUN_ON(thread_);
bool CreateNetworks(bool include_ignored, NetworkList* networks) const;
// Determines if a network should be ignored. This should only be determined
// based on the network's property instead of any individual IP.
bool IsIgnoredNetwork(const Network& network) const RTC_RUN_ON(thread_);
bool IsIgnoredNetwork(const Network& network) const;
// This function connects a UDP socket to a public address and returns the
// local address associated it. Since it binds to the "any" address
// internally, it returns the default local address on a multi-homed endpoint.
IPAddress QueryDefaultLocalAddress(int family) const RTC_RUN_ON(thread_);
IPAddress QueryDefaultLocalAddress(int family) const;
private:
friend class NetworkTest;
// Creates a network monitor and listens for network updates.
void StartNetworkMonitor() RTC_RUN_ON(thread_);
void StartNetworkMonitor();
// Stops and removes the network monitor.
void StopNetworkMonitor() RTC_RUN_ON(thread_);
void StopNetworkMonitor();
// Called when it receives updates from the network monitor.
void OnNetworksChanged();
// Updates the networks and reschedules the next update.
void UpdateNetworksContinually() RTC_RUN_ON(thread_);
void UpdateNetworksContinually();
// Only updates the networks; does not reschedule the next update.
void UpdateNetworksOnce() RTC_RUN_ON(thread_);
void UpdateNetworksOnce();
Thread* thread_ = nullptr;
bool sent_first_update_ = true;
int start_count_ = 0;
Thread* thread_;
bool sent_first_update_;
int start_count_;
std::vector<std::string> network_ignore_list_;
NetworkMonitorFactory* network_monitor_factory_ RTC_GUARDED_BY(thread_) =
nullptr;
std::unique_ptr<NetworkMonitorInterface> network_monitor_
RTC_GUARDED_BY(thread_);
std::unique_ptr<NetworkMonitorInterface> network_monitor_;
};
// Represents a Unix-type network interface, with a name and single address.