Commit 0d4fcfbc authored by perezju's avatar perezju Committed by Commit bot

Revert of Start moving ownership of SyncNotificationController to...

Revert of Start moving ownership of SyncNotificationController to SyncController. (patchset #3 id:40001 of https://codereview.chromium.org/889723002/)

Reason for revert:
Broke downstream builds

Original issue's description:
> Start moving ownership of SyncNotificationController to SyncController.
>
> GoogleServicesNotificationController is modified to work
> the way most other singleton classes work, so that it is
> not necessary to pass into the SyncNotificationController
> constructor (and thus, into SyncController in the future).
>
> SyncController gets a temporary setter method so that SNC
> can be constructed downstream and passed in until all its
> dependencies are upstream.
>
> BUG=428882
>
> Committed: https://crrev.com/deaa0fe6ca3e0428a85fc22b019819437d84120b
> Cr-Commit-Position: refs/heads/master@{#314515}

TBR=nyquist@chromium.org,maxbogue@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=428882

Review URL: https://codereview.chromium.org/895373002

Cr-Commit-Position: refs/heads/master@{#314537}
parent d5eeecc5
......@@ -10,6 +10,7 @@ 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;
......@@ -26,31 +27,29 @@ public class GoogleServicesNotificationController {
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 @@ public class GoogleServicesNotificationController {
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 class GoogleServicesNotificationController {
public void cancelNotification(int id) {
mNotificationManager.cancel(id);
}
@VisibleForTesting
public void overrideNotificationManagerForTests(NotificationManagerProxy managerProxy) {
mNotificationManager = managerProxy;
}
}
......@@ -42,8 +42,6 @@ public class SyncController implements ProfileSyncService.SyncStateChangedListen
private final ChromeSigninController mChromeSigninController;
private final AndroidSyncSettings mAndroidSyncSettings;
private final ProfileSyncService mProfileSyncService;
// TODO(maxbogue): Make final once it's constructed in this class.
private SyncNotificationController mSyncNotificationController = null;
private SyncController(Context context) {
mContext = context;
......@@ -188,24 +186,4 @@ public class SyncController implements ProfileSyncService.SyncStateChangedListen
}
});
}
/**
* Sets the SyncNotificationController.
*
* This is a temporary method for transferring ownership of SyncNotificationController
* upstream. Once all of SNC's dependencies are upstreamed, it will be created in the
* SyncController constructor and this method won't exist.
*/
public void setSyncNotificationController(SyncNotificationController snc) {
assert mSyncNotificationController == null;
mSyncNotificationController = snc;
mProfileSyncService.addSyncStateChangedListener(mSyncNotificationController);
}
/**
* Returns the SyncNotificationController.
*/
public SyncNotificationController getSyncNotificationController() {
return mSyncNotificationController;
}
}
......@@ -32,21 +32,6 @@ public class SyncNotificationController implements ProfileSyncService.SyncStateC
private final Class<? extends Fragment> mAccountManagementFragment;
private final ProfileSyncService mProfileSyncService;
public SyncNotificationController(Context context,
Class<? extends Activity> passphraseRequestActivity,
Class<? extends Fragment> accountManagementFragment) {
mApplicationContext = context.getApplicationContext();
mNotificationController = GoogleServicesNotificationController.get(context);
mProfileSyncService = ProfileSyncService.get(context);
mAndroidSyncSettings = AndroidSyncSettings.get(context);
mPassphraseRequestActivity = passphraseRequestActivity;
mAccountManagementFragment = accountManagementFragment;
}
/**
* Deprecated for having unnecessary args; use the first constructor.
*/
@Deprecated
public SyncNotificationController(Context context,
GoogleServicesNotificationController controller,
Class<? extends Activity> passphraseRequestActivity,
......
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