New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 710254 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner: ----
Closed: Mar 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

ntp_snippets enums: use enum class instead of plain c++ enum

Project Member Reported by dgn@chromium.org, Apr 10 2017

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.
 

Comment 1 by treib@chromium.org, Apr 11 2017

Cc: dgn@chromium.org
IIRC, the UMA histogram macros don't work well with enum classes, so that might be the reason for using plain old enums there.

Comment 2 by dgn@chromium.org, 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?

Comment 3 by treib@chromium.org, 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.
Project Member

Comment 4 by bugdroid1@chromium.org, Jan 11 2018

Comment 5 by fi...@chromium.org, Jan 12 2018

Components: -UI>Browser>NewTabPage UI>Browser>ContentSuggestions
Project Member

Comment 7 by bugdroid1@chromium.org, 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

I think this issue is fixed.

Comment 9 by treib@chromium.org, Mar 22 2018

Status: Fixed (was: Available)
Yup, thanks!

Sign in to add a comment