Add FieldTrialsRegistry that verifies looked up field trials
This new class implements the existing FieldTrialsView interface, extending it with the verification functionality. For now, the verification will only be performed if the rtc_strict_field_trials GN arg is set. Most classes extending FieldTrialsView today have been converted to extend from FieldTrialsRegistry instead to automatically perform verification. Bug: webrtc:14154 Change-Id: I4819724cd66a04507e62fcc2bb1019187b6ba8c7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/276270 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Emil Lundmark <lndmrk@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38453}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
9707f579ae
commit
1c8103d4db
@ -255,7 +255,7 @@ rtc_library("explicit_key_value_config") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"../api:field_trials_view",
|
||||
"../api:field_trials_registry",
|
||||
"../rtc_base:checks",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/strings:strings" ]
|
||||
@ -271,7 +271,7 @@ rtc_library("scoped_key_value_config") {
|
||||
|
||||
deps = [
|
||||
":field_trial",
|
||||
"../api:field_trials_view",
|
||||
"../api:field_trials_registry",
|
||||
"../rtc_base:checks",
|
||||
"../system_wrappers:field_trial",
|
||||
]
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#include "test/explicit_key_value_config.h"
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -46,7 +45,7 @@ ExplicitKeyValueConfig::ExplicitKeyValueConfig(absl::string_view s) {
|
||||
RTC_CHECK_EQ(field_start, s.size());
|
||||
}
|
||||
|
||||
std::string ExplicitKeyValueConfig::Lookup(absl::string_view key) const {
|
||||
std::string ExplicitKeyValueConfig::GetValue(absl::string_view key) const {
|
||||
auto it = key_value_map_.find(key);
|
||||
if (it != key_value_map_.end())
|
||||
return it->second;
|
||||
|
||||
@ -16,17 +16,18 @@
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "api/field_trials_registry.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
class ExplicitKeyValueConfig : public FieldTrialsView {
|
||||
class ExplicitKeyValueConfig : public FieldTrialsRegistry {
|
||||
public:
|
||||
explicit ExplicitKeyValueConfig(absl::string_view s);
|
||||
std::string Lookup(absl::string_view key) const override;
|
||||
|
||||
private:
|
||||
std::string GetValue(absl::string_view key) const override;
|
||||
|
||||
// Unlike std::less<std::string>, std::less<> is transparent and allows
|
||||
// heterogeneous lookup directly with absl::string_view.
|
||||
std::map<std::string, std::string, std::less<>> key_value_map_;
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
|
||||
#include "test/scoped_key_value_config.h"
|
||||
|
||||
#include "api/field_trials_view.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
#include "test/field_trial.h"
|
||||
@ -97,7 +96,7 @@ ScopedKeyValueConfig* ScopedKeyValueConfig::GetRoot(ScopedKeyValueConfig* n) {
|
||||
return n;
|
||||
}
|
||||
|
||||
std::string ScopedKeyValueConfig::Lookup(absl::string_view key) const {
|
||||
std::string ScopedKeyValueConfig::GetValue(absl::string_view key) const {
|
||||
if (parent_ == nullptr) {
|
||||
return leaf_->LookupRecurse(key);
|
||||
} else {
|
||||
|
||||
@ -17,24 +17,23 @@
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "api/field_trials_registry.h"
|
||||
#include "test/field_trial.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
class ScopedKeyValueConfig : public FieldTrialsView {
|
||||
class ScopedKeyValueConfig : public FieldTrialsRegistry {
|
||||
public:
|
||||
virtual ~ScopedKeyValueConfig();
|
||||
ScopedKeyValueConfig();
|
||||
explicit ScopedKeyValueConfig(absl::string_view s);
|
||||
ScopedKeyValueConfig(ScopedKeyValueConfig& parent, absl::string_view s);
|
||||
|
||||
std::string Lookup(absl::string_view key) const override;
|
||||
|
||||
private:
|
||||
ScopedKeyValueConfig(ScopedKeyValueConfig* parent, absl::string_view s);
|
||||
ScopedKeyValueConfig* GetRoot(ScopedKeyValueConfig* n);
|
||||
std::string GetValue(absl::string_view key) const override;
|
||||
std::string LookupRecurse(absl::string_view key) const;
|
||||
|
||||
ScopedKeyValueConfig* const parent_;
|
||||
|
||||
Reference in New Issue
Block a user