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

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

Issue 895373002: Revert of Start moving ownership of SyncNotificationController to SyncController. (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 297953ff187599e7751df8d0002a09736433c858..95ac152183bdbe5931c02f36bc5bc8aa8c70ef32 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,6 +10,7 @@
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;
@@ -26,31 +27,29 @@
private static final Object LOCK = new Object();
private static GoogleServicesNotificationController sInstance;
+ private static NotificationManagerProxy sNotificationManagerProxyOverride;
private final Context mApplicationContext;
- private NotificationManagerProxy mNotificationManager;
+ private final NotificationManagerProxy mNotificationManager;
- /**
- * Retrieve the singleton instance of this class.
- *
- * @param context the current context.
- * @return the singleton instance.
- */
- public static GoogleServicesNotificationController get(Context context) {
+ @VisibleForTesting
+ public static void overrideNotificationManagerForTests(NotificationManagerProxy managerProxy) {
+ sNotificationManagerProxyOverride = managerProxy;
+ }
+
+ public static GoogleServicesNotificationController createNewInstance(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) {
return sInstance;
@@ -64,9 +63,13 @@
private GoogleServicesNotificationController(Context context) {
mApplicationContext = context.getApplicationContext();
- mNotificationManager = new NotificationManagerProxyImpl(
- (NotificationManager) mApplicationContext.getSystemService(
- Context.NOTIFICATION_SERVICE));
+ if (sNotificationManagerProxyOverride == null) {
+ mNotificationManager = new NotificationManagerProxyImpl(
+ (NotificationManager) mApplicationContext.getSystemService(
+ Context.NOTIFICATION_SERVICE));
+ } else {
+ mNotificationManager = sNotificationManagerProxyOverride;
+ }
}
public void updateSingleNotification(int id, String message, Intent intent) {
@@ -104,9 +107,4 @@
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