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

Unified Diff: components/ntp_snippets/remote/remote_suggestions_fetcher.cc

Issue 2665743002: [Remote suggestions] Clean up variation params in the fetcher. (Closed)
Patch Set: Created 3 years, 11 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/ntp_snippets/remote/remote_suggestions_fetcher.cc
diff --git a/components/ntp_snippets/remote/remote_suggestions_fetcher.cc b/components/ntp_snippets/remote/remote_suggestions_fetcher.cc
index b4afcee5cc6b80f32ce28f592e41a69e34d7a979..efd768988d9c7c7d93b147eb091c490993d7815c 100644
--- a/components/ntp_snippets/remote/remote_suggestions_fetcher.cc
+++ b/components/ntp_snippets/remote/remote_suggestions_fetcher.cc
@@ -52,17 +52,9 @@ const char kContentSuggestionsApiScope[] =
const char kSnippetsServerNonAuthorizedFormat[] = "%s?key=%s";
const char kAuthorizationRequestHeaderFormat[] = "Bearer %s";
-// Variation parameter for personalizing fetching of suggestions.
-const char kPersonalizationName[] = "fetching_personalization";
-
// Variation parameter for chrome-content-suggestions backend.
const char kContentSuggestionsBackend[] = "content_suggestions_backend";
-// Constants for possible values of the "fetching_personalization" parameter.
-const char kPersonalizationPersonalString[] = "personal";
-const char kPersonalizationNonPersonalString[] = "non_personal";
-const char kPersonalizationBothString[] = "both"; // the default value
-
const int kFetchTimeHistogramResolution = 5;
std::string FetchResultToString(FetchResult result) {
@@ -119,8 +111,8 @@ Status FetchResultToStatus(FetchResult result) {
}
std::string GetFetchEndpoint() {
- std::string endpoint = variations::GetVariationParamValue(
- ntp_snippets::kStudyName, kContentSuggestionsBackend);
+ std::string endpoint = variations::GetVariationParamValueByFeature(
+ ntp_snippets::kArticleSuggestionsFeature, kContentSuggestionsBackend);
Marc Treib 2017/01/30 17:02:57 This will break the current configs, right? Shoul
jkrcal 2017/01/30 17:11:01 I would handle it in the configs, server-side. Af
Marc Treib 2017/01/31 09:01:43 Actually on second thought, since the ZineServer e
return endpoint.empty() ? kContentSuggestionsServer : endpoint;
}
@@ -284,21 +276,7 @@ RemoteSuggestionsFetcher::RemoteSuggestionsFetcher(
pref_service,
RequestThrottler::RequestType::
CONTENT_SUGGESTION_FETCHER_ACTIVE_SUGGESTIONS_CONSUMER),
- weak_ptr_factory_(this) {
- std::string personalization = variations::GetVariationParamValue(
- ntp_snippets::kStudyName, kPersonalizationName);
- if (personalization == kPersonalizationNonPersonalString) {
- personalization_ = Personalization::kNonPersonal;
- } else if (personalization == kPersonalizationPersonalString) {
- personalization_ = Personalization::kPersonal;
- } else {
- personalization_ = Personalization::kBoth;
- LOG_IF(WARNING, !personalization.empty() &&
- personalization != kPersonalizationBothString)
- << "Unknown value for " << kPersonalizationName << ": "
- << personalization;
- }
-}
+ weak_ptr_factory_(this) {}
RemoteSuggestionsFetcher::~RemoteSuggestionsFetcher() {
if (waiting_for_refresh_token_) {
@@ -333,17 +311,16 @@ void RemoteSuggestionsFetcher::FetchSnippets(
.SetLanguageModel(language_model_)
.SetParams(params)
.SetParseJsonCallback(parse_json_callback_)
- .SetPersonalization(personalization_)
.SetTickClock(tick_clock_.get())
.SetUrlRequestContextGetter(url_request_context_getter_)
.SetUserClassifier(*user_classifier_);
- if (NeedsAuthentication() && signin_manager_->IsAuthenticated()) {
+ if (signin_manager_->IsAuthenticated()) {
// Signed-in: get OAuth token --> fetch suggestions.
oauth_token_retried_ = false;
pending_requests_.emplace(std::move(builder), std::move(callback));
StartTokenRequest();
- } else if (NeedsAuthentication() && signin_manager_->AuthInProgress()) {
+ } else if (signin_manager_->AuthInProgress()) {
// Currently signing in: wait for auth to finish (the refresh token) -->
// get OAuth token --> fetch suggestions.
pending_requests_.emplace(std::move(builder), std::move(callback));
@@ -607,25 +584,4 @@ bool RemoteSuggestionsFetcher::DemandQuotaForRequest(bool interactive_request) {
return false;
}
-bool RemoteSuggestionsFetcher::NeedsAuthentication() const {
- return (personalization_ == Personalization::kPersonal ||
- personalization_ == Personalization::kBoth);
-}
-
-std::string RemoteSuggestionsFetcher::PersonalizationModeString() const {
- switch (personalization_) {
- case Personalization::kPersonal:
- return "Only personalized";
- break;
- case Personalization::kBoth:
- return "Both personalized and non-personalized";
- break;
- case Personalization::kNonPersonal:
- return "Only non-personalized";
- break;
- }
- NOTREACHED();
- return std::string();
-}
-
} // namespace ntp_snippets

Powered by Google App Engine
This is Rietveld 408576698