ntp_snippets enums: use enum class instead of plain c++ enum |
|||
Issue description
e.g. in ntp_snippets_metrics
That would consist in replacing things like
enum ContentSuggestionsNotificationAction {
CONTENT_SUGGESTIONS_TAP = 0,
CONTENT_SUGGESTIONS_DISMISSAL,
...
with
enum class ContentSuggestionsNotificationAction {
TAP = 0,
DISMISSAL,
...
For better scoping and also generating cleaner java enums.
,
Apr 11 2017
Ah you mean it requires an extra static_cast<int>() ? Doesn't seem too bad, we'd do that only in a single place, when calling the macro, right?
,
Apr 12 2017
The UMA_HISTOGRAM_ENUMERATION macro has some static_asserts on the passed-in types, and I *thought* those triggered if you just passed in ints. But from looking at the code (https://cs.chromium.org/webrtc/src/base/metrics/histogram_macros_internal.h?type=cs&q=INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG&l=140), that shouldn't be the case. So yes, if all that's required is a cast to int, then that's fine.
,
Jan 11 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/7fd744931c8b702cc7977f36bb88e3ddab2ce5ee commit 7fd744931c8b702cc7977f36bb88e3ddab2ce5ee Author: Zhuoyu Qian <zhuoyu.qian@samsung.com> Date: Thu Jan 11 01:32:33 2018 Switch ntp_snippets enums to be enum class. This patch makes ContentSuggestionsNotification{Impression/Action/OptOut} to enum class for better type safety. Rename the enumerators. BUG= 710254 Signed-off-by: Zhuoyu Qian <zhuoyu.qian@samsung.com> Change-Id: I7f4a227b37dbc7dd1c6ab17a6ad0fb84344d35d9 Reviewed-on: https://chromium-review.googlesource.com/850655 Reviewed-by: Nicolas Dossou-Gbété <dgn@chromium.org> Reviewed-by: Marc Treib <treib@chromium.org> Cr-Commit-Position: refs/heads/master@{#528522} [modify] https://crrev.com/7fd744931c8b702cc7977f36bb88e3ddab2ce5ee/chrome/browser/android/ntp/android_content_suggestions_notifier.cc [modify] https://crrev.com/7fd744931c8b702cc7977f36bb88e3ddab2ce5ee/chrome/browser/android/ntp/content_suggestions_notifier_service.cc [modify] https://crrev.com/7fd744931c8b702cc7977f36bb88e3ddab2ce5ee/chrome/browser/ntp_snippets/ntp_snippets_metrics.cc [modify] https://crrev.com/7fd744931c8b702cc7977f36bb88e3ddab2ce5ee/chrome/browser/ntp_snippets/ntp_snippets_metrics.h [modify] https://crrev.com/7fd744931c8b702cc7977f36bb88e3ddab2ce5ee/chrome/browser/ui/webui/snippets_internals_message_handler.cc
,
Jan 12 2018
,
Jan 15 2018
Query to find remaining non-class enums: https://cs.chromium.org/search/?q=f:ntp_snippets+enum%5Cs%5Cw%2B%5Cs%7B+lang:cc+-f:out&sq=package:chromium&type=cs
,
Mar 21 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/6b8cc4b9cbf971a02cb723772ff295a387e4d5df commit 6b8cc4b9cbf971a02cb723772ff295a387e4d5df Author: Zhuoyu Qian <zhuoyu.qian@samsung.com> Date: Wed Mar 21 09:21:28 2018 Switch ntp_snippets enums to be enum class instead of plain c++ enum. This patch makes HistogramCategories, ContentSuggestionsService::State, RemoteSuggestion::ContentType, ReceivedMessageAction and TestType to enum class instead of plain C++ enum for better type safety. Bug: 710254 Signed-off-by: Zhuoyu Qian <zhuoyu.qian@samsung.com> Change-Id: I40ff10809aa5e135b3ac9380ba54e97170eed02d Reviewed-on: https://chromium-review.googlesource.com/970049 Reviewed-by: Marc Treib <treib@chromium.org> Cr-Commit-Position: refs/heads/master@{#544658} [modify] https://crrev.com/6b8cc4b9cbf971a02cb723772ff295a387e4d5df/chrome/browser/android/ntp/content_suggestions_notifier_service_unittest.cc [modify] https://crrev.com/6b8cc4b9cbf971a02cb723772ff295a387e4d5df/components/ntp_snippets/breaking_news/breaking_news_gcm_app_handler_unittest.cc [modify] https://crrev.com/6b8cc4b9cbf971a02cb723772ff295a387e4d5df/components/ntp_snippets/breaking_news/breaking_news_metrics.h [modify] https://crrev.com/6b8cc4b9cbf971a02cb723772ff295a387e4d5df/components/ntp_snippets/content_suggestions_metrics.cc [modify] https://crrev.com/6b8cc4b9cbf971a02cb723772ff295a387e4d5df/components/ntp_snippets/content_suggestions_service.h [modify] https://crrev.com/6b8cc4b9cbf971a02cb723772ff295a387e4d5df/components/ntp_snippets/remote/cached_image_fetcher_unittest.cc [modify] https://crrev.com/6b8cc4b9cbf971a02cb723772ff295a387e4d5df/components/ntp_snippets/remote/remote_suggestion.h
,
Mar 22 2018
I think this issue is fixed.
,
Mar 22 2018
Yup, thanks! |
|||
►
Sign in to add a comment |
|||
Comment 1 by treib@chromium.org
, Apr 11 2017