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

Unified Diff: components/ntp_snippets/features.cc

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
Index: components/ntp_snippets/features.cc
diff --git a/components/ntp_snippets/features.cc b/components/ntp_snippets/features.cc
index fe007b58d22f8c9249b2ccd4e9cb80ef69f7c975..085257bc24d4cb05859a7827ee3313290e0dbfc7 100644
--- a/components/ntp_snippets/features.cc
+++ b/components/ntp_snippets/features.cc
@@ -4,7 +4,6 @@
#include "components/ntp_snippets/features.h"
-#include "base/strings/string_number_conversions.h"
#include "components/variations/variations_associated_data.h"
namespace ntp_snippets {
@@ -42,46 +41,4 @@ const base::Feature kForeignSessionsSuggestionsFeature{
const base::Feature kFetchMoreFeature{"NTPSuggestionsFetchMore",
base::FEATURE_ENABLED_BY_DEFAULT};
-int GetParamAsInt(const base::Feature& feature,
- const std::string& param_name,
- const int default_value) {
- std::string value_as_string =
- variations::GetVariationParamValueByFeature(feature, param_name);
- int value_as_int = 0;
- if (!base::StringToInt(value_as_string, &value_as_int)) {
- if (!value_as_string.empty()) {
- LOG(WARNING) << "Failed to parse variation param " << param_name
- << " with string value " << value_as_string
- << " under feature " << feature.name
- << " into an int. Falling back to default value of "
- << default_value;
- }
- value_as_int = default_value;
- }
- return value_as_int;
-}
-
-
-bool GetParamAsBool(const base::Feature& feature,
- const std::string& param_name,
- bool default_value) {
- std::string value_as_string =
- variations::GetVariationParamValueByFeature(feature, param_name);
- if (value_as_string == "true") {
- return true;
- }
- if (value_as_string == "false") {
- return false;
- }
-
- if (!value_as_string.empty()) {
- LOG(WARNING) << "Failed to parse variation param " << param_name
- << " with string value " << value_as_string
- << " under feature " << feature.name
- << " into a bool. Falling back to default value of "
- << default_value;
- }
- return default_value;
-}
-
} // namespace ntp_snippets
« no previous file with comments | « components/ntp_snippets/features.h ('k') | components/ntp_snippets/offline_pages/recent_tab_suggestions_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698