Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Unified Diff: components/variations/variations_associated_data.cc

Issue 1941963002: Add variations params api to get params from features. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/variations/variations_associated_data.cc
diff --git a/components/variations/variations_associated_data.cc b/components/variations/variations_associated_data.cc
index 9a84a32fe64637789f227c36677e3ea92e7210eb..9aa51d379f3d884a094d208d621e0d4eaacbe7f8 100644
--- a/components/variations/variations_associated_data.cc
+++ b/components/variations/variations_associated_data.cc
@@ -8,6 +8,7 @@
#include <utility>
#include <vector>
+#include "base/feature_list.h"
#include "base/macros.h"
#include "base/memory/singleton.h"
@@ -212,6 +213,18 @@ bool GetVariationParams(const std::string& trial_name,
trial_name, params);
}
+bool GetVariationParamsByFeature(const base::Feature& feature,
+ std::map<std::string, std::string>* params) {
+ if (!base::FeatureList::IsEnabled(feature))
+ return false;
+
+ base::FieldTrial* trial = base::FeatureList::GetFieldTrial(feature);
+ if (!trial)
+ return false;
+
+ return GetVariationParams(trial->trial_name(), params);
+}
+
std::string GetVariationParamValue(const std::string& trial_name,
const std::string& param_name) {
std::map<std::string, std::string> params;
@@ -223,6 +236,18 @@ std::string GetVariationParamValue(const std::string& trial_name,
return std::string();
}
+std::string GetVariationParamValueByFeature(const base::Feature& feature,
+ const std::string& param_name) {
+ if (!base::FeatureList::IsEnabled(feature))
+ return std::string();
+
+ base::FieldTrial* trial = base::FeatureList::GetFieldTrial(feature);
+ if (!trial)
+ return std::string();
+
+ return GetVariationParamValue(trial->trial_name(), param_name);
+}
+
// Functions below are exposed for testing explicitly behind this namespace.
// They simply wrap existing functions in this file.
namespace testing {
« no previous file with comments | « components/variations/variations_associated_data.h ('k') | components/variations/variations_associated_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698