Check field trials are valid in ScopedFieldTrials.
This CL adds an RTC_CHECK in both ctor and dtor to ensure field trials are valid. Even if the check in the ctor is done already in debug mode, having it done always is fine because ScopedFieldTrials are testonly. The check in the dtor should catch issues like reverting to another ScopedFieldTrial which has already been destroyed. Bug: None Change-Id: I53a8680c3ff4fd0e2cbb3055af726a9023b45ac7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/229861 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/main@{#34828}
This commit is contained in:
parent
524c789d99
commit
f3db00f832
@ -220,7 +220,10 @@ rtc_library("field_trial") {
|
||||
"field_trial.h",
|
||||
]
|
||||
|
||||
deps = [ "../system_wrappers:field_trial" ]
|
||||
deps = [
|
||||
"../rtc_base:checks",
|
||||
"../system_wrappers:field_trial",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("explicit_key_value_config") {
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -24,11 +25,16 @@ void ValidateFieldTrialsStringOrDie(const std::string&) {}
|
||||
|
||||
ScopedFieldTrials::ScopedFieldTrials(const std::string& config)
|
||||
: previous_field_trials_(webrtc::field_trial::GetFieldTrialString()) {
|
||||
RTC_CHECK(webrtc::field_trial::FieldTrialsStringIsValid(config.c_str()))
|
||||
<< "Invalid field trials string: " << config;
|
||||
current_field_trials_ = config;
|
||||
webrtc::field_trial::InitFieldTrialsFromString(current_field_trials_.c_str());
|
||||
}
|
||||
|
||||
ScopedFieldTrials::~ScopedFieldTrials() {
|
||||
RTC_CHECK(
|
||||
webrtc::field_trial::FieldTrialsStringIsValid(previous_field_trials_))
|
||||
<< "Invalid field trials string: " << previous_field_trials_;
|
||||
webrtc::field_trial::InitFieldTrialsFromString(previous_field_trials_);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user