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

Side by Side Diff: chrome/browser/android/most_visited_sites.cc

Issue 701353004: [Most Visited] Only log impression metrics on initial NTP load. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « chrome/browser/android/most_visited_sites.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 return suggestions::GetSyncState( 184 return suggestions::GetSyncState(
185 sync->IsSyncEnabledAndLoggedIn(), 185 sync->IsSyncEnabledAndLoggedIn(),
186 sync->SyncActive(), 186 sync->SyncActive(),
187 sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES)); 187 sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES));
188 } 188 }
189 189
190 } // namespace 190 } // namespace
191 191
192 MostVisitedSites::MostVisitedSites(Profile* profile) 192 MostVisitedSites::MostVisitedSites(Profile* profile)
193 : profile_(profile), num_sites_(0), is_control_group_(false), 193 : profile_(profile), num_sites_(0), is_control_group_(false),
194 num_local_thumbs_(0), num_server_thumbs_(0), num_empty_thumbs_(0), 194 initial_load_done_(false), num_local_thumbs_(0), num_server_thumbs_(0),
195 weak_ptr_factory_(this) { 195 num_empty_thumbs_(0), weak_ptr_factory_(this) {
196 // Register the debugging page for the Suggestions Service and the thumbnails 196 // Register the debugging page for the Suggestions Service and the thumbnails
197 // debugging page. 197 // debugging page.
198 content::URLDataSource::Add(profile_, 198 content::URLDataSource::Add(profile_,
199 new suggestions::SuggestionsSource(profile_)); 199 new suggestions::SuggestionsSource(profile_));
200 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); 200 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_));
201 201
202 // Register this class as an observer to the sync service. It is important to 202 // Register this class as an observer to the sync service. It is important to
203 // be notified of changes in the sync state such as initialization, sync 203 // be notified of changes in the sync state such as initialization, sync
204 // being enabled or disabled, etc. 204 // being enabled or disabled, etc.
205 ProfileSyncService* profile_sync_service = 205 ProfileSyncService* profile_sync_service =
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 void MostVisitedSites::OnMostVisitedURLsAvailable( 392 void MostVisitedSites::OnMostVisitedURLsAvailable(
393 ScopedJavaGlobalRef<jobject>* j_observer, 393 ScopedJavaGlobalRef<jobject>* j_observer,
394 int num_sites, 394 int num_sites,
395 const history::MostVisitedURLList& visited_list) { 395 const history::MostVisitedURLList& visited_list) {
396 std::vector<base::string16> titles; 396 std::vector<base::string16> titles;
397 std::vector<std::string> urls; 397 std::vector<std::string> urls;
398 ExtractMostVisitedTitlesAndURLs(visited_list, &titles, &urls, num_sites); 398 ExtractMostVisitedTitlesAndURLs(visited_list, &titles, &urls, num_sites);
399 399
400 mv_source_ = TOP_SITES; 400 mv_source_ = TOP_SITES;
401 401
402 int num_tiles = urls.size(); 402 // Only log impression metrics on the initial load of the NTP.
403 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumTilesHistogramName, num_tiles); 403 if (!initial_load_done_) {
404 const std::string histogram = is_control_group_ ? 404 int num_tiles = urls.size();
405 kImpressionControlHistogramName : kImpressionClientHistogramName; 405 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumTilesHistogramName, num_tiles);
406 for (int i = 0; i < num_tiles; ++i) { 406 const std::string histogram = is_control_group_ ?
407 LogHistogramEvent(histogram, i, num_sites_); 407 kImpressionControlHistogramName : kImpressionClientHistogramName;
408 for (int i = 0; i < num_tiles; ++i) {
409 LogHistogramEvent(histogram, i, num_sites_);
410 }
408 } 411 }
412 initial_load_done_ = true;
409 413
410 JNIEnv* env = AttachCurrentThread(); 414 JNIEnv* env = AttachCurrentThread();
411 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable( 415 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable(
412 env, 416 env,
413 j_observer->obj(), 417 j_observer->obj(),
414 ToJavaArrayOfStrings(env, titles).obj(), 418 ToJavaArrayOfStrings(env, titles).obj(),
415 ToJavaArrayOfStrings(env, urls).obj()); 419 ToJavaArrayOfStrings(env, urls).obj());
416 } 420 }
417 421
418 void MostVisitedSites::OnSuggestionsProfileAvailable( 422 void MostVisitedSites::OnSuggestionsProfileAvailable(
(...skipping 13 matching lines...) Expand all
432 } 436 }
433 437
434 std::vector<base::string16> titles; 438 std::vector<base::string16> titles;
435 std::vector<std::string> urls; 439 std::vector<std::string> urls;
436 440
437 int i = 0; 441 int i = 0;
438 for (; i < size && i < num_sites_; ++i) { 442 for (; i < size && i < num_sites_; ++i) {
439 const ChromeSuggestion& suggestion = suggestions_profile.suggestions(i); 443 const ChromeSuggestion& suggestion = suggestions_profile.suggestions(i);
440 titles.push_back(base::UTF8ToUTF16(suggestion.title())); 444 titles.push_back(base::UTF8ToUTF16(suggestion.title()));
441 urls.push_back(suggestion.url()); 445 urls.push_back(suggestion.url());
442 if (suggestion.providers_size()) { 446 // Only log impression metrics on the initial NTP load.
443 std::string histogram = base::StringPrintf( 447 if (!initial_load_done_) {
444 kImpressionServerHistogramFormat, suggestion.providers(0)); 448 if (suggestion.providers_size()) {
445 LogHistogramEvent(histogram, i, num_sites_); 449 std::string histogram = base::StringPrintf(
446 } else { 450 kImpressionServerHistogramFormat, suggestion.providers(0));
447 UMA_HISTOGRAM_SPARSE_SLOWLY(kImpressionServerHistogramName, i); 451 LogHistogramEvent(histogram, i, num_sites_);
452 } else {
453 UMA_HISTOGRAM_SPARSE_SLOWLY(kImpressionServerHistogramName, i);
454 }
448 } 455 }
449 } 456 }
450 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumTilesHistogramName, i); 457 if (!initial_load_done_) {
458 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumTilesHistogramName, i);
459 }
460 initial_load_done_ = true;
451 461
452 mv_source_ = SUGGESTIONS_SERVICE; 462 mv_source_ = SUGGESTIONS_SERVICE;
453 // Keep a copy of the suggestions for eventual logging. 463 // Keep a copy of the suggestions for eventual logging.
454 server_suggestions_ = suggestions_profile; 464 server_suggestions_ = suggestions_profile;
455 465
456 JNIEnv* env = AttachCurrentThread(); 466 JNIEnv* env = AttachCurrentThread();
457 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable( 467 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable(
458 env, 468 env,
459 j_observer->obj(), 469 j_observer->obj(),
460 ToJavaArrayOfStrings(env, titles).obj(), 470 ToJavaArrayOfStrings(env, titles).obj(),
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 num_empty_thumbs_ = 0; 526 num_empty_thumbs_ = 0;
517 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumServerTilesHistogramName, num_server_thumbs_); 527 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumServerTilesHistogramName, num_server_thumbs_);
518 num_server_thumbs_ = 0; 528 num_server_thumbs_ = 0;
519 } 529 }
520 530
521 static jlong Init(JNIEnv* env, jobject obj, jobject jprofile) { 531 static jlong Init(JNIEnv* env, jobject obj, jobject jprofile) {
522 MostVisitedSites* most_visited_sites = 532 MostVisitedSites* most_visited_sites =
523 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile)); 533 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile));
524 return reinterpret_cast<intptr_t>(most_visited_sites); 534 return reinterpret_cast<intptr_t>(most_visited_sites);
525 } 535 }
OLDNEW
« no previous file with comments | « chrome/browser/android/most_visited_sites.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698