Commit 2f3b927d authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Signin][Android] Cleanup GoogleServicesManager

Cleans up GoogleServicesManager to simplify upcoming changes to this
class. No behavior change.

Bug: 1107942
Change-Id: I586ec4a9e8edffef6c4f50a39f541c562c9f90fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2310669
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Reviewed-by: default avatarAlice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790782}
parent 9c2ef271
...@@ -44,10 +44,6 @@ public class GoogleServicesManager implements ApplicationStateListener { ...@@ -44,10 +44,6 @@ public class GoogleServicesManager implements ApplicationStateListener {
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
private static GoogleServicesManager sGoogleServicesManager; private static GoogleServicesManager sGoogleServicesManager;
private final ChromeSigninController mChromeSigninController;
private final SigninHelper mSigninHelper;
/** /**
* A helper method for retrieving the application-wide GoogleServicesManager. * A helper method for retrieving the application-wide GoogleServicesManager.
* <p/> * <p/>
...@@ -64,21 +60,17 @@ public class GoogleServicesManager implements ApplicationStateListener { ...@@ -64,21 +60,17 @@ public class GoogleServicesManager implements ApplicationStateListener {
} }
private GoogleServicesManager() { private GoogleServicesManager() {
try { try (TraceEvent ignored =
TraceEvent.begin("GoogleServicesManager.GoogleServicesManager"); TraceEvent.scoped("GoogleServicesManager.GoogleServicesManager")) {
ThreadUtils.assertOnUiThread(); ThreadUtils.assertOnUiThread();
mChromeSigninController = ChromeSigninController.get();
mSigninHelper = SigninHelper.get();
// The sign out flow starts by clearing the signed in user in the ChromeSigninController // The sign out flow starts by clearing the signed in user in the ChromeSigninController
// on the Java side, and then performs a sign out on the native side. If there is a // on the Java side, and then performs a sign out on the native side. If there is a
// crash on the native side then the signin state may get out of sync. Make sure that // crash on the native side then the signin state may get out of sync. Make sure that
// the native side is signed out if the Java side doesn't have a currently signed in // the native side is signed out if the Java side doesn't have a currently signed in
// user. // user.
// TODO(bsazonov): Move this to SigninManager. // TODO(https://crbug.com/1107942): Move this to SigninManager.
SigninManager signinManager = IdentityServicesProvider.get().getSigninManager(); SigninManager signinManager = IdentityServicesProvider.get().getSigninManager();
if (!mChromeSigninController.isSignedIn() if (!ChromeSigninController.get().isSignedIn()
&& signinManager.getIdentityManager().hasPrimaryAccount()) { && signinManager.getIdentityManager().hasPrimaryAccount()) {
Log.w(TAG, "Signed in state got out of sync, forcing native sign out"); Log.w(TAG, "Signed in state got out of sync, forcing native sign out");
// TODO(https://crbug.com/873116): Pass the correct reason for the signout. // TODO(https://crbug.com/873116): Pass the correct reason for the signout.
...@@ -89,8 +81,6 @@ public class GoogleServicesManager implements ApplicationStateListener { ...@@ -89,8 +81,6 @@ public class GoogleServicesManager implements ApplicationStateListener {
SyncController.get(); SyncController.get();
ApplicationStatus.registerApplicationStateListener(this); ApplicationStatus.registerApplicationStateListener(this);
} finally {
TraceEvent.end("GoogleServicesManager.GoogleServicesManager");
} }
} }
...@@ -100,13 +90,10 @@ public class GoogleServicesManager implements ApplicationStateListener { ...@@ -100,13 +90,10 @@ public class GoogleServicesManager implements ApplicationStateListener {
* and updates state accordingly. * and updates state accordingly.
*/ */
public void onMainActivityStart() { public void onMainActivityStart() {
try { try (TraceEvent ignored = TraceEvent.scoped("GoogleServicesManager.onMainActivityStart")) {
TraceEvent.begin("GoogleServicesManager.onMainActivityStart");
boolean accountsChanged = boolean accountsChanged =
SigninPreferencesManager.getInstance().checkAndClearAccountsChangedPref(); SigninPreferencesManager.getInstance().checkAndClearAccountsChangedPref();
mSigninHelper.validateAccountSettings(accountsChanged); SigninHelper.get().validateAccountSettings(accountsChanged);
} finally {
TraceEvent.end("GoogleServicesManager.onMainActivityStart");
} }
} }
......
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