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

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

Issue 343643002: [Android NTP] Use UMA histograms instead of local ones. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « no previous file | 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 break; 271 break;
272 } 272 }
273 } 273 }
274 } 274 }
275 275
276 void MostVisitedSites::RecordOpenedMostVisitedItem(JNIEnv* env, 276 void MostVisitedSites::RecordOpenedMostVisitedItem(JNIEnv* env,
277 jobject obj, 277 jobject obj,
278 jint index) { 278 jint index) {
279 switch (mv_source_) { 279 switch (mv_source_) {
280 case TOP_SITES: { 280 case TOP_SITES: {
281 HISTOGRAM_SPARSE_SLOWLY(kOpenedItemClientHistogramName, index); 281 UMA_HISTOGRAM_SPARSE_SLOWLY(kOpenedItemClientHistogramName, index);
282 break; 282 break;
283 } 283 }
284 case SUGGESTIONS_SERVICE: { 284 case SUGGESTIONS_SERVICE: {
285 if (server_suggestions_.suggestions_size() > index) { 285 if (server_suggestions_.suggestions_size() > index) {
286 if (server_suggestions_.suggestions(index).providers_size()) { 286 if (server_suggestions_.suggestions(index).providers_size()) {
287 std::string histogram = base::StringPrintf( 287 std::string histogram = base::StringPrintf(
288 kOpenedItemServerProviderHistogramFormat, 288 kOpenedItemServerProviderHistogramFormat,
289 server_suggestions_.suggestions(index).providers(0)); 289 server_suggestions_.suggestions(index).providers(0));
290 LogHistogramEvent(histogram, index, num_sites_); 290 LogHistogramEvent(histogram, index, num_sites_);
291 } else { 291 } else {
292 HISTOGRAM_SPARSE_SLOWLY(kOpenedItemServerHistogramName, index); 292 UMA_HISTOGRAM_SPARSE_SLOWLY(kOpenedItemServerHistogramName, index);
293 } 293 }
294 } 294 }
295 break; 295 break;
296 } 296 }
297 } 297 }
298 } 298 }
299 299
300 void MostVisitedSites::Observe(int type, 300 void MostVisitedSites::Observe(int type,
301 const content::NotificationSource& source, 301 const content::NotificationSource& source,
302 const content::NotificationDetails& details) { 302 const content::NotificationDetails& details) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 ScopedJavaGlobalRef<jobject>* j_observer, 346 ScopedJavaGlobalRef<jobject>* j_observer,
347 int num_sites, 347 int num_sites,
348 const history::MostVisitedURLList& visited_list) { 348 const history::MostVisitedURLList& visited_list) {
349 std::vector<base::string16> titles; 349 std::vector<base::string16> titles;
350 std::vector<std::string> urls; 350 std::vector<std::string> urls;
351 ExtractMostVisitedTitlesAndURLs(visited_list, &titles, &urls, num_sites); 351 ExtractMostVisitedTitlesAndURLs(visited_list, &titles, &urls, num_sites);
352 352
353 mv_source_ = TOP_SITES; 353 mv_source_ = TOP_SITES;
354 354
355 int num_tiles = urls.size(); 355 int num_tiles = urls.size();
356 HISTOGRAM_SPARSE_SLOWLY(kNumTilesHistogramName, num_tiles); 356 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumTilesHistogramName, num_tiles);
357 for (int i = 0; i < num_tiles; ++i) { 357 for (int i = 0; i < num_tiles; ++i) {
358 HISTOGRAM_SPARSE_SLOWLY(kImpressionClientHistogramName, i); 358 UMA_HISTOGRAM_SPARSE_SLOWLY(kImpressionClientHistogramName, i);
359 } 359 }
360 360
361 JNIEnv* env = AttachCurrentThread(); 361 JNIEnv* env = AttachCurrentThread();
362 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable( 362 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable(
363 env, 363 env,
364 j_observer->obj(), 364 j_observer->obj(),
365 ToJavaArrayOfStrings(env, titles).obj(), 365 ToJavaArrayOfStrings(env, titles).obj(),
366 ToJavaArrayOfStrings(env, urls).obj()); 366 ToJavaArrayOfStrings(env, urls).obj());
367 } 367 }
368 368
(...skipping 13 matching lines...) Expand all
382 int i = 0; 382 int i = 0;
383 for (; i < size && i < num_sites_; ++i) { 383 for (; i < size && i < num_sites_; ++i) {
384 const ChromeSuggestion& suggestion = suggestions_profile.suggestions(i); 384 const ChromeSuggestion& suggestion = suggestions_profile.suggestions(i);
385 titles.push_back(base::UTF8ToUTF16(suggestion.title())); 385 titles.push_back(base::UTF8ToUTF16(suggestion.title()));
386 urls.push_back(suggestion.url()); 386 urls.push_back(suggestion.url());
387 if (suggestion.providers_size()) { 387 if (suggestion.providers_size()) {
388 std::string histogram = base::StringPrintf( 388 std::string histogram = base::StringPrintf(
389 kImpressionServerHistogramFormat, suggestion.providers(0)); 389 kImpressionServerHistogramFormat, suggestion.providers(0));
390 LogHistogramEvent(histogram, i, num_sites_); 390 LogHistogramEvent(histogram, i, num_sites_);
391 } else { 391 } else {
392 HISTOGRAM_SPARSE_SLOWLY(kImpressionServerHistogramName, i); 392 UMA_HISTOGRAM_SPARSE_SLOWLY(kImpressionServerHistogramName, i);
393 } 393 }
394 } 394 }
395 HISTOGRAM_SPARSE_SLOWLY(kNumTilesHistogramName, i); 395 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumTilesHistogramName, i);
396 396
397 mv_source_ = SUGGESTIONS_SERVICE; 397 mv_source_ = SUGGESTIONS_SERVICE;
398 // Keep a copy of the suggestions for eventual logging. 398 // Keep a copy of the suggestions for eventual logging.
399 server_suggestions_ = suggestions_profile; 399 server_suggestions_ = suggestions_profile;
400 400
401 JNIEnv* env = AttachCurrentThread(); 401 JNIEnv* env = AttachCurrentThread();
402 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable( 402 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable(
403 env, 403 env,
404 j_observer->obj(), 404 j_observer->obj(),
405 ToJavaArrayOfStrings(env, titles).obj(), 405 ToJavaArrayOfStrings(env, titles).obj(),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 gfx::ConvertToJavaBitmap(bitmap).obj()); 447 gfx::ConvertToJavaBitmap(bitmap).obj());
448 } else { 448 } else {
449 num_empty_thumbs_++; 449 num_empty_thumbs_++;
450 } 450 }
451 451
452 Java_ThumbnailCallback_onMostVisitedURLsThumbnailAvailable( 452 Java_ThumbnailCallback_onMostVisitedURLsThumbnailAvailable(
453 env, j_callback->obj(), j_bitmap_ref->obj()); 453 env, j_callback->obj(), j_bitmap_ref->obj());
454 } 454 }
455 455
456 void MostVisitedSites::RecordUMAMetrics() { 456 void MostVisitedSites::RecordUMAMetrics() {
457 HISTOGRAM_SPARSE_SLOWLY(kNumLocalThumbnailTilesHistogramName, 457 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumLocalThumbnailTilesHistogramName,
458 num_local_thumbs_); 458 num_local_thumbs_);
459 num_local_thumbs_ = 0; 459 num_local_thumbs_ = 0;
460 HISTOGRAM_SPARSE_SLOWLY(kNumEmptyTilesHistogramName, num_empty_thumbs_); 460 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumEmptyTilesHistogramName, num_empty_thumbs_);
461 num_empty_thumbs_ = 0; 461 num_empty_thumbs_ = 0;
462 HISTOGRAM_SPARSE_SLOWLY(kNumServerTilesHistogramName, num_server_thumbs_); 462 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumServerTilesHistogramName, num_server_thumbs_);
463 num_server_thumbs_ = 0; 463 num_server_thumbs_ = 0;
464 } 464 }
465 465
466 static jlong Init(JNIEnv* env, jobject obj, jobject jprofile) { 466 static jlong Init(JNIEnv* env, jobject obj, jobject jprofile) {
467 MostVisitedSites* most_visited_sites = 467 MostVisitedSites* most_visited_sites =
468 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile)); 468 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile));
469 return reinterpret_cast<intptr_t>(most_visited_sites); 469 return reinterpret_cast<intptr_t>(most_visited_sites);
470 } 470 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698