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

Side by Side Diff: chrome/browser/search/suggestions/suggestions_service.cc

Issue 341943002: [Android NTP] Logging histograms for users that are part of a control group. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial 2 Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/search/suggestions/suggestions_service.h" 5 #include "chrome/browser/search/suggestions/suggestions_service.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 const unsigned int kRequestTimeoutMs = 200; 73 const unsigned int kRequestTimeoutMs = 200;
74 74
75 } // namespace 75 } // namespace
76 76
77 const char kSuggestionsFieldTrialName[] = "ChromeSuggestions"; 77 const char kSuggestionsFieldTrialName[] = "ChromeSuggestions";
78 const char kSuggestionsFieldTrialURLParam[] = "url"; 78 const char kSuggestionsFieldTrialURLParam[] = "url";
79 const char kSuggestionsFieldTrialSuggestionsSuffixParam[] = 79 const char kSuggestionsFieldTrialSuggestionsSuffixParam[] =
80 "suggestions_suffix"; 80 "suggestions_suffix";
81 const char kSuggestionsFieldTrialBlacklistSuffixParam[] = "blacklist_suffix"; 81 const char kSuggestionsFieldTrialBlacklistSuffixParam[] = "blacklist_suffix";
82 const char kSuggestionsFieldTrialStateParam[] = "state"; 82 const char kSuggestionsFieldTrialStateParam[] = "state";
83 const char kSuggestionsFieldTrialControlParam[] = "control";
83 const char kSuggestionsFieldTrialStateEnabled[] = "enabled"; 84 const char kSuggestionsFieldTrialStateEnabled[] = "enabled";
84 85
85 SuggestionsService::SuggestionsService( 86 SuggestionsService::SuggestionsService(
86 Profile* profile, scoped_ptr<SuggestionsStore> suggestions_store) 87 Profile* profile, scoped_ptr<SuggestionsStore> suggestions_store)
87 : suggestions_store_(suggestions_store.Pass()), 88 : suggestions_store_(suggestions_store.Pass()),
88 thumbnail_manager_(new ThumbnailManager(profile)), 89 thumbnail_manager_(new ThumbnailManager(profile)),
89 profile_(profile), 90 profile_(profile),
90 weak_ptr_factory_(this) { 91 weak_ptr_factory_(this) {
91 // Obtain the URL to use to fetch suggestions data from the Variations param. 92 // Obtain the URL to use to fetch suggestions data from the Variations param.
92 suggestions_url_ = 93 suggestions_url_ =
93 GURL(GetExperimentParam(kSuggestionsFieldTrialURLParam) + 94 GURL(GetExperimentParam(kSuggestionsFieldTrialURLParam) +
94 GetExperimentParam(kSuggestionsFieldTrialSuggestionsSuffixParam)); 95 GetExperimentParam(kSuggestionsFieldTrialSuggestionsSuffixParam));
95 blacklist_url_prefix_ = 96 blacklist_url_prefix_ =
96 GetExperimentParam(kSuggestionsFieldTrialURLParam) + 97 GetExperimentParam(kSuggestionsFieldTrialURLParam) +
97 GetExperimentParam(kSuggestionsFieldTrialBlacklistSuffixParam); 98 GetExperimentParam(kSuggestionsFieldTrialBlacklistSuffixParam);
98 } 99 }
99 100
100 SuggestionsService::~SuggestionsService() {} 101 SuggestionsService::~SuggestionsService() {}
101 102
102 // static 103 // static
103 bool SuggestionsService::IsEnabled() { 104 bool SuggestionsService::IsEnabled() {
104 return GetExperimentParam(kSuggestionsFieldTrialStateParam) == 105 return GetExperimentParam(kSuggestionsFieldTrialStateParam) ==
105 kSuggestionsFieldTrialStateEnabled; 106 kSuggestionsFieldTrialStateEnabled;
106 } 107 }
107 108
109 // static
110 bool SuggestionsService::IsControlGroup() {
111 return GetExperimentParam(kSuggestionsFieldTrialControlParam) ==
112 kSuggestionsFieldTrialStateEnabled;
113 }
114
108 void SuggestionsService::FetchSuggestionsData( 115 void SuggestionsService::FetchSuggestionsData(
109 SuggestionsService::ResponseCallback callback) { 116 SuggestionsService::ResponseCallback callback) {
110 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 117 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
111 118
112 FetchSuggestionsDataNoTimeout(callback); 119 FetchSuggestionsDataNoTimeout(callback);
113 120
114 // Post a task to serve the cached suggestions if the request hasn't completed 121 // Post a task to serve the cached suggestions if the request hasn't completed
115 // after some time. Cancels the previous such task, if one existed. 122 // after some time. Cancels the previous such task, if one existed.
116 pending_timeout_closure_.reset(new CancelableClosure(base::Bind( 123 pending_timeout_closure_.reset(new CancelableClosure(base::Bind(
117 &SuggestionsService::OnRequestTimeout, weak_ptr_factory_.GetWeakPtr()))); 124 &SuggestionsService::OnRequestTimeout, weak_ptr_factory_.GetWeakPtr())));
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 return request; 276 return request;
270 } 277 }
271 278
272 void SuggestionsService::ServeFromCache() { 279 void SuggestionsService::ServeFromCache() {
273 SuggestionsProfile suggestions; 280 SuggestionsProfile suggestions;
274 suggestions_store_->LoadSuggestions(&suggestions); 281 suggestions_store_->LoadSuggestions(&suggestions);
275 DispatchRequestsAndClear(suggestions, &waiting_requestors_); 282 DispatchRequestsAndClear(suggestions, &waiting_requestors_);
276 } 283 }
277 284
278 } // namespace suggestions 285 } // namespace suggestions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698