Commit a96df5ac authored by Marcin Wiącek's avatar Marcin Wiącek Committed by Commit Bot

Improve @IntDef in Chrome/Android

This patch is aligning various @IntDef to some standard used with many other CLs:

1. @IntDef is first, @Retention second and related @interface third
2. NUM_ENTRIES declaring number of entries is not included into @IntDef
3. there is used @Retention(RetentionPolicy.SOURCE)

BUG=919666

Change-Id: I0a2e0600e09ec1919b83e7bafc7e4ff6698dfa9d
Reviewed-on: https://chromium-review.googlesource.com/c/1461041Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Marcin Wiącek <marcin@mwiacek.com>
Cr-Commit-Position: refs/heads/master@{#631995}
parent 685e93d8
......@@ -73,7 +73,7 @@ public class ExploreSitesBackgroundTask extends NativeBackgroundTask {
(ignored) -> mTaskFinishedCallback.taskFinished(false));
RecordHistogram.recordEnumeratedHistogram("ExploreSites.CatalogUpdateRequestSource",
ExploreSitesEnums.CatalogUpdateRequestSource.BACKGROUND,
ExploreSitesEnums.CatalogUpdateRequestSource.COUNT);
ExploreSitesEnums.CatalogUpdateRequestSource.NUM_ENTRIES);
}
@Override
......
......@@ -30,15 +30,14 @@ public class ExploreSitesCategory {
static final int MAX_COLUMNS = 4;
// This enum must match the numbering for ExploreSites.CategoryClick in histograms.xml. Do not
// reorder or remove items, only add new items before COUNT.
@Retention(RetentionPolicy.SOURCE)
// reorder or remove items, only add new items before NUM_ENTRIES.
@IntDef({CategoryType.MORE_BUTTON, CategoryType.DEFAULT, CategoryType.SOCIAL,
CategoryType.ENTERTAINMENT, CategoryType.SPORT, CategoryType.NEWS,
CategoryType.SHOPPING, CategoryType.REFERENCE, CategoryType.BANKING,
CategoryType.GOVERNMENT, CategoryType.TRAVEL, CategoryType.EDUCATION, CategoryType.JOBS,
CategoryType.APPS_GAMES, CategoryType.FAVORITE, CategoryType.GOOGLE, CategoryType.FOOD,
CategoryType.HEALTH, CategoryType.BOOKS, CategoryType.TECHNOLOGY, CategoryType.SCIENCE,
CategoryType.COUNT})
CategoryType.HEALTH, CategoryType.BOOKS, CategoryType.TECHNOLOGY, CategoryType.SCIENCE})
@Retention(RetentionPolicy.SOURCE)
public @interface CategoryType {
int MORE_BUTTON = -1; // This is not included in histograms.xml.
int DEFAULT = 0;
......@@ -62,7 +61,7 @@ public class ExploreSitesCategory {
int TECHNOLOGY = 18;
int SCIENCE = 19;
// This must always be one higher than the last category number.
int COUNT = 20;
int NUM_ENTRIES = 20;
}
public static ExploreSitesCategory createPlaceholder(
......
......@@ -226,8 +226,8 @@ public class ExploreSitesCategoryCardView extends LinearLayout {
* @param category The category the user picked.
*/
public static void recordCategoryClick(int category) {
RecordHistogram.recordEnumeratedHistogram(
"ExploreSites.CategoryClick", category, ExploreSitesCategory.CategoryType.COUNT);
RecordHistogram.recordEnumeratedHistogram("ExploreSites.CategoryClick", category,
ExploreSitesCategory.CategoryType.NUM_ENTRIES);
}
/**
......
......@@ -16,12 +16,12 @@ import java.lang.annotation.RetentionPolicy;
public class ExploreSitesEnums {
/** Enum for use with UMA for identifying where a catalog update request started. */
@IntDef({CatalogUpdateRequestSource.NEW_TAB_PAGE, CatalogUpdateRequestSource.EXPLORE_SITES_PAGE,
CatalogUpdateRequestSource.BACKGROUND, CatalogUpdateRequestSource.COUNT})
CatalogUpdateRequestSource.BACKGROUND})
@Retention(RetentionPolicy.SOURCE)
public @interface CatalogUpdateRequestSource {
int NEW_TAB_PAGE = 0; // Catalog update request came from NTP
int EXPLORE_SITES_PAGE = 1; // Catalog update request came from ESP
int BACKGROUND = 2; // Catalog update request came from background update.
int COUNT = 3; // This must always be one higher than the last value.
int NUM_ENTRIES = 3; // This must always be one higher than the last value.
}
}
......@@ -161,7 +161,7 @@ public class ExploreSitesPage extends BasicNativePage {
mProfile, /* isImmediateFetch =*/true, this::onUpdatedCatalog);
RecordHistogram.recordEnumeratedHistogram("ExploreSites.CatalogUpdateRequestSource",
ExploreSitesEnums.CatalogUpdateRequestSource.EXPLORE_SITES_PAGE,
ExploreSitesEnums.CatalogUpdateRequestSource.COUNT);
ExploreSitesEnums.CatalogUpdateRequestSource.NUM_ENTRIES);
return;
}
mModel.set(STATUS_KEY, CatalogLoadingState.SUCCESS);
......
......@@ -138,7 +138,7 @@ public class ExploreSitesSection {
(Boolean success) -> { updateCategoryIcons(); });
RecordHistogram.recordEnumeratedHistogram("ExploreSites.CatalogUpdateRequestSource",
ExploreSitesEnums.CatalogUpdateRequestSource.NEW_TAB_PAGE,
ExploreSitesEnums.CatalogUpdateRequestSource.COUNT);
ExploreSitesEnums.CatalogUpdateRequestSource.NUM_ENTRIES);
}
RecordHistogram.recordBooleanHistogram(
"ExploreSites.NTPLoadingCatalogFromNetwork", loadingCatalogFromNetwork);
......
......@@ -36,7 +36,7 @@ public class SideSlideLayout extends ViewGroup {
@IntDef({UmaNavigationType.NAVIGATION_TYPE_NONE, UmaNavigationType.FORWARD_TOUCHPAD,
UmaNavigationType.BACK_TOUCHPAD, UmaNavigationType.FORWARD_TOUCHSCREEN,
UmaNavigationType.BACK_TOUCHSCREEN, UmaNavigationType.RELOAD_TOUCHPAD,
UmaNavigationType.RELOAD_TOUCHSCREEN, UmaNavigationType.NAVIGATION_TYPE_COUNT})
UmaNavigationType.RELOAD_TOUCHSCREEN})
@Retention(RetentionPolicy.SOURCE)
private @interface UmaNavigationType {
int NAVIGATION_TYPE_NONE = 0;
......@@ -46,7 +46,7 @@ public class SideSlideLayout extends ViewGroup {
int BACK_TOUCHSCREEN = 4;
int RELOAD_TOUCHPAD = 5;
int RELOAD_TOUCHSCREEN = 6;
int NAVIGATION_TYPE_COUNT = 7;
int NUM_ENTRIES = 7;
}
/**
......@@ -379,6 +379,6 @@ public class SideSlideLayout extends ViewGroup {
RecordHistogram.recordEnumeratedHistogram(name,
forward ? UmaNavigationType.FORWARD_TOUCHSCREEN
: UmaNavigationType.BACK_TOUCHSCREEN,
UmaNavigationType.NAVIGATION_TYPE_COUNT);
UmaNavigationType.NUM_ENTRIES);
}
}
......@@ -123,13 +123,12 @@ public final class NewTabPageUma {
int NUM_ENTRIES = 4;
}
@IntDef({ContentSuggestionsDisplayStatus.VISIBLE, ContentSuggestionsDisplayStatus.COLLAPSED,
ContentSuggestionsDisplayStatus.DISABLED_BY_POLICY,
ContentSuggestionsDisplayStatus.NUM_ENTRIES})
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused. This maps directly to
// the ContentSuggestionsDisplayStatus enum defined in tools/metrics/enums.xml.
@IntDef({ContentSuggestionsDisplayStatus.VISIBLE, ContentSuggestionsDisplayStatus.COLLAPSED,
ContentSuggestionsDisplayStatus.DISABLED_BY_POLICY})
@Retention(RetentionPolicy.SOURCE)
private @interface ContentSuggestionsDisplayStatus {
int VISIBLE = 0;
int COLLAPSED = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment