Add a FieldTrialsView argument to the NetworkEmulationManager ctor.

Change-Id: Ic4acd04aef9e9f6185d045bc300d8dbea50759fd
Bug: b/314891512
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/330001
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Jeremy Leconte <jleconte@google.com>
Cr-Commit-Position: refs/heads/main@{#41320}
This commit is contained in:
Jeremy Leconte 2023-12-05 14:47:22 +01:00 committed by WebRTC LUCI CQ
parent f887e07234
commit 242ed95fd7
8 changed files with 25 additions and 11 deletions

View file

@ -643,6 +643,7 @@ if (rtc_include_tests) {
"test/create_network_emulation_manager.h",
]
deps = [
":field_trials_view",
":network_emulation_manager_api",
"../test/network:emulated_network",
]

View file

@ -13,15 +13,17 @@
#include <memory>
#include "api/field_trials_view.h"
#include "test/network/network_emulation_manager.h"
namespace webrtc {
std::unique_ptr<NetworkEmulationManager> CreateNetworkEmulationManager(
TimeMode time_mode,
EmulatedNetworkStatsGatheringMode stats_gathering_mode) {
EmulatedNetworkStatsGatheringMode stats_gathering_mode,
const FieldTrialsView* field_trials) {
return std::make_unique<test::NetworkEmulationManagerImpl>(
time_mode, stats_gathering_mode);
time_mode, stats_gathering_mode, field_trials);
}
} // namespace webrtc

View file

@ -13,6 +13,7 @@
#include <memory>
#include "api/field_trials_view.h"
#include "api/test/network_emulation_manager.h"
namespace webrtc {
@ -21,7 +22,8 @@ namespace webrtc {
std::unique_ptr<NetworkEmulationManager> CreateNetworkEmulationManager(
TimeMode time_mode = TimeMode::kRealTime,
EmulatedNetworkStatsGatheringMode stats_gathering_mode =
EmulatedNetworkStatsGatheringMode::kDefault);
EmulatedNetworkStatsGatheringMode::kDefault,
const FieldTrialsView* field_trials = nullptr);
} // namespace webrtc

View file

@ -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),

View file

@ -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,

View file

@ -24,6 +24,7 @@ rtc_library("time_controller") {
]
deps = [
"../../api:field_trials_view",
"../../api:sequence_checker",
"../../api:time_controller",
"../../api/task_queue",

View file

@ -9,6 +9,7 @@
*/
#include "test/time_controller/real_time_controller.h"
#include "api/field_trials_view.h"
#include "api/task_queue/default_task_queue_factory.h"
#include "rtc_base/null_socket_server.h"
@ -30,8 +31,8 @@ class MainThread : public rtc::Thread {
CurrentThreadSetter current_setter_;
};
} // namespace
RealTimeController::RealTimeController()
: task_queue_factory_(CreateDefaultTaskQueueFactory()),
RealTimeController::RealTimeController(const FieldTrialsView* field_trials)
: task_queue_factory_(CreateDefaultTaskQueueFactory(field_trials)),
main_thread_(std::make_unique<MainThread>()) {
main_thread_->SetName("Main", this);
}

View file

@ -13,6 +13,7 @@
#include <functional>
#include <memory>
#include "api/field_trials_view.h"
#include "api/task_queue/task_queue_factory.h"
#include "api/test/time_controller.h"
#include "api/units/time_delta.h"
@ -21,7 +22,7 @@
namespace webrtc {
class RealTimeController : public TimeController {
public:
RealTimeController();
RealTimeController(const FieldTrialsView* field_trials = nullptr);
Clock* GetClock() override;
TaskQueueFactory* GetTaskQueueFactory() override;