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

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

Issue 2800833003: Revert of Android: Remove GetApplicationContext part 2 (Closed)
Patch Set: 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
Index: chrome/android/java/src/org/chromium/chrome/browser/BackgroundSyncLauncher.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/BackgroundSyncLauncher.java b/chrome/android/java/src/org/chromium/chrome/browser/BackgroundSyncLauncher.java
index dc6d9508b4bac5f25ddad3b5537adc7e73b9b463..4bbbb4cdf1ec392afee4fa90a27ea82ddd26765b 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/BackgroundSyncLauncher.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/BackgroundSyncLauncher.java
@@ -55,15 +55,16 @@
/**
* Create a BackgroundSyncLauncher object, which is owned by C++.
- */
- @VisibleForTesting
- @CalledByNative
- protected static BackgroundSyncLauncher create() {
+ * @param context The app context.
+ */
+ @VisibleForTesting
+ @CalledByNative
+ protected static BackgroundSyncLauncher create(Context context) {
if (sInstance != null) {
throw new IllegalStateException("Already instantiated");
}
- sInstance = new BackgroundSyncLauncher();
+ sInstance = new BackgroundSyncLauncher(context);
return sInstance;
}
@@ -158,14 +159,14 @@
return sInstance != null;
}
- protected BackgroundSyncLauncher() {
- mScheduler = GcmNetworkManager.getInstance(ContextUtils.getApplicationContext());
+ protected BackgroundSyncLauncher(Context context) {
+ mScheduler = GcmNetworkManager.getInstance(context);
launchBrowserIfStopped(false, 0);
}
- private static boolean canUseGooglePlayServices() {
+ private static boolean canUseGooglePlayServices(Context context) {
return ExternalAuthUtils.getInstance().canUseGooglePlayServices(
- ContextUtils.getApplicationContext(), new UserRecoverableErrorHandler.Silent());
+ context, new UserRecoverableErrorHandler.Silent());
}
/**
@@ -174,15 +175,16 @@
* which fail cannot be reregistered. Better to wait until Play Services is updated before
* attempting them.
*
- */
- @CalledByNative
- private static boolean shouldDisableBackgroundSync() {
+ * @param context The application context.
+ */
+ @CalledByNative
+ private static boolean shouldDisableBackgroundSync(Context context) {
// Check to see if Play Services is up to date, and disable GCM if not.
// This will not automatically set {@link sGCMEnabled} to true, in case it has been
// disabled in tests.
if (sGCMEnabled) {
boolean isAvailable = true;
- if (!canUseGooglePlayServices()) {
+ if (!canUseGooglePlayServices(context)) {
setGCMEnabled(false);
Log.i(TAG, "Disabling Background Sync because Play Services is not up to date.");
isAvailable = false;

Powered by Google App Engine
This is Rietveld 408576698