Removing NetworkMonitorFactory static global.

It's now passed through CreatePeerConnectionFactory like all similar
injectable dependencies.

Also removing network_monitor.h from native_api/base, since clients
should all be moved to the new location now.

Bug: webrtc:9883
Change-Id: I3776262ce2a2a380d01c163f4d18a0dfad4b5b41
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/181401
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@{#31931}
This commit is contained in:
Taylor Brandstetter
2020-08-12 01:58:10 +00:00
committed by Commit Bot
parent 95a19cae2c
commit 07fc24d9a3
6 changed files with 4 additions and 68 deletions

View File

@ -845,15 +845,11 @@ void BasicNetworkManager::StopUpdating() {
}
void BasicNetworkManager::StartNetworkMonitor() {
NetworkMonitorFactory* factory = network_monitor_factory_;
if (factory == nullptr) {
factory = NetworkMonitorFactory::GetFactory();
if (factory == nullptr) {
if (network_monitor_factory_ == nullptr) {
return;
}
}
if (!network_monitor_) {
network_monitor_.reset(factory->CreateNetworkMonitor());
network_monitor_.reset(network_monitor_factory_->CreateNetworkMonitor());
if (!network_monitor_) {
return;
}

View File

@ -12,9 +12,6 @@
#define RTC_BASE_NETWORK_MONITOR_H_
#include "rtc_base/network_constants.h"
// TODO(deadbeef): Remove this include when downstream code stops using
// NetworkMonitorFactory::SetFactory.
#include "rtc_base/network_monitor_factory.h"
#include "rtc_base/third_party/sigslot/sigslot.h"
#include "rtc_base/thread.h"
@ -64,8 +61,7 @@ class NetworkBinderInterface {
*
* Memory consideration:
* NetworkMonitor is owned by the caller (NetworkManager). The global network
* monitor factory is owned by the factory itself but needs to be released from
* the factory creator.
* monitor factory is owned by the PeerConnectionFactory.
*/
// Generic network monitor interface. It starts and stops monitoring network
// changes, and fires the SignalNetworksChanged event when networks change.

View File

@ -10,33 +10,9 @@
#include "rtc_base/network_monitor_factory.h"
namespace {
// This is set by NetworkMonitorFactory::SetFactory and the caller of
// NetworkMonitorFactory::SetFactory must be responsible for calling
// ReleaseFactory to destroy the factory.
rtc::NetworkMonitorFactory* network_monitor_factory = nullptr;
} // namespace
namespace rtc {
NetworkMonitorFactory::NetworkMonitorFactory() {}
NetworkMonitorFactory::~NetworkMonitorFactory() {}
void NetworkMonitorFactory::SetFactory(NetworkMonitorFactory* factory) {
if (network_monitor_factory != nullptr) {
delete network_monitor_factory;
}
network_monitor_factory = factory;
}
void NetworkMonitorFactory::ReleaseFactory(NetworkMonitorFactory* factory) {
if (factory == network_monitor_factory) {
SetFactory(nullptr);
}
}
NetworkMonitorFactory* NetworkMonitorFactory::GetFactory() {
return network_monitor_factory;
}
} // namespace rtc

View File

@ -24,15 +24,6 @@ class NetworkMonitorInterface;
*/
class NetworkMonitorFactory {
public:
// This is not thread-safe; it should be called once (or once per audio/video
// call) during the call initialization.
// DEPRECATED: Should pass NetworkMonitorFactory through
// PeerConnectionFactoryDependencies instead.
static void SetFactory(NetworkMonitorFactory* factory);
static void ReleaseFactory(NetworkMonitorFactory* factory);
static NetworkMonitorFactory* GetFactory();
virtual NetworkMonitorInterface* CreateNetworkMonitor() = 0;
virtual ~NetworkMonitorFactory();

View File

@ -849,16 +849,11 @@ if (current_os == "linux" || is_android) {
sources = [
"native_api/base/init.cc",
"native_api/base/init.h",
"native_api/base/network_monitor.h",
]
deps = [
":base_jni",
":native_api_jni",
# TODO(deadbeef): Remove this once clients start depending on
# native_network_monitor directly.
":native_api_network_monitor",
"//rtc_base",
"//rtc_base:checks",
]

View File

@ -1,18 +0,0 @@
/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef SDK_ANDROID_NATIVE_API_BASE_NETWORK_MONITOR_H_
#define SDK_ANDROID_NATIVE_API_BASE_NETWORK_MONITOR_H_
// TODO(deadbeef): Remove this forwarding header once clients switch to the
// new one.
#include "sdk/android/native_api/network_monitor/network_monitor.h"
#endif // SDK_ANDROID_NATIVE_API_BASE_NETWORK_MONITOR_H_