Get rid of NetworkMonitorBase helper class.

All it provides is a method to call a signal on the network thread,
so it's not worth the added complexity. Implementations of
NetworkMonitorInterface must hop to the network thread anyway to
guard their members.

Also added some thread annotations to AndroidNetworkMonitor.

Bug: webrtc:9883
Change-Id: I64bb82ea593433f3a52871dbb75eb2ac4f47d69c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/181420
Commit-Queue: Taylor <deadbeef@webrtc.org>
Reviewed-by: Anders Carlsson <andersc@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32087}
This commit is contained in:
Taylor Brandstetter
2020-09-11 17:15:30 +00:00
committed by Commit Bot
parent ef8507d106
commit 32eb03a1fb
7 changed files with 116 additions and 123 deletions

View File

@ -10,40 +10,18 @@
#include "rtc_base/network_monitor.h"
#include <stdint.h>
#include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h"
namespace {
const uint32_t UPDATE_NETWORKS_MESSAGE = 1;
} // namespace
namespace rtc {
NetworkMonitorInterface::NetworkMonitorInterface() {}
const char* NetworkPreferenceToString(NetworkPreference preference) {
switch (preference) {
case NetworkPreference::NEUTRAL:
return "NEUTRAL";
case NetworkPreference::NOT_PREFERRED:
return "NOT_PREFERRED";
}
}
NetworkMonitorInterface::NetworkMonitorInterface() {}
NetworkMonitorInterface::~NetworkMonitorInterface() {}
NetworkMonitorBase::NetworkMonitorBase()
: MessageHandler(false), worker_thread_(Thread::Current()) {}
NetworkMonitorBase::~NetworkMonitorBase() {
worker_thread_->Clear(this);
}
void NetworkMonitorBase::OnNetworksChanged() {
RTC_LOG(LS_VERBOSE) << "Network change is received at the network monitor";
worker_thread_->Post(RTC_FROM_HERE, this, UPDATE_NETWORKS_MESSAGE);
}
void NetworkMonitorBase::OnMessage(Message* msg) {
RTC_DCHECK(msg->message_id == UPDATE_NETWORKS_MESSAGE);
SignalNetworksChanged();
}
AdapterType NetworkMonitorBase::GetVpnUnderlyingAdapterType(
const std::string& interface_name) {
return ADAPTER_TYPE_UNKNOWN;
}
} // namespace rtc