mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
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:
parent
f887e07234
commit
242ed95fd7
8 changed files with 25 additions and 11 deletions
|
@ -643,6 +643,7 @@ if (rtc_include_tests) {
|
||||||
"test/create_network_emulation_manager.h",
|
"test/create_network_emulation_manager.h",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
|
":field_trials_view",
|
||||||
":network_emulation_manager_api",
|
":network_emulation_manager_api",
|
||||||
"../test/network:emulated_network",
|
"../test/network:emulated_network",
|
||||||
]
|
]
|
||||||
|
|
|
@ -13,15 +13,17 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "api/field_trials_view.h"
|
||||||
#include "test/network/network_emulation_manager.h"
|
#include "test/network/network_emulation_manager.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
std::unique_ptr<NetworkEmulationManager> CreateNetworkEmulationManager(
|
std::unique_ptr<NetworkEmulationManager> CreateNetworkEmulationManager(
|
||||||
TimeMode time_mode,
|
TimeMode time_mode,
|
||||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode) {
|
EmulatedNetworkStatsGatheringMode stats_gathering_mode,
|
||||||
|
const FieldTrialsView* field_trials) {
|
||||||
return std::make_unique<test::NetworkEmulationManagerImpl>(
|
return std::make_unique<test::NetworkEmulationManagerImpl>(
|
||||||
time_mode, stats_gathering_mode);
|
time_mode, stats_gathering_mode, field_trials);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "api/field_trials_view.h"
|
||||||
#include "api/test/network_emulation_manager.h"
|
#include "api/test/network_emulation_manager.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
@ -21,7 +22,8 @@ namespace webrtc {
|
||||||
std::unique_ptr<NetworkEmulationManager> CreateNetworkEmulationManager(
|
std::unique_ptr<NetworkEmulationManager> CreateNetworkEmulationManager(
|
||||||
TimeMode time_mode = TimeMode::kRealTime,
|
TimeMode time_mode = TimeMode::kRealTime,
|
||||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode =
|
EmulatedNetworkStatsGatheringMode stats_gathering_mode =
|
||||||
EmulatedNetworkStatsGatheringMode::kDefault);
|
EmulatedNetworkStatsGatheringMode::kDefault,
|
||||||
|
const FieldTrialsView* field_trials = nullptr);
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "api/field_trials_view.h"
|
||||||
#include "api/units/time_delta.h"
|
#include "api/units/time_delta.h"
|
||||||
#include "api/units/timestamp.h"
|
#include "api/units/timestamp.h"
|
||||||
#include "call/simulated_network.h"
|
#include "call/simulated_network.h"
|
||||||
|
@ -30,10 +31,12 @@ constexpr uint32_t kMinIPv4Address = 0xC0A80000;
|
||||||
// uint32_t representation of 192.168.255.255 address
|
// uint32_t representation of 192.168.255.255 address
|
||||||
constexpr uint32_t kMaxIPv4Address = 0xC0A8FFFF;
|
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) {
|
switch (mode) {
|
||||||
case TimeMode::kRealTime:
|
case TimeMode::kRealTime:
|
||||||
return std::make_unique<RealTimeController>();
|
return std::make_unique<RealTimeController>(field_trials);
|
||||||
case TimeMode::kSimulated:
|
case TimeMode::kSimulated:
|
||||||
// Using an offset of 100000 to get nice fixed width and readable
|
// Using an offset of 100000 to get nice fixed width and readable
|
||||||
// timestamps in typical test scenarios.
|
// timestamps in typical test scenarios.
|
||||||
|
@ -46,10 +49,11 @@ std::unique_ptr<TimeController> CreateTimeController(TimeMode mode) {
|
||||||
|
|
||||||
NetworkEmulationManagerImpl::NetworkEmulationManagerImpl(
|
NetworkEmulationManagerImpl::NetworkEmulationManagerImpl(
|
||||||
TimeMode mode,
|
TimeMode mode,
|
||||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode)
|
EmulatedNetworkStatsGatheringMode stats_gathering_mode,
|
||||||
|
const FieldTrialsView* field_trials)
|
||||||
: time_mode_(mode),
|
: time_mode_(mode),
|
||||||
stats_gathering_mode_(stats_gathering_mode),
|
stats_gathering_mode_(stats_gathering_mode),
|
||||||
time_controller_(CreateTimeController(mode)),
|
time_controller_(CreateTimeController(mode, field_trials)),
|
||||||
clock_(time_controller_->GetClock()),
|
clock_(time_controller_->GetClock()),
|
||||||
next_node_id_(1),
|
next_node_id_(1),
|
||||||
next_ip4_address_(kMinIPv4Address),
|
next_ip4_address_(kMinIPv4Address),
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "api/array_view.h"
|
#include "api/array_view.h"
|
||||||
|
#include "api/field_trials_view.h"
|
||||||
#include "api/test/network_emulation_manager.h"
|
#include "api/test/network_emulation_manager.h"
|
||||||
#include "api/test/simulated_network.h"
|
#include "api/test/simulated_network.h"
|
||||||
#include "api/test/time_controller.h"
|
#include "api/test/time_controller.h"
|
||||||
|
@ -38,7 +39,8 @@ class NetworkEmulationManagerImpl : public NetworkEmulationManager {
|
||||||
public:
|
public:
|
||||||
NetworkEmulationManagerImpl(
|
NetworkEmulationManagerImpl(
|
||||||
TimeMode mode,
|
TimeMode mode,
|
||||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode);
|
EmulatedNetworkStatsGatheringMode stats_gathering_mode,
|
||||||
|
const FieldTrialsView* field_trials = nullptr);
|
||||||
~NetworkEmulationManagerImpl();
|
~NetworkEmulationManagerImpl();
|
||||||
|
|
||||||
EmulatedNetworkNode* CreateEmulatedNode(BuiltInNetworkBehaviorConfig config,
|
EmulatedNetworkNode* CreateEmulatedNode(BuiltInNetworkBehaviorConfig config,
|
||||||
|
|
|
@ -24,6 +24,7 @@ rtc_library("time_controller") {
|
||||||
]
|
]
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
|
"../../api:field_trials_view",
|
||||||
"../../api:sequence_checker",
|
"../../api:sequence_checker",
|
||||||
"../../api:time_controller",
|
"../../api:time_controller",
|
||||||
"../../api/task_queue",
|
"../../api/task_queue",
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
*/
|
*/
|
||||||
#include "test/time_controller/real_time_controller.h"
|
#include "test/time_controller/real_time_controller.h"
|
||||||
|
|
||||||
|
#include "api/field_trials_view.h"
|
||||||
#include "api/task_queue/default_task_queue_factory.h"
|
#include "api/task_queue/default_task_queue_factory.h"
|
||||||
#include "rtc_base/null_socket_server.h"
|
#include "rtc_base/null_socket_server.h"
|
||||||
|
|
||||||
|
@ -30,8 +31,8 @@ class MainThread : public rtc::Thread {
|
||||||
CurrentThreadSetter current_setter_;
|
CurrentThreadSetter current_setter_;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
RealTimeController::RealTimeController()
|
RealTimeController::RealTimeController(const FieldTrialsView* field_trials)
|
||||||
: task_queue_factory_(CreateDefaultTaskQueueFactory()),
|
: task_queue_factory_(CreateDefaultTaskQueueFactory(field_trials)),
|
||||||
main_thread_(std::make_unique<MainThread>()) {
|
main_thread_(std::make_unique<MainThread>()) {
|
||||||
main_thread_->SetName("Main", this);
|
main_thread_->SetName("Main", this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "api/field_trials_view.h"
|
||||||
#include "api/task_queue/task_queue_factory.h"
|
#include "api/task_queue/task_queue_factory.h"
|
||||||
#include "api/test/time_controller.h"
|
#include "api/test/time_controller.h"
|
||||||
#include "api/units/time_delta.h"
|
#include "api/units/time_delta.h"
|
||||||
|
@ -21,7 +22,7 @@
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
class RealTimeController : public TimeController {
|
class RealTimeController : public TimeController {
|
||||||
public:
|
public:
|
||||||
RealTimeController();
|
RealTimeController(const FieldTrialsView* field_trials = nullptr);
|
||||||
|
|
||||||
Clock* GetClock() override;
|
Clock* GetClock() override;
|
||||||
TaskQueueFactory* GetTaskQueueFactory() override;
|
TaskQueueFactory* GetTaskQueueFactory() override;
|
||||||
|
|
Loading…
Reference in a new issue