Change AndroidNetworkMonitor::NotifyConnectionTypeChanged to use Invoke

This is consistent with other Notify methods in this class, which
handle callbacks from java using blocking invokes to the network
thread.

This eliminates the use of the deprecated AsyncInvoker class.

Bug: webrtc:12339
Change-Id: Ib2d19b37b8f669df5b97e89d720f6eb6fc9e5517
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/209181
Reviewed-by: Taylor <deadbeef@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33398}
This commit is contained in:
Niels Möller
2021-03-02 11:22:59 +01:00
committed by Commit Bot
parent 82a94125a4
commit c81665cf9d
2 changed files with 2 additions and 4 deletions

View File

@ -524,7 +524,7 @@ AndroidNetworkMonitorFactory::CreateNetworkMonitor() {
void AndroidNetworkMonitor::NotifyConnectionTypeChanged( void AndroidNetworkMonitor::NotifyConnectionTypeChanged(
JNIEnv* env, JNIEnv* env,
const JavaRef<jobject>& j_caller) { const JavaRef<jobject>& j_caller) {
invoker_.AsyncInvoke<void>(RTC_FROM_HERE, network_thread_, [this] { network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
RTC_LOG(LS_INFO) RTC_LOG(LS_INFO)
<< "Android network monitor detected connection type change."; << "Android network monitor detected connection type change.";
SignalNetworksChanged(); SignalNetworksChanged();

View File

@ -17,7 +17,6 @@
#include <vector> #include <vector>
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "rtc_base/async_invoker.h"
#include "rtc_base/network_monitor.h" #include "rtc_base/network_monitor.h"
#include "rtc_base/network_monitor_factory.h" #include "rtc_base/network_monitor_factory.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
@ -117,7 +116,7 @@ class AndroidNetworkMonitor : public rtc::NetworkMonitorInterface,
const int android_sdk_int_; const int android_sdk_int_;
ScopedJavaGlobalRef<jobject> j_application_context_; ScopedJavaGlobalRef<jobject> j_application_context_;
ScopedJavaGlobalRef<jobject> j_network_monitor_; ScopedJavaGlobalRef<jobject> j_network_monitor_;
rtc::Thread* network_thread_; rtc::Thread* const network_thread_;
bool started_ RTC_GUARDED_BY(network_thread_) = false; bool started_ RTC_GUARDED_BY(network_thread_) = false;
std::map<std::string, rtc::AdapterType> adapter_type_by_name_ std::map<std::string, rtc::AdapterType> adapter_type_by_name_
RTC_GUARDED_BY(network_thread_); RTC_GUARDED_BY(network_thread_);
@ -132,7 +131,6 @@ class AndroidNetworkMonitor : public rtc::NetworkMonitorInterface,
bool find_network_handle_without_ipv6_temporary_part_ bool find_network_handle_without_ipv6_temporary_part_
RTC_GUARDED_BY(network_thread_) = false; RTC_GUARDED_BY(network_thread_) = false;
bool surface_cellular_types_ RTC_GUARDED_BY(network_thread_) = false; bool surface_cellular_types_ RTC_GUARDED_BY(network_thread_) = false;
rtc::AsyncInvoker invoker_;
}; };
class AndroidNetworkMonitorFactory : public rtc::NetworkMonitorFactory { class AndroidNetworkMonitorFactory : public rtc::NetworkMonitorFactory {