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

Side by Side Diff: components/ntp_tiles/most_visited_sites.cc

Issue 2136503002: NTP: Fix metrics recording race condition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@android_uma
Patch Set: rebase Created 4 years, 5 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
« no previous file with comments | « components/ntp_tiles/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 "components/ntp_tiles/most_visited_sites.h" 5 #include "components/ntp_tiles/most_visited_sites.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 240 }
241 241
242 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsReal", 242 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsReal",
243 counts_per_type[ICON_REAL]); 243 counts_per_type[ICON_REAL]);
244 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsColor", 244 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsColor",
245 counts_per_type[ICON_COLOR]); 245 counts_per_type[ICON_COLOR]);
246 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsGray", 246 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsGray",
247 counts_per_type[ICON_DEFAULT]); 247 counts_per_type[ICON_DEFAULT]);
248 } 248 }
249 249
250 void MostVisitedSites::RecordOpenedMostVisitedItem(int index, int tile_type) { 250 void MostVisitedSites::RecordOpenedMostVisitedItem(int index,
251 // TODO(treib): |current_suggestions_| could be updated before this function 251 int tile_type,
252 // is called, leading to DCHECKs and/or memory corruption. Adjust this 252 int source) {
253 // function to work with asynchronous UI.
254 DCHECK_GE(index, 0);
255 DCHECK_LT(index, static_cast<int>(current_suggestions_.size()));
256
257 UMA_HISTOGRAM_ENUMERATION("NewTabPage.MostVisited", index, num_sites_); 253 UMA_HISTOGRAM_ENUMERATION("NewTabPage.MostVisited", index, num_sites_);
258 254
259 std::string histogram = base::StringPrintf( 255 std::string histogram = base::StringPrintf(
260 "NewTabPage.MostVisited.%s", 256 "NewTabPage.MostVisited.%s", GetSourceHistogramName(source).c_str());
261 GetSourceHistogramName(current_suggestions_[index].source).c_str());
262 LogHistogramEvent(histogram, index, num_sites_); 257 LogHistogramEvent(histogram, index, num_sites_);
263 258
264 histogram = base::StringPrintf( 259 histogram = base::StringPrintf("NewTabPage.TileTypeClicked.%s",
265 "NewTabPage.TileTypeClicked.%s", 260 GetSourceHistogramName(source).c_str());
266 GetSourceHistogramName(current_suggestions_[index].source).c_str());
267 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES); 261 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES);
268 } 262 }
269 263
270 void MostVisitedSites::OnBlockedSitesChanged() { 264 void MostVisitedSites::OnBlockedSitesChanged() {
271 BuildCurrentSuggestions(); 265 BuildCurrentSuggestions();
272 } 266 }
273 267
274 // static 268 // static
275 void MostVisitedSites::RegisterProfilePrefs( 269 void MostVisitedSites::RegisterProfilePrefs(
276 user_prefs::PrefRegistrySyncable* registry) { 270 user_prefs::PrefRegistrySyncable* registry) {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 543
550 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, 544 void MostVisitedSites::TopSitesChanged(TopSites* top_sites,
551 ChangeReason change_reason) { 545 ChangeReason change_reason) {
552 if (mv_source_ == TOP_SITES) { 546 if (mv_source_ == TOP_SITES) {
553 // The displayed suggestions are invalidated. 547 // The displayed suggestions are invalidated.
554 InitiateTopSitesQuery(); 548 InitiateTopSitesQuery();
555 } 549 }
556 } 550 }
557 551
558 } // namespace ntp_tiles 552 } // namespace ntp_tiles
OLDNEW
« no previous file with comments | « components/ntp_tiles/most_visited_sites.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698