Replace legacy rtc::TaskQueue with TaskQueueBase in test Network helper
rtc::TaskQueue wrapper provide no extra feature there.
Bug: webrtc:14169
Change-Id: I91ec99e10400627f1fb6f534cc679e3b11534c0b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/333481
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41484}
diff --git a/test/network/BUILD.gn b/test/network/BUILD.gn
index 2949b34..6df563d 100644
--- a/test/network/BUILD.gn
+++ b/test/network/BUILD.gn
@@ -47,6 +47,7 @@
"../../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_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 @@
]
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",
diff --git a/test/network/cross_traffic_unittest.cc b/test/network/cross_traffic_unittest.cc
index 36aff67..0f98fc9 100644
--- a/test/network/cross_traffic_unittest.cc
+++ b/test/network/cross_traffic_unittest.cc
@@ -55,7 +55,7 @@
EmulatedEndpointConfig(),
EmulatedNetworkStatsGatheringMode::kDefault,
},
- /*is_enabled=*/true, &task_queue_, &clock};
+ /*is_enabled=*/true, task_queue_.Get(), &clock};
};
} // namespace
diff --git a/test/network/network_emulation.cc b/test/network/network_emulation.cc
index f1c9ca8..642bf6f 100644
--- a/test/network/network_emulation.cc
+++ b/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 @@
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 @@
}
}
-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 @@
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 @@
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/test/network/network_emulation.h b/test/network/network_emulation.h
index dffabaf..2070519 100644
--- a/test/network/network_emulation.h
+++ b/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 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 @@
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 @@
// 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 @@
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 @@
// 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 @@
EmulatedEndpointImpl(const Options& options,
bool is_enabled,
- rtc::TaskQueue* task_queue,
+ absl::Nonnull<TaskQueueBase*> task_queue,
Clock* clock);
~EmulatedEndpointImpl() override;
@@ -341,7 +343,7 @@
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/test/network/network_emulation_manager.cc b/test/network/network_emulation_manager.cc
index 46c43e2..dd0e93d 100644
--- a/test/network/network_emulation_manager.cc
+++ b/test/network/network_emulation_manager.cc
@@ -79,8 +79,9 @@
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));
@@ -115,7 +116,7 @@
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;