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

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

Issue 895283003: Start moving ownership of SyncNotificationController to SyncController, take 2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/sync/SyncController.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/GoogleServicesNotificationController.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/GoogleServicesNotificationController.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/GoogleServicesNotificationController.java
index 95ac152183bdbe5931c02f36bc5bc8aa8c70ef32..a5f36c74e3ec196b783bee727e917bda16d8eaf1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/GoogleServicesNotificationController.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/GoogleServicesNotificationController.java
@@ -10,7 +10,6 @@ import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
-import android.util.Log;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
@@ -27,28 +26,31 @@ public class GoogleServicesNotificationController {
private static final Object LOCK = new Object();
private static GoogleServicesNotificationController sInstance;
- private static NotificationManagerProxy sNotificationManagerProxyOverride;
private final Context mApplicationContext;
- private final NotificationManagerProxy mNotificationManager;
+ private NotificationManagerProxy mNotificationManager;
- @VisibleForTesting
- public static void overrideNotificationManagerForTests(NotificationManagerProxy managerProxy) {
- sNotificationManagerProxyOverride = managerProxy;
- }
-
- public static GoogleServicesNotificationController createNewInstance(Context context) {
+ /**
+ * Retrieve the singleton instance of this class.
+ *
+ * @param context the current context.
+ * @return the singleton instance.
+ */
+ public static GoogleServicesNotificationController get(Context context) {
synchronized (LOCK) {
if (sInstance == null) {
sInstance = new GoogleServicesNotificationController(context);
- } else {
- Log.e(TAG, "GoogleServicesNotificationController already created. "
- + "Currently on thread: " + Thread.currentThread());
}
return sInstance;
}
}
+ @Deprecated
+ public static GoogleServicesNotificationController createNewInstance(Context context) {
+ return get(context);
+ }
+
+ @Deprecated
@VisibleForTesting
public static GoogleServicesNotificationController getInstance() {
synchronized (LOCK) {
@@ -63,13 +65,9 @@ public class GoogleServicesNotificationController {
private GoogleServicesNotificationController(Context context) {
mApplicationContext = context.getApplicationContext();
- if (sNotificationManagerProxyOverride == null) {
- mNotificationManager = new NotificationManagerProxyImpl(
- (NotificationManager) mApplicationContext.getSystemService(
- Context.NOTIFICATION_SERVICE));
- } else {
- mNotificationManager = sNotificationManagerProxyOverride;
- }
+ mNotificationManager = new NotificationManagerProxyImpl(
+ (NotificationManager) mApplicationContext.getSystemService(
+ Context.NOTIFICATION_SERVICE));
}
public void updateSingleNotification(int id, String message, Intent intent) {
@@ -107,4 +105,9 @@ public class GoogleServicesNotificationController {
public void cancelNotification(int id) {
mNotificationManager.cancel(id);
}
+
+ @VisibleForTesting
+ public void overrideNotificationManagerForTests(NotificationManagerProxy managerProxy) {
+ mNotificationManager = managerProxy;
+ }
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/sync/SyncController.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698