diff options
Diffstat (limited to '')
7 files changed, 38 insertions, 27 deletions
diff --git a/third_party/libwebrtc/test/network/BUILD.gn b/third_party/libwebrtc/test/network/BUILD.gn index b8255d35fd..6df563d31d 100644 --- a/third_party/libwebrtc/test/network/BUILD.gn +++ b/third_party/libwebrtc/test/network/BUILD.gn @@ -47,6 +47,7 @@ rtc_library("emulated_network") { "../../api:simulated_network_api", "../../api:time_controller", "../../api/numerics", + "../../api/task_queue", "../../api/task_queue:pending_task_safety_flag", "../../api/test/network_emulation", "../../api/transport:stun_types", @@ -67,7 +68,6 @@ rtc_library("emulated_network") { "../../rtc_base:random", "../../rtc_base:rtc_base_tests_utils", "../../rtc_base:rtc_event", - "../../rtc_base:rtc_task_queue", "../../rtc_base:safe_minmax", "../../rtc_base:socket", "../../rtc_base:socket_address", @@ -87,6 +87,7 @@ rtc_library("emulated_network") { ] absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container", + "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", @@ -117,7 +118,6 @@ if (rtc_include_tests && !build_with_chromium) { deps = [ ":emulated_network", "../:test_support", - "../../api:callfactory_api", "../../api:enable_media_with_defaults", "../../api:libjingle_peerconnection_api", "../../api:scoped_refptr", diff --git a/third_party/libwebrtc/test/network/cross_traffic_unittest.cc b/third_party/libwebrtc/test/network/cross_traffic_unittest.cc index 36aff67bb2..0f98fc9e72 100644 --- a/third_party/libwebrtc/test/network/cross_traffic_unittest.cc +++ b/third_party/libwebrtc/test/network/cross_traffic_unittest.cc @@ -55,7 +55,7 @@ struct TrafficCounterFixture { EmulatedEndpointConfig(), EmulatedNetworkStatsGatheringMode::kDefault, }, - /*is_enabled=*/true, &task_queue_, &clock}; + /*is_enabled=*/true, task_queue_.Get(), &clock}; }; } // namespace diff --git a/third_party/libwebrtc/test/network/network_emulation.cc b/third_party/libwebrtc/test/network/network_emulation.cc index f1c9ca80dd..642bf6fc7a 100644 --- a/third_party/libwebrtc/test/network/network_emulation.cc +++ b/third_party/libwebrtc/test/network/network_emulation.cc @@ -15,9 +15,11 @@ #include <memory> #include <utility> +#include "absl/base/nullability.h" #include "absl/types/optional.h" #include "api/numerics/samples_stats_counter.h" #include "api/sequence_checker.h" +#include "api/task_queue/task_queue_base.h" #include "api/test/network_emulation/network_emulation_interfaces.h" #include "api/test/network_emulation_manager.h" #include "api/units/data_size.h" @@ -330,7 +332,7 @@ void LinkEmulation::OnPacketReceived(EmulatedIpPacket packet) { return; Timestamp current_time = clock_->CurrentTime(); process_task_ = RepeatingTaskHandle::DelayedStart( - task_queue_->Get(), + task_queue_, std::max(TimeDelta::Zero(), Timestamp::Micros(*next_time_us) - current_time), [this]() { @@ -383,7 +385,7 @@ void LinkEmulation::Process(Timestamp at_time) { } } -NetworkRouterNode::NetworkRouterNode(rtc::TaskQueue* task_queue) +NetworkRouterNode::NetworkRouterNode(absl::Nonnull<TaskQueueBase*> task_queue) : task_queue_(task_queue) {} void NetworkRouterNode::OnPacketReceived(EmulatedIpPacket packet) { @@ -459,7 +461,7 @@ void NetworkRouterNode::SetFilter( EmulatedNetworkNode::EmulatedNetworkNode( Clock* clock, - rtc::TaskQueue* task_queue, + absl::Nonnull<TaskQueueBase*> task_queue, std::unique_ptr<NetworkBehaviorInterface> network_behavior, EmulatedNetworkStatsGatheringMode stats_gathering_mode) : router_(task_queue), @@ -510,10 +512,11 @@ EmulatedEndpointImpl::Options::Options( config.allow_receive_packets_with_different_dest_ip), log_name(ip.ToString() + " (" + config.name.value_or("") + ")") {} -EmulatedEndpointImpl::EmulatedEndpointImpl(const Options& options, - bool is_enabled, - rtc::TaskQueue* task_queue, - Clock* clock) +EmulatedEndpointImpl::EmulatedEndpointImpl( + const Options& options, + bool is_enabled, + absl::Nonnull<TaskQueueBase*> task_queue, + Clock* clock) : options_(options), is_enabled_(is_enabled), clock_(clock), diff --git a/third_party/libwebrtc/test/network/network_emulation.h b/third_party/libwebrtc/test/network/network_emulation.h index dffabafa7c..20705197be 100644 --- a/third_party/libwebrtc/test/network/network_emulation.h +++ b/third_party/libwebrtc/test/network/network_emulation.h @@ -19,10 +19,12 @@ #include <utility> #include <vector> +#include "absl/base/nullability.h" #include "absl/types/optional.h" #include "api/array_view.h" #include "api/numerics/samples_stats_counter.h" #include "api/sequence_checker.h" +#include "api/task_queue/task_queue_base.h" #include "api/test/network_emulation/network_emulation_interfaces.h" #include "api/test/network_emulation_manager.h" #include "api/test/simulated_network.h" @@ -145,7 +147,7 @@ class EmulatedNetworkNodeStatsBuilder { class LinkEmulation : public EmulatedNetworkReceiverInterface { public: LinkEmulation(Clock* clock, - rtc::TaskQueue* task_queue, + absl::Nonnull<TaskQueueBase*> task_queue, std::unique_ptr<NetworkBehaviorInterface> network_behavior, EmulatedNetworkReceiverInterface* receiver, EmulatedNetworkStatsGatheringMode stats_gathering_mode) @@ -168,7 +170,7 @@ class LinkEmulation : public EmulatedNetworkReceiverInterface { void Process(Timestamp at_time) RTC_RUN_ON(task_queue_); Clock* const clock_; - rtc::TaskQueue* const task_queue_; + const absl::Nonnull<TaskQueueBase*> task_queue_; const std::unique_ptr<NetworkBehaviorInterface> network_behavior_ RTC_GUARDED_BY(task_queue_); EmulatedNetworkReceiverInterface* const receiver_; @@ -186,7 +188,7 @@ class LinkEmulation : public EmulatedNetworkReceiverInterface { // the packet will be silently dropped. class NetworkRouterNode : public EmulatedNetworkReceiverInterface { public: - explicit NetworkRouterNode(rtc::TaskQueue* task_queue); + explicit NetworkRouterNode(absl::Nonnull<TaskQueueBase*> task_queue); void OnPacketReceived(EmulatedIpPacket packet) override; void SetReceiver(const rtc::IPAddress& dest_ip, @@ -200,7 +202,7 @@ class NetworkRouterNode : public EmulatedNetworkReceiverInterface { void SetFilter(std::function<bool(const EmulatedIpPacket&)> filter); private: - rtc::TaskQueue* const task_queue_; + const absl::Nonnull<TaskQueueBase*> task_queue_; absl::optional<EmulatedNetworkReceiverInterface*> default_receiver_ RTC_GUARDED_BY(task_queue_); std::map<rtc::IPAddress, EmulatedNetworkReceiverInterface*> routing_ @@ -224,7 +226,7 @@ class EmulatedNetworkNode : public EmulatedNetworkReceiverInterface { // they are ready. EmulatedNetworkNode( Clock* clock, - rtc::TaskQueue* task_queue, + absl::Nonnull<TaskQueueBase*> task_queue, std::unique_ptr<NetworkBehaviorInterface> network_behavior, EmulatedNetworkStatsGatheringMode stats_gathering_mode); ~EmulatedNetworkNode() override; @@ -283,7 +285,7 @@ class EmulatedEndpointImpl : public EmulatedEndpoint { EmulatedEndpointImpl(const Options& options, bool is_enabled, - rtc::TaskQueue* task_queue, + absl::Nonnull<TaskQueueBase*> task_queue, Clock* clock); ~EmulatedEndpointImpl() override; @@ -341,7 +343,7 @@ class EmulatedEndpointImpl : public EmulatedEndpoint { const Options options_; bool is_enabled_ RTC_GUARDED_BY(enabled_state_checker_); Clock* const clock_; - rtc::TaskQueue* const task_queue_; + const absl::Nonnull<TaskQueueBase*> task_queue_; std::unique_ptr<rtc::Network> network_; NetworkRouterNode router_; diff --git a/third_party/libwebrtc/test/network/network_emulation_manager.cc b/third_party/libwebrtc/test/network/network_emulation_manager.cc index 97c0bc1ba8..dd0e93d8ee 100644 --- a/third_party/libwebrtc/test/network/network_emulation_manager.cc +++ b/third_party/libwebrtc/test/network/network_emulation_manager.cc @@ -13,6 +13,7 @@ #include <algorithm> #include <memory> +#include "api/field_trials_view.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "call/simulated_network.h" @@ -30,10 +31,12 @@ constexpr uint32_t kMinIPv4Address = 0xC0A80000; // uint32_t representation of 192.168.255.255 address constexpr uint32_t kMaxIPv4Address = 0xC0A8FFFF; -std::unique_ptr<TimeController> CreateTimeController(TimeMode mode) { +std::unique_ptr<TimeController> CreateTimeController( + TimeMode mode, + const FieldTrialsView* field_trials) { switch (mode) { case TimeMode::kRealTime: - return std::make_unique<RealTimeController>(); + return std::make_unique<RealTimeController>(field_trials); case TimeMode::kSimulated: // Using an offset of 100000 to get nice fixed width and readable // timestamps in typical test scenarios. @@ -46,10 +49,11 @@ std::unique_ptr<TimeController> CreateTimeController(TimeMode mode) { NetworkEmulationManagerImpl::NetworkEmulationManagerImpl( TimeMode mode, - EmulatedNetworkStatsGatheringMode stats_gathering_mode) + EmulatedNetworkStatsGatheringMode stats_gathering_mode, + const FieldTrialsView* field_trials) : time_mode_(mode), stats_gathering_mode_(stats_gathering_mode), - time_controller_(CreateTimeController(mode)), + time_controller_(CreateTimeController(mode, field_trials)), clock_(time_controller_->GetClock()), next_node_id_(1), next_ip4_address_(kMinIPv4Address), @@ -75,8 +79,9 @@ EmulatedNetworkNode* NetworkEmulationManagerImpl::CreateEmulatedNode( EmulatedNetworkNode* NetworkEmulationManagerImpl::CreateEmulatedNode( std::unique_ptr<NetworkBehaviorInterface> network_behavior) { - auto node = std::make_unique<EmulatedNetworkNode>( - clock_, &task_queue_, std::move(network_behavior), stats_gathering_mode_); + auto node = std::make_unique<EmulatedNetworkNode>(clock_, task_queue_.Get(), + std::move(network_behavior), + stats_gathering_mode_); EmulatedNetworkNode* out = node.get(); task_queue_.PostTask([this, node = std::move(node)]() mutable { network_nodes_.push_back(std::move(node)); @@ -111,7 +116,7 @@ EmulatedEndpointImpl* NetworkEmulationManagerImpl::CreateEndpoint( auto node = std::make_unique<EmulatedEndpointImpl>( EmulatedEndpointImpl::Options(next_node_id_++, *ip, config, stats_gathering_mode_), - config.start_as_enabled, &task_queue_, clock_); + config.start_as_enabled, task_queue_.Get(), clock_); EmulatedEndpointImpl* out = node.get(); endpoints_.push_back(std::move(node)); return out; diff --git a/third_party/libwebrtc/test/network/network_emulation_manager.h b/third_party/libwebrtc/test/network/network_emulation_manager.h index 29debca693..4b0a76494f 100644 --- a/third_party/libwebrtc/test/network/network_emulation_manager.h +++ b/third_party/libwebrtc/test/network/network_emulation_manager.h @@ -18,6 +18,7 @@ #include <vector> #include "api/array_view.h" +#include "api/field_trials_view.h" #include "api/test/network_emulation_manager.h" #include "api/test/simulated_network.h" #include "api/test/time_controller.h" @@ -38,7 +39,8 @@ class NetworkEmulationManagerImpl : public NetworkEmulationManager { public: NetworkEmulationManagerImpl( TimeMode mode, - EmulatedNetworkStatsGatheringMode stats_gathering_mode); + EmulatedNetworkStatsGatheringMode stats_gathering_mode, + const FieldTrialsView* field_trials = nullptr); ~NetworkEmulationManagerImpl(); EmulatedNetworkNode* CreateEmulatedNode(BuiltInNetworkBehaviorConfig config, diff --git a/third_party/libwebrtc/test/network/network_emulation_pc_unittest.cc b/third_party/libwebrtc/test/network/network_emulation_pc_unittest.cc index 09d3946747..73ac54e7ef 100644 --- a/third_party/libwebrtc/test/network/network_emulation_pc_unittest.cc +++ b/third_party/libwebrtc/test/network/network_emulation_pc_unittest.cc @@ -56,8 +56,7 @@ rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( rtc::Thread* network_thread) { PeerConnectionFactoryDependencies pcf_deps; pcf_deps.task_queue_factory = CreateDefaultTaskQueueFactory(); - pcf_deps.event_log_factory = - std::make_unique<RtcEventLogFactory>(pcf_deps.task_queue_factory.get()); + pcf_deps.event_log_factory = std::make_unique<RtcEventLogFactory>(); pcf_deps.network_thread = network_thread; pcf_deps.signaling_thread = signaling_thread; pcf_deps.trials = std::make_unique<FieldTrialBasedConfig>(); |