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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelDefinitions.java

Issue 2832493002: [Android O] Only delete legacy notification channels on upgrade (Closed)
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelDefinitions.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelDefinitions.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelDefinitions.java
index c7842aaa479685a870f774881f251b770191d485..8e66a2ebf3fc20aba09fb92935ddc9edb846c282 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelDefinitions.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelDefinitions.java
@@ -33,13 +33,17 @@ public class ChannelDefinitions {
static final String CHANNEL_GROUP_ID_GENERAL = "general";
/**
* Version number identifying the current set of channels. This must be incremented whenever
- * any channels are added or removed from the set of channels created in
- * {@link ChannelsInitializer#initializeStartupChannels()}.
+ * the set of channels returned by {@link #getStartupChannelIds()} or
+ * {@link #getLegacyChannelIds()} changes.
*/
static final int CHANNELS_VERSION = 0;
- // To define a new channel, add the channel ID to this StringDef and add a new entry to
- // PredefinedChannels.MAP below with the appropriate channel parameters.
+ /**
+ * To define a new channel, add the channel ID to this StringDef and add a new entry to
+ * PredefinedChannels.MAP below with the appropriate channel parameters.
+ * To remove an existing channel, remove the ID from this StringDef, remove its entry from
+ * Predefined Channels.MAP, and add the ID to the LEGACY_CHANNELS_ID array below.
+ */
@StringDef({CHANNEL_ID_BROWSER, CHANNEL_ID_DOWNLOADS, CHANNEL_ID_INCOGNITO, CHANNEL_ID_MEDIA,
CHANNEL_ID_SITES})
@Retention(RetentionPolicy.SOURCE)
@@ -55,6 +59,7 @@ public class ChannelDefinitions {
/**
* The set of predefined channels to be initialized on startup. CHANNELS_VERSION must be
* incremented every time an entry is modified, removed or added to this map.
+ * If an entry is removed from here then it must be added to the LEGACY_CHANNEL_IDs array.
*/
static final Map<String, Channel> MAP;
static {
@@ -83,6 +88,13 @@ public class ChannelDefinitions {
}
}
+ /**
+ * When channels become deprecated they should be removed from PredefinedChannels and their ids
+ * added to this array so they can be deleted on upgrade.
+ * We also want to keep track of old channel ids so they aren't accidentally reused.
+ */
+ private static final String[] LEGACY_CHANNEL_IDS = {};
+
// Map defined in static inner class so it's only initialized lazily.
private static class PredefinedChannelGroups {
static final Map<String, ChannelGroup> MAP;
@@ -95,11 +107,22 @@ public class ChannelDefinitions {
}
}
+ /**
+ * @return A set of channel ids of channels that should be initialized on startup.
+ */
Set<String> getStartupChannelIds() {
// CHANNELS_VERSION must be incremented if the set of channels returned here changes.
return PredefinedChannels.MAP.keySet();
}
+ /**
+ * @return An array of old ChannelIds that may have been returned by
+ * {@link #getStartupChannelIds} in the past, but are no longer in use.
+ */
+ public String[] getLegacyChannelIds() {
+ return LEGACY_CHANNEL_IDS;
+ }
+
ChannelGroup getChannelGroupFromId(Channel channel) {
return PredefinedChannelGroups.MAP.get(channel.mGroupId);
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698