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

Unified Diff: components/variations/variations_associated_data.h

Issue 2558743003: Add generic functions for getting typed variation parameter values (Closed)
Patch Set: Alexei's comments Created 4 years 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
« no previous file with comments | « components/ntp_snippets/user_classifier.cc ('k') | components/variations/variations_associated_data.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/variations/variations_associated_data.h
diff --git a/components/variations/variations_associated_data.h b/components/variations/variations_associated_data.h
index 0734e8be495a5058b6b009f70a3c4c7f8ea0e524..ad359a485612628782e765139087e6d9666cb729 100644
--- a/components/variations/variations_associated_data.h
+++ b/components/variations/variations_associated_data.h
@@ -152,13 +152,38 @@ std::string GetVariationParamValue(const std::string& trial_name,
// with at most one variation, through the variation's associated field trial,
// and selected group. See base/feature_list.h for more information on
// features. If the feature is not enabled, or the specified parameter does not
-// exist, returns an empty string.Calling this function will result in the
+// exist, returns an empty string. Calling this function will result in the
// associated field trial being marked as active if found (i.e. group() will be
// called on it), if it wasn't already. Currently, this information is only
// available from the browser process. Thread safe.
std::string GetVariationParamValueByFeature(const base::Feature& feature,
const std::string& param_name);
+// Same as GetVariationParamValueByFeature(). On top of that, it converts the
+// string value into an int using base::StringToInt() and returns it, if
+// successful. Otherwise, it returns |default_value|. If the string value is not
+// empty and the conversion does not succeed, it produces a warning to LOG.
+int GetVariationParamByFeatureAsInt(const base::Feature& feature,
+ const std::string& param_name,
+ int default_value);
+
+// Same as GetVariationParamValueByFeature(). On top of that, it converts the
+// string value into a double using base::StringToDouble() and returns it, if
+// successful. Otherwise, it returns |default_value|. If the string value is not
+// empty and the conversion does not succeed, it produces a warning to LOG.
+double GetVariationParamByFeatureAsDouble(const base::Feature& feature,
+ const std::string& param_name,
+ double default_value);
+
+// Same as GetVariationParamValueByFeature(). On top of that, it converts the
+// string value into a boolean and returns it, if successful. Otherwise, it
+// returns |default_value|. The only string representations accepted here are
+// "true" and "false". If the string value is not empty and the conversion does
+// not succeed, it produces a warning to LOG.
+bool GetVariationParamByFeatureAsBool(const base::Feature& feature,
+ const std::string& param_name,
+ bool default_value);
+
// Expose some functions for testing.
namespace testing {
« no previous file with comments | « components/ntp_snippets/user_classifier.cc ('k') | components/variations/variations_associated_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698