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

Side by Side Diff: components/ntp_snippets/content_suggestions_metrics.cc

Issue 2797793002: Remove base::underlying_type, replace uses with std::underlying_type (Closed)
Patch Set: underlyingtype: rm-tests Created 3 years, 8 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 | « base/template_util_unittest.cc ('k') | components/prefs/pref_value_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_snippets/content_suggestions_metrics.h" 5 #include "components/ntp_snippets/content_suggestions_metrics.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <string> 8 #include <string>
9 #include <type_traits> 9 #include <type_traits>
10 10
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/metrics/histogram_functions.h" 12 #include "base/metrics/histogram_functions.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/metrics/user_metrics.h" 14 #include "base/metrics/user_metrics.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/template_util.h"
17 16
18 namespace ntp_snippets { 17 namespace ntp_snippets {
19 namespace metrics { 18 namespace metrics {
20 19
21 namespace { 20 namespace {
22 21
23 const int kMaxSuggestionsPerCategory = 10; 22 const int kMaxSuggestionsPerCategory = 10;
24 const int kMaxSuggestionsTotal = 50; 23 const int kMaxSuggestionsTotal = 50;
25 const int kMaxCategories = 10; 24 const int kMaxCategories = 10;
26 25
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 PHYSICAL_WEB_PAGES, 75 PHYSICAL_WEB_PAGES,
77 FOREIGN_TABS, 76 FOREIGN_TABS,
78 ARTICLES, 77 ARTICLES,
79 READING_LIST, 78 READING_LIST,
80 // Insert new values here! 79 // Insert new values here!
81 COUNT 80 COUNT
82 }; 81 };
83 82
84 HistogramCategories GetHistogramCategory(Category category) { 83 HistogramCategories GetHistogramCategory(Category category) {
85 static_assert( 84 static_assert(
86 std::is_same<decltype(category.id()), typename base::underlying_type< 85 std::is_same<decltype(category.id()),
87 KnownCategories>::type>::value, 86 typename std::underlying_type<KnownCategories>::type>::value,
88 "KnownCategories must have the same underlying type as category.id()"); 87 "KnownCategories must have the same underlying type as category.id()");
89 // Note: Since the underlying type of KnownCategories is int, it's legal to 88 // Note: Since the underlying type of KnownCategories is int, it's legal to
90 // cast from int to KnownCategories, even if the given value isn't listed in 89 // cast from int to KnownCategories, even if the given value isn't listed in
91 // the enumeration. The switch still makes sure that all known values are 90 // the enumeration. The switch still makes sure that all known values are
92 // listed here. 91 // listed here.
93 auto known_category = static_cast<KnownCategories>(category.id()); 92 auto known_category = static_cast<KnownCategories>(category.id());
94 switch (known_category) { 93 switch (known_category) {
95 case KnownCategories::RECENT_TABS: 94 case KnownCategories::RECENT_TABS:
96 return HistogramCategories::RECENT_TABS; 95 return HistogramCategories::RECENT_TABS;
97 case KnownCategories::DOWNLOADS: 96 case KnownCategories::DOWNLOADS:
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 356 }
358 357
359 void OnCategoryDismissed(Category category) { 358 void OnCategoryDismissed(Category category) {
360 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed, 359 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed,
361 GetHistogramCategory(category), 360 GetHistogramCategory(category),
362 HistogramCategories::COUNT); 361 HistogramCategories::COUNT);
363 } 362 }
364 363
365 } // namespace metrics 364 } // namespace metrics
366 } // namespace ntp_snippets 365 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « base/template_util_unittest.cc ('k') | components/prefs/pref_value_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698