blob: 709e9dfbe5c90892a4c1b6cc39a6c7d77c321263 [file] [log] [blame]
* Copyright 2020 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.
#include <vector>
#include "absl/strings/string_view.h"
#include "api/field_trials_view.h"
#include "api/sequence_checker.h"
#include "api/task_queue/pending_task_safety_flag.h"
#include "rtc_base/network_monitor.h"
#include "rtc_base/network_monitor_factory.h"
#include "rtc_base/string_utils.h"
#include "rtc_base/thread.h"
#include "rtc_base/thread_annotations.h"
#include "sdk/objc/components/network/RTCNetworkMonitor+Private.h"
#include "sdk/objc/native/src/network_monitor_observer.h"
namespace webrtc {
class ObjCNetworkMonitorFactory : public rtc::NetworkMonitorFactory {
ObjCNetworkMonitorFactory() = default;
~ObjCNetworkMonitorFactory() override = default;
rtc::NetworkMonitorInterface* CreateNetworkMonitor(
const FieldTrialsView& field_trials) override;
class ObjCNetworkMonitor : public rtc::NetworkMonitorInterface,
public NetworkMonitorObserver {
~ObjCNetworkMonitor() override;
void Start() override;
void Stop() override;
InterfaceInfo GetInterfaceInfo(absl::string_view interface_name) override;
// NetworkMonitorObserver override.
// Fans out updates to observers on the correct thread.
void OnPathUpdate(
std::map<std::string, rtc::AdapterType, rtc::AbslStringViewCmp>
adapter_type_by_name) override;
rtc::Thread* thread_ = nullptr;
bool started_ = false;
std::map<std::string, rtc::AdapterType, rtc::AbslStringViewCmp>
adapter_type_by_name_ RTC_GUARDED_BY(thread_);
rtc::scoped_refptr<PendingTaskSafetyFlag> safety_flag_;
RTCNetworkMonitor* network_monitor_ = nil;
} // namespace webrtc