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

Side by Side Diff: chrome/browser/android/most_visited_sites.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: rebased 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/android/most_visited_sites.h" 5 #include "chrome/browser/android/most_visited_sites.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 // Total number of tiles displayed. 52 // Total number of tiles displayed.
53 const char kNumTilesHistogramName[] = "NewTabPage.NumberOfTiles"; 53 const char kNumTilesHistogramName[] = "NewTabPage.NumberOfTiles";
54 // Tracking thumbnails. 54 // Tracking thumbnails.
55 const char kNumLocalThumbnailTilesHistogramName[] = 55 const char kNumLocalThumbnailTilesHistogramName[] =
56 "NewTabPage.NumberOfThumbnailTiles"; 56 "NewTabPage.NumberOfThumbnailTiles";
57 const char kNumEmptyTilesHistogramName[] = "NewTabPage.NumberOfGrayTiles"; 57 const char kNumEmptyTilesHistogramName[] = "NewTabPage.NumberOfGrayTiles";
58 const char kNumServerTilesHistogramName[] = "NewTabPage.NumberOfExternalTiles"; 58 const char kNumServerTilesHistogramName[] = "NewTabPage.NumberOfExternalTiles";
59 // Client suggestion opened. 59 // Client suggestion opened.
60 const char kOpenedItemClientHistogramName[] = "NewTabPage.MostVisited.client"; 60 const char kOpenedItemClientHistogramName[] = "NewTabPage.MostVisited.client";
61 // Control group suggestion opened.
62 const char kOpenedItemControlHistogramName[] = "NewTabPage.MostVisited.client0";
61 // Server suggestion opened, no provider. 63 // Server suggestion opened, no provider.
62 const char kOpenedItemServerHistogramName[] = "NewTabPage.MostVisited.server"; 64 const char kOpenedItemServerHistogramName[] = "NewTabPage.MostVisited.server";
63 // Server suggestion opened with provider. 65 // Server suggestion opened with provider.
64 const char kOpenedItemServerProviderHistogramFormat[] = 66 const char kOpenedItemServerProviderHistogramFormat[] =
65 "NewTabPage.MostVisited.server%d"; 67 "NewTabPage.MostVisited.server%d";
66 // Client impression. 68 // Client impression.
67 const char kImpressionClientHistogramName[] = 69 const char kImpressionClientHistogramName[] =
68 "NewTabPage.SuggestionsImpression.client"; 70 "NewTabPage.SuggestionsImpression.client";
71 // Control group impression.
72 const char kImpressionControlHistogramName[] =
73 "NewTabPage.SuggestionsImpression.client0";
69 // Server suggestion impression, no provider. 74 // Server suggestion impression, no provider.
70 const char kImpressionServerHistogramName[] = 75 const char kImpressionServerHistogramName[] =
71 "NewTabPage.SuggestionsImpression.server"; 76 "NewTabPage.SuggestionsImpression.server";
72 // Server suggestion impression with provider. 77 // Server suggestion impression with provider.
73 const char kImpressionServerHistogramFormat[] = 78 const char kImpressionServerHistogramFormat[] =
74 "NewTabPage.SuggestionsImpression.server%d"; 79 "NewTabPage.SuggestionsImpression.server%d";
75 80
76 void ExtractMostVisitedTitlesAndURLs( 81 void ExtractMostVisitedTitlesAndURLs(
77 const history::MostVisitedURLList& visited_list, 82 const history::MostVisitedURLList& visited_list,
78 std::vector<base::string16>* titles, 83 std::vector<base::string16>* titles,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 1, 166 1,
162 num_sites, 167 num_sites,
163 num_sites + 1, 168 num_sites + 1,
164 base::Histogram::kUmaTargetedHistogramFlag); 169 base::Histogram::kUmaTargetedHistogramFlag);
165 counter->Add(position); 170 counter->Add(position);
166 } 171 }
167 172
168 } // namespace 173 } // namespace
169 174
170 MostVisitedSites::MostVisitedSites(Profile* profile) 175 MostVisitedSites::MostVisitedSites(Profile* profile)
171 : profile_(profile), num_sites_(0), num_local_thumbs_(0), 176 : profile_(profile), num_sites_(0), is_control_group_(false),
172 num_server_thumbs_(0), num_empty_thumbs_(0), weak_ptr_factory_(this) { 177 num_local_thumbs_(0), num_server_thumbs_(0), num_empty_thumbs_(0),
178 weak_ptr_factory_(this) {
173 // Register the debugging page for the Suggestions Service and the thumbnails 179 // Register the debugging page for the Suggestions Service and the thumbnails
174 // debugging page. 180 // debugging page.
175 content::URLDataSource::Add(profile_, 181 content::URLDataSource::Add(profile_,
176 new suggestions::SuggestionsSource(profile_)); 182 new suggestions::SuggestionsSource(profile_));
177 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); 183 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_));
178 } 184 }
179 185
180 MostVisitedSites::~MostVisitedSites() { 186 MostVisitedSites::~MostVisitedSites() {
181 } 187 }
182 188
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 break; 277 break;
272 } 278 }
273 } 279 }
274 } 280 }
275 281
276 void MostVisitedSites::RecordOpenedMostVisitedItem(JNIEnv* env, 282 void MostVisitedSites::RecordOpenedMostVisitedItem(JNIEnv* env,
277 jobject obj, 283 jobject obj,
278 jint index) { 284 jint index) {
279 switch (mv_source_) { 285 switch (mv_source_) {
280 case TOP_SITES: { 286 case TOP_SITES: {
281 UMA_HISTOGRAM_SPARSE_SLOWLY(kOpenedItemClientHistogramName, index); 287 const std::string histogram = is_control_group_ ?
288 kOpenedItemControlHistogramName : kOpenedItemClientHistogramName;
289 LogHistogramEvent(histogram, index, num_sites_);
282 break; 290 break;
283 } 291 }
284 case SUGGESTIONS_SERVICE: { 292 case SUGGESTIONS_SERVICE: {
285 if (server_suggestions_.suggestions_size() > index) { 293 if (server_suggestions_.suggestions_size() > index) {
286 if (server_suggestions_.suggestions(index).providers_size()) { 294 if (server_suggestions_.suggestions(index).providers_size()) {
287 std::string histogram = base::StringPrintf( 295 std::string histogram = base::StringPrintf(
288 kOpenedItemServerProviderHistogramFormat, 296 kOpenedItemServerProviderHistogramFormat,
289 server_suggestions_.suggestions(index).providers(0)); 297 server_suggestions_.suggestions(index).providers(0));
290 LogHistogramEvent(histogram, index, num_sites_); 298 LogHistogramEvent(histogram, index, num_sites_);
291 } else { 299 } else {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 int num_sites, 355 int num_sites,
348 const history::MostVisitedURLList& visited_list) { 356 const history::MostVisitedURLList& visited_list) {
349 std::vector<base::string16> titles; 357 std::vector<base::string16> titles;
350 std::vector<std::string> urls; 358 std::vector<std::string> urls;
351 ExtractMostVisitedTitlesAndURLs(visited_list, &titles, &urls, num_sites); 359 ExtractMostVisitedTitlesAndURLs(visited_list, &titles, &urls, num_sites);
352 360
353 mv_source_ = TOP_SITES; 361 mv_source_ = TOP_SITES;
354 362
355 int num_tiles = urls.size(); 363 int num_tiles = urls.size();
356 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumTilesHistogramName, num_tiles); 364 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumTilesHistogramName, num_tiles);
365 const std::string histogram = is_control_group_ ?
366 kImpressionControlHistogramName : kImpressionClientHistogramName;
357 for (int i = 0; i < num_tiles; ++i) { 367 for (int i = 0; i < num_tiles; ++i) {
358 UMA_HISTOGRAM_SPARSE_SLOWLY(kImpressionClientHistogramName, i); 368 LogHistogramEvent(histogram, i, num_sites_);
359 } 369 }
360 370
361 JNIEnv* env = AttachCurrentThread(); 371 JNIEnv* env = AttachCurrentThread();
362 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable( 372 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable(
363 env, 373 env,
364 j_observer->obj(), 374 j_observer->obj(),
365 ToJavaArrayOfStrings(env, titles).obj(), 375 ToJavaArrayOfStrings(env, titles).obj(),
366 ToJavaArrayOfStrings(env, urls).obj()); 376 ToJavaArrayOfStrings(env, urls).obj());
367 } 377 }
368 378
369 void MostVisitedSites::OnSuggestionsProfileAvailable( 379 void MostVisitedSites::OnSuggestionsProfileAvailable(
370 ScopedJavaGlobalRef<jobject>* j_observer, 380 ScopedJavaGlobalRef<jobject>* j_observer,
371 const SuggestionsProfile& suggestions_profile) { 381 const SuggestionsProfile& suggestions_profile) {
372 int size = suggestions_profile.suggestions_size(); 382 int size = suggestions_profile.suggestions_size();
373 if (size == 0) { 383
374 // No suggestions data available, initiate Top Sites query. 384 // Determine if the user is in a control group (they would have received
385 // suggestions, but are in a group where they shouldn't).
386 is_control_group_ = size && SuggestionsService::IsControlGroup();
387
388 // If no suggestions data is available or the user is in a control group,
389 // initiate Top Sites query.
390 if (is_control_group_ || !size) {
375 InitiateTopSitesQuery(); 391 InitiateTopSitesQuery();
376 return; 392 return;
377 } 393 }
378 394
379 std::vector<base::string16> titles; 395 std::vector<base::string16> titles;
380 std::vector<std::string> urls; 396 std::vector<std::string> urls;
381 397
382 int i = 0; 398 int i = 0;
383 for (; i < size && i < num_sites_; ++i) { 399 for (; i < size && i < num_sites_; ++i) {
384 const ChromeSuggestion& suggestion = suggestions_profile.suggestions(i); 400 const ChromeSuggestion& suggestion = suggestions_profile.suggestions(i);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 num_empty_thumbs_ = 0; 477 num_empty_thumbs_ = 0;
462 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumServerTilesHistogramName, num_server_thumbs_); 478 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumServerTilesHistogramName, num_server_thumbs_);
463 num_server_thumbs_ = 0; 479 num_server_thumbs_ = 0;
464 } 480 }
465 481
466 static jlong Init(JNIEnv* env, jobject obj, jobject jprofile) { 482 static jlong Init(JNIEnv* env, jobject obj, jobject jprofile) {
467 MostVisitedSites* most_visited_sites = 483 MostVisitedSites* most_visited_sites =
468 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile)); 484 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile));
469 return reinterpret_cast<intptr_t>(most_visited_sites); 485 return reinterpret_cast<intptr_t>(most_visited_sites);
470 } 486 }
OLDNEW
« no previous file with comments | « chrome/browser/android/most_visited_sites.h ('k') | chrome/browser/search/suggestions/suggestions_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698