summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTommy Nyquist <nyquist@chromium.org>2015-09-01 15:02:45 -0700
committerTommy Nyquist <nyquist@chromium.org>2015-09-01 22:03:40 +0000
commitff5fb8a723d287259c3f22a0439e01a51f287659 (patch)
treee788318710b1fd4cbf06c4aaf491baf4ee536165
parentea282f4f59ada506fdbfabf9c8efe1f09dab5b1c (diff)
downloadchromium_src-ff5fb8a723d287259c3f22a0439e01a51f287659.zip
chromium_src-ff5fb8a723d287259c3f22a0439e01a51f287659.tar.gz
chromium_src-ff5fb8a723d287259c3f22a0439e01a51f287659.tar.bz2
[Part 2] CacheInvalidation Library Update to use GCM in GMSCore.
The change adds: 1) ChromeGcmListenerService to receive GCM messages sent to the application. 2) InvalidationGcmUpstreamSender to send upstream messages for invalidations using GCM and record UMA stats. 3) Updates the manifest to include the services and changes the channel initialization call. The call has been moved to InvalidationController since it registers the application with GCM for invalidations only. The other user of GCM is Web Push which currently uses GoogleCloudMessagingV2 for registration. Part 1: https://codereview.chromium.org/1300923002/ BUG=397327, 477059 Review URL: https://codereview.chromium.org/1289203006 Cr-Commit-Position: refs/heads/master@{#345975} (cherry picked from commit 8148b0974c04fd08e1a1eba73b441fb5329ea25c) R=khushalsagar@chromium.org Review URL: https://codereview.chromium.org/1324923002 . Cr-Commit-Position: refs/branch-heads/2490@{#119} Cr-Branched-From: 7790a3535f2a81a03685eca31a32cf69ae0c114f-refs/heads/master@{#344925}
-rw-r--r--chrome/android/java/AndroidManifest.xml54
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/gsa/GSAServiceClient.java2
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/invalidation/InvalidationController.java46
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/services/gcm/ChromeGcmListenerService.java65
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/services/gcm/GcmUpstreamUma.java48
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/services/gcm/InvalidationGcmUpstreamSender.java86
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/sync/SyncController.java2
-rw-r--r--chrome/android/junit/src/org/chromium/chrome/browser/invalidations/InvalidationControllerTest.java30
-rw-r--r--chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java11
-rw-r--r--sync/android/java/src/org/chromium/sync/signin/ChromeSigninController.java36
10 files changed, 290 insertions, 90 deletions
diff --git a/chrome/android/java/AndroidManifest.xml b/chrome/android/java/AndroidManifest.xml
index 9cc950c..fef1009 100644
--- a/chrome/android/java/AndroidManifest.xml
+++ b/chrome/android/java/AndroidManifest.xml
@@ -484,9 +484,9 @@ by a child template that "extends" this file.
android:exported="false" />
<receiver android:name="org.chromium.chrome.browser.bookmarkswidget.BookmarkWidgetProxy"
android:exported="false" />
-
- <!-- Receiver for GCM messages. Rebroadcasts them locally for sync and cloudprint. -->
- <receiver android:name="com.google.ipc.invalidation.external.client.contrib.MultiplexingGcmListener$GCMReceiver"
+
+ <!-- Receiver for GCM messages. -->
+ <receiver android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
@@ -495,11 +495,32 @@ by a child template that "extends" this file.
<category android:name="{{ manifest_package }}"/>
</intent-filter>
</receiver>
- <service android:name="com.google.ipc.invalidation.external.client.contrib.MultiplexingGcmListener"
+ <!-- GcmTaskService for registration for Invalidations. -->
+ <service android:name="com.google.ipc.invalidation.ticl.android2.channel.GcmRegistrationTaskService"
+ android:exported="true"
+ android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE" >
+ <intent-filter>
+ <action android:name="com.google.android.gms.gcm.ACTION_TASK_READY"/>
+ </intent-filter>
+ </service>
+ <!-- InstanceIDListenerService for token refresh events from GCM. -->
+ <service android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidInstanceIDListenerService"
android:exported="false">
- <meta-data android:name="sender_ids"
- android:value="cloudprint.c2dm@gmail.com,ipc.invalidation@gmail.com"/>
+ <intent-filter>
+ <action android:name="com.google.android.gms.iid.InstanceID"/>
+ </intent-filter>
+ </service>
+ <!-- GcmListenerService for messages from GCM. -->
+ <service android:name="org.chromium.chrome.browser.services.gcm.ChromeGcmListenerService"
+ android:exported="false" >
+ <intent-filter>
+ <action android:name="com.google.android.c2dm.intent.RECEIVE" />
+ </intent-filter>
</service>
+ <meta-data android:name="ipc.invalidation.ticl.gcm_upstream_service_class"
+ android:value="org.chromium.chrome.browser.services.gcm.InvalidationGcmUpstreamSender" />
+ <service android:name="org.chromium.chrome.browser.services.gcm.InvalidationGcmUpstreamSender"
+ android:exported="false"/>
<!-- Notification service for sync. -->
<meta-data android:name="ipc.invalidation.ticl.listener_service_class"
@@ -519,27 +540,6 @@ by a child template that "extends" this file.
<receiver android:name="com.google.ipc.invalidation.external.client2.contrib.AndroidListener$AlarmReceiver"
android:exported="false"/>
- <!-- Notification service multiplexed GCM receiver -->
- <service android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidMessageReceiverService"
- android:exported="false"
- android:enabled="true"/>
- <receiver android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidMessageReceiverService$Receiver"
- android:exported="false">
- <intent-filter>
- <action android:name="com.google.ipc.invalidation.gcmmplex.EVENT" />
- </intent-filter>
- </receiver>
-
- <!-- GCMDriver multiplexed GCM receiver -->
- <service android:name="org.chromium.chrome.browser.services.gcm.GCMListener"
- android:exported="false"/>
- <receiver android:name="org.chromium.chrome.browser.services.gcm.GCMListener$Receiver"
- android:exported="false">
- <intent-filter>
- <action android:name="com.google.ipc.invalidation.gcmmplex.EVENT" />
- </intent-filter>
- </receiver>
-
<!-- Android Notification service listener -->
<service android:name="org.chromium.chrome.browser.notifications.NotificationService"
android:exported="false"/>
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/gsa/GSAServiceClient.java b/chrome/android/java/src/org/chromium/chrome/browser/gsa/GSAServiceClient.java
index 23e0837..25696a2 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/gsa/GSAServiceClient.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/gsa/GSAServiceClient.java
@@ -16,6 +16,7 @@ import android.os.Messenger;
import android.os.RemoteException;
import android.util.Log;
+import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.chrome.browser.ChromeApplication;
/**
@@ -50,6 +51,7 @@ public class GSAServiceClient {
/**
* Handler of incoming messages from service.
*/
+ @SuppressFBWarnings("BC_IMPOSSIBLE_CAST")
private class IncomingHandler extends Handler {
@Override
public void handleMessage(Message msg) {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/invalidation/InvalidationController.java b/chrome/android/java/src/org/chromium/chrome/browser/invalidation/InvalidationController.java
index 3575e43..a280a8f 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/invalidation/InvalidationController.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/invalidation/InvalidationController.java
@@ -6,9 +6,12 @@ package org.chromium.chrome.browser.invalidation;
import android.content.Context;
import android.content.Intent;
+import android.os.AsyncTask;
import android.os.Handler;
import android.os.SystemClock;
+import com.google.ipc.invalidation.ticl.android2.channel.AndroidGcmController;
+
import org.chromium.base.ApplicationState;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.FieldTrialList;
@@ -151,11 +154,25 @@ public class InvalidationController implements ApplicationStatus.ApplicationStat
private int mNumRecentTabPages;
/**
+ * Whether GCM Upstream should be used for sending upstream messages.
+ */
+ private boolean mUseGcmUpstream;
+
+ /**
+ * Whether GCM has been initialized for Invalidations.
+ */
+ private boolean mGcmInitialized;
+
+ /**
* Updates the sync invalidation types that the client is registered for based on the preferred
* sync types. Starts the client if needed.
*/
public void ensureStartedAndUpdateRegisteredTypes() {
mStarted = true;
+
+ // Ensure GCM has been initialized.
+ ensureGcmIsInitialized();
+
// Do not apply changes to {@link #mSessionInvalidationsEnabled} yet because the timer task
// may be scheduled far into the future.
mEnableSessionInvalidationsTimer.resume();
@@ -176,6 +193,26 @@ public class InvalidationController implements ApplicationStatus.ApplicationStat
}
/**
+ * Registers for Google Cloud Messaging (GCM) for Invalidations.
+ */
+ private void ensureGcmIsInitialized() {
+ if (mGcmInitialized) return;
+ mGcmInitialized = true;
+ new AsyncTask<Void, Void, Void>() {
+ @Override
+ protected Void doInBackground(Void... arg0) {
+ AndroidGcmController.get(mContext).initializeGcm(mUseGcmUpstream);
+ return null;
+ }
+ }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ }
+
+ @VisibleForTesting
+ public boolean isGcmInitialized() {
+ return mGcmInitialized;
+ }
+
+ /**
* Starts the invalidation client without updating the registered invalidation types.
*/
private void start() {
@@ -232,7 +269,10 @@ public class InvalidationController implements ApplicationStatus.ApplicationStat
boolean canDisableSessionInvalidations =
FieldTrialList.findFullName("AndroidSessionNotifications")
.equals("Disabled");
- sInstance = new InvalidationController(context, canDisableSessionInvalidations);
+ boolean canUseGcmUpstream =
+ FieldTrialList.findFullName("InvalidationsGCMUpstream").equals("Enabled");
+ sInstance = new InvalidationController(
+ context, canDisableSessionInvalidations, canUseGcmUpstream);
}
return sInstance;
}
@@ -264,10 +304,12 @@ public class InvalidationController implements ApplicationStatus.ApplicationStat
* Creates an instance using {@code context} to send intents.
*/
@VisibleForTesting
- InvalidationController(Context context, boolean canDisableSessionInvalidations) {
+ InvalidationController(
+ Context context, boolean canDisableSessionInvalidations, boolean canUseGcmUpstream) {
Context appContext = context.getApplicationContext();
if (appContext == null) throw new NullPointerException("Unable to get application context");
mContext = appContext;
+ mUseGcmUpstream = canUseGcmUpstream;
mCanDisableSessionInvalidations = canDisableSessionInvalidations;
mSessionInvalidationsEnabled = !mCanDisableSessionInvalidations;
mEnableSessionInvalidationsTimer = new Timer();
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/services/gcm/ChromeGcmListenerService.java b/chrome/android/java/src/org/chromium/chrome/browser/services/gcm/ChromeGcmListenerService.java
new file mode 100644
index 0000000..26a4b62
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/services/gcm/ChromeGcmListenerService.java
@@ -0,0 +1,65 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.services.gcm;
+
+import android.os.Bundle;
+import android.util.Log;
+
+import com.google.android.gms.gcm.GcmListenerService;
+import com.google.ipc.invalidation.ticl.android2.channel.AndroidGcmController;
+
+import org.chromium.base.ThreadUtils;
+import org.chromium.components.gcm_driver.GCMDriver;
+
+/**
+ * Receives Downstream messages and status of upstream messages from GCM.
+ */
+public class ChromeGcmListenerService extends GcmListenerService {
+ private static final String TAG = "ChromeGcmListener";
+
+ @Override
+ public void onMessageReceived(String from, Bundle data) {
+ String invalidationSenderId = AndroidGcmController.get(this).getSenderId();
+ if (from.equals(invalidationSenderId)) {
+ AndroidGcmController.get(this).onMessageReceived(data);
+ return;
+ }
+ pushMessageReceived(data);
+ }
+
+ @Override
+ public void onMessageSent(String msgId) {
+ Log.d(TAG, "Message sent successfully. Message id: " + msgId);
+ GcmUpstreamUma.recordHistogram(getApplicationContext(), GcmUpstreamUma.UMA_SUCCESS);
+ }
+
+ @Override
+ public void onSendError(String msgId, String error) {
+ Log.w(TAG, "Error in sending message. Message id: " + msgId + " Error: " + error);
+ GcmUpstreamUma.recordHistogram(getApplicationContext(), GcmUpstreamUma.UMA_SEND_FAILED);
+ }
+
+ @Override
+ public void onDeletedMessages() {
+ // TODO(johnme): Ask GCM to include the subtype in this event.
+ Log.w(TAG, "Push messages were deleted, but we can't tell the Service Worker as we don't"
+ + "know what subtype (app ID) it occurred for.");
+ }
+
+ private void pushMessageReceived(final Bundle data) {
+ final String bundleSubtype = "subtype";
+ if (!data.containsKey(bundleSubtype)) {
+ Log.w(TAG, "Received push message with no subtype");
+ return;
+ }
+ final String appId = data.getString(bundleSubtype);
+ ThreadUtils.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ GCMDriver.onMessageReceived(getApplicationContext(), appId, data);
+ }
+ });
+ }
+}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/services/gcm/GcmUpstreamUma.java b/chrome/android/java/src/org/chromium/chrome/browser/services/gcm/GcmUpstreamUma.java
new file mode 100644
index 0000000..6dd1579
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/services/gcm/GcmUpstreamUma.java
@@ -0,0 +1,48 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.services.gcm;
+
+import android.content.Context;
+
+import org.chromium.base.ThreadUtils;
+import org.chromium.base.library_loader.LibraryProcessType;
+import org.chromium.base.metrics.RecordHistogram;
+import org.chromium.content.browser.BrowserStartupController;
+import org.chromium.content.browser.BrowserStartupController.StartupCallback;
+
+/**
+ * Helper Class for Invalidations GCM Upstream UMA Collection.
+ */
+public class GcmUpstreamUma {
+ // Values for the "Invalidations.GCMUpstreamRequest" UMA histogram. The list is append-only.
+ public static final int UMA_SUCCESS = 0;
+ public static final int UMA_SIZE_LIMIT_EXCEEDED = 1;
+ public static final int UMA_TOKEN_REQUEST_FAILED = 2;
+ public static final int UMA_SEND_FAILED = 3;
+ public static final int UMA_MAX = 4;
+
+ public static void recordHistogram(final Context context, final int value) {
+ ThreadUtils.postOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ BrowserStartupController.get(context, LibraryProcessType.PROCESS_BROWSER)
+ .addStartupCompletedObserver(
+ new StartupCallback() {
+ @Override
+ public void onSuccess(boolean alreadyStarted) {
+ RecordHistogram.recordEnumeratedHistogram(
+ "Invalidations.GCMUpstreamRequest", value, UMA_MAX);
+ }
+
+ @Override
+ public void onFailure() {
+ // Startup failed.
+ }
+ });
+ }
+ });
+ }
+}
+
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/services/gcm/InvalidationGcmUpstreamSender.java b/chrome/android/java/src/org/chromium/chrome/browser/services/gcm/InvalidationGcmUpstreamSender.java
new file mode 100644
index 0000000..46e07f9
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/services/gcm/InvalidationGcmUpstreamSender.java
@@ -0,0 +1,86 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.services.gcm;
+
+import android.accounts.Account;
+import android.os.Bundle;
+import android.util.Log;
+
+import com.google.android.gms.gcm.GoogleCloudMessaging;
+import com.google.ipc.invalidation.ticl.android2.channel.GcmUpstreamSenderService;
+
+import org.chromium.chrome.browser.signin.OAuth2TokenService;
+import org.chromium.sync.SyncConstants;
+import org.chromium.sync.signin.AccountManagerHelper;
+import org.chromium.sync.signin.ChromeSigninController;
+
+import java.io.IOException;
+import java.util.UUID;
+
+import javax.annotation.Nullable;
+
+/**
+ * Sends Upstream messages for Invalidations using GCM.
+ */
+public class InvalidationGcmUpstreamSender extends GcmUpstreamSenderService {
+ private static final String TAG = "InvalidationGcmUpstream";
+
+ // GCM Payload Limit in bytes.
+ private static final int GCM_PAYLOAD_LIMIT = 4000;
+
+ @Override
+ public void deliverMessage(final String to, final Bundle data) {
+ @Nullable
+ Account account = ChromeSigninController.get(this).getSignedInUser();
+ if (account == null) {
+ // This should never happen, because this code should only be run if a user is
+ // signed-in.
+ Log.w(TAG, "No signed-in user; cannot send message to data center");
+ return;
+ }
+
+ // Attempt to retrieve a token for the user.
+ OAuth2TokenService.getOAuth2AccessToken(this, null, account,
+ SyncConstants.CHROME_SYNC_OAUTH2_SCOPE,
+ new AccountManagerHelper.GetAuthTokenCallback() {
+ @Override
+ public void tokenAvailable(String token) {
+ sendUpstreamMessage(to, data, token);
+ }
+ });
+ }
+
+ private void sendUpstreamMessage(String to, Bundle data, String token) {
+ if (token == null) {
+ GcmUpstreamUma.recordHistogram(
+ getApplicationContext(), GcmUpstreamUma.UMA_TOKEN_REQUEST_FAILED);
+ }
+ // Add the OAuth2 token to the bundle. The token should have the prefix Bearer added to it.
+ data.putString("Authorization", "Bearer " + token);
+ if (!isMessageWithinLimit(data)) {
+ GcmUpstreamUma.recordHistogram(
+ getApplicationContext(), GcmUpstreamUma.UMA_SIZE_LIMIT_EXCEEDED);
+ return;
+ }
+ String msgId = UUID.randomUUID().toString();
+ try {
+ GoogleCloudMessaging.getInstance(getApplicationContext()).send(to, msgId, 1, data);
+ } catch (IOException | IllegalArgumentException exception) {
+ Log.w(TAG, "Send message failed");
+ GcmUpstreamUma.recordHistogram(getApplicationContext(), GcmUpstreamUma.UMA_SEND_FAILED);
+ }
+ }
+
+ private boolean isMessageWithinLimit(Bundle data) {
+ int size = 0;
+ for (String key : data.keySet()) {
+ size += key.length() + data.getString(key).length();
+ }
+ if (size > GCM_PAYLOAD_LIMIT) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/sync/SyncController.java b/chrome/android/java/src/org/chromium/chrome/browser/sync/SyncController.java
index ee14726..e5e3836 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/sync/SyncController.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/sync/SyncController.java
@@ -62,8 +62,6 @@ public class SyncController implements ProfileSyncService.SyncStateChangedListen
mProfileSyncService = ProfileSyncService.get(mContext);
mProfileSyncService.addSyncStateChangedListener(this);
- mChromeSigninController.ensureGcmIsInitialized();
-
// Set the sessions ID using the generator that was registered for GENERATOR_ID.
mProfileSyncService.setSessionsId(
UniqueIdentificationGeneratorFactory.getInstance(GENERATOR_ID));
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/invalidations/InvalidationControllerTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/invalidations/InvalidationControllerTest.java
index 75d323f..e3a169a 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/invalidations/InvalidationControllerTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/invalidations/InvalidationControllerTest.java
@@ -121,7 +121,7 @@ public class InvalidationControllerTest {
@Test
@Feature({"Sync"})
public void testStop() throws Exception {
- InvalidationController controller = new InvalidationController(mContext, true);
+ InvalidationController controller = new InvalidationController(mContext, true, false);
controller.stop();
Intent intent = getOnlyIntent();
validateIntentComponent(intent);
@@ -136,10 +136,13 @@ public class InvalidationControllerTest {
@Test
@Feature({"Sync"})
public void testEnsureStartedAndUpdateRegisteredTypes() {
- InvalidationController controller = new InvalidationController(mContext, false);
+ InvalidationController controller = new InvalidationController(mContext, false, false);
controller.ensureStartedAndUpdateRegisteredTypes();
Intent intent = getOnlyIntent();
+ // Ensure GCM is initialized. This is a regression test for http://crbug.com/475299.
+ Assert.assertTrue(controller.isGcmInitialized());
+
// Validate destination.
validateIntentComponent(intent);
Assert.assertEquals(InvalidationIntentProtocol.ACTION_REGISTER, intent.getAction());
@@ -163,7 +166,7 @@ public class InvalidationControllerTest {
public void testPauseAndResumeMainActivityWithSyncDisabled() throws Exception {
AndroidSyncSettings.disableChromeSync(mContext);
- InvalidationController controller = new InvalidationController(mContext, false);
+ InvalidationController controller = new InvalidationController(mContext, false, false);
controller.onApplicationStateChange(ApplicationState.HAS_PAUSED_ACTIVITIES);
controller.onApplicationStateChange(ApplicationState.HAS_RUNNING_ACTIVITIES);
assertNoNewIntents();
@@ -178,7 +181,7 @@ public class InvalidationControllerTest {
final AtomicBoolean listenerCallbackCalled = new AtomicBoolean();
// Create instance.
- new InvalidationController(mContext, true) {
+ new InvalidationController(mContext, true, false) {
@Override
public void onApplicationStateChange(int newState) {
listenerCallbackCalled.set(true);
@@ -200,7 +203,7 @@ public class InvalidationControllerTest {
@Test
@Feature({"Sync"})
public void testCannotToggleSessionInvalidations() {
- InvalidationController controller = new InvalidationController(mContext, false);
+ InvalidationController controller = new InvalidationController(mContext, false, false);
controller.ensureStartedAndUpdateRegisteredTypes();
Assert.assertEquals(mAllTypes, getRegisterIntentRegisterTypes(getOnlyIntent()));
@@ -224,7 +227,7 @@ public class InvalidationControllerTest {
@Test
@Feature({"Sync"})
public void testRecentTabsPageShown() {
- InvalidationController controller = new InvalidationController(mContext, true);
+ InvalidationController controller = new InvalidationController(mContext, true, false);
controller.ensureStartedAndUpdateRegisteredTypes();
Assert.assertEquals(mNonSessionTypes, getRegisterIntentRegisterTypes(getOnlyIntent()));
@@ -245,7 +248,7 @@ public class InvalidationControllerTest {
@Test
@Feature({"Sync"})
public void testStartWhileRecentTabsPageShown() {
- InvalidationController controller = new InvalidationController(mContext, true);
+ InvalidationController controller = new InvalidationController(mContext, true, false);
controller.onRecentTabsPageOpened();
Robolectric.runUiThreadTasksIncludingDelayedTasks();
assertNoNewIntents();
@@ -266,7 +269,7 @@ public class InvalidationControllerTest {
@Test
@Feature({"Sync"})
public void testMultipleRecentTabsPages() {
- InvalidationController controller = new InvalidationController(mContext, true);
+ InvalidationController controller = new InvalidationController(mContext, true, false);
controller.ensureStartedAndUpdateRegisteredTypes();
Assert.assertEquals(mNonSessionTypes, getRegisterIntentRegisterTypes(getOnlyIntent()));
@@ -293,7 +296,7 @@ public class InvalidationControllerTest {
@Test
@Feature({"Sync"})
public void testOpenCloseRecentTabsPageQuickly() {
- InvalidationController controller = new InvalidationController(mContext, true);
+ InvalidationController controller = new InvalidationController(mContext, true, false);
controller.ensureStartedAndUpdateRegisteredTypes();
Assert.assertEquals(mNonSessionTypes, getRegisterIntentRegisterTypes(getOnlyIntent()));
@@ -323,7 +326,7 @@ public class InvalidationControllerTest {
@Test
@Feature({"Sync"})
public void testDisableSessionInvalidationsOnStart() {
- InvalidationController controller = new InvalidationController(mContext, true);
+ InvalidationController controller = new InvalidationController(mContext, true, false);
controller.ensureStartedAndUpdateRegisteredTypes();
Assert.assertEquals(mNonSessionTypes, getRegisterIntentRegisterTypes(getOnlyIntent()));
controller.onRecentTabsPageOpened();
@@ -349,7 +352,7 @@ public class InvalidationControllerTest {
@Test
@Feature({"Sync"})
public void testDisableSessionInvalidationsOnResume() {
- InvalidationController controller = new InvalidationController(mContext, true);
+ InvalidationController controller = new InvalidationController(mContext, true, false);
controller.ensureStartedAndUpdateRegisteredTypes();
Assert.assertEquals(mNonSessionTypes, getRegisterIntentRegisterTypes(getOnlyIntent()));
controller.onRecentTabsPageOpened();
@@ -374,7 +377,7 @@ public class InvalidationControllerTest {
@Test
@Feature({"Sync"})
public void testPauseAndResumeMainActivity() throws Exception {
- InvalidationController controller = new InvalidationController(mContext, true);
+ InvalidationController controller = new InvalidationController(mContext, true, false);
controller.ensureStartedAndUpdateRegisteredTypes();
Assert.assertEquals(mNonSessionTypes, getRegisterIntentRegisterTypes(getOnlyIntent()));
controller.onRecentTabsPageOpened();
@@ -398,7 +401,7 @@ public class InvalidationControllerTest {
@Test
@Feature({"Sync"})
public void testPauseAndResumeMainActivityAfterStop() throws Exception {
- InvalidationController controller = new InvalidationController(mContext, true);
+ InvalidationController controller = new InvalidationController(mContext, true, false);
controller.ensureStartedAndUpdateRegisteredTypes();
Assert.assertEquals(mNonSessionTypes, getRegisterIntentRegisterTypes(getOnlyIntent()));
@@ -460,4 +463,5 @@ public class InvalidationControllerTest {
intent.getStringArrayListExtra(InvalidationIntentProtocol.EXTRA_REGISTERED_TYPES));
return registeredTypes;
}
+
}
diff --git a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java
index fcf500f..c6732cb 100644
--- a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java
+++ b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java
@@ -20,7 +20,6 @@ import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.browser.test.util.JavaScriptUtils;
import org.chromium.sync.AndroidSyncSettings;
import org.chromium.sync.signin.AccountManagerHelper;
-import org.chromium.sync.signin.ChromeSigninController;
import java.util.concurrent.TimeoutException;
@@ -30,16 +29,6 @@ import java.util.concurrent.TimeoutException;
public class SyncTest extends SyncTestBase {
private static final String TAG = "SyncTest";
- /**
- * This is a regression test for http://crbug.com/475299.
- */
- @LargeTest
- @Feature({"Sync"})
- public void testGcmInitialized() throws Throwable {
- setupTestAccountAndSignInToSync(CLIENT_ID);
- assertTrue(ChromeSigninController.get(mContext).isGcmInitialized());
- }
-
@LargeTest
@Feature({"Sync"})
public void testGetAboutSyncInfoYieldsValidData() throws Throwable {
diff --git a/sync/android/java/src/org/chromium/sync/signin/ChromeSigninController.java b/sync/android/java/src/org/chromium/sync/signin/ChromeSigninController.java
index 4a5e8e8..cd86532 100644
--- a/sync/android/java/src/org/chromium/sync/signin/ChromeSigninController.java
+++ b/sync/android/java/src/org/chromium/sync/signin/ChromeSigninController.java
@@ -6,12 +6,9 @@ package org.chromium.sync.signin;
import android.accounts.Account;
import android.content.Context;
-import android.os.AsyncTask;
import android.preference.PreferenceManager;
import android.util.Log;
-import com.google.ipc.invalidation.external.client.contrib.MultiplexingGcmListener;
-
import org.chromium.base.ObserverList;
import org.chromium.base.VisibleForTesting;
import org.chromium.sync.AndroidSyncSettings;
@@ -44,8 +41,6 @@ public class ChromeSigninController {
private final ObserverList<Listener> mListeners = new ObserverList<Listener>();
- private boolean mGcmInitialized;
-
private ChromeSigninController(Context context) {
mApplicationContext = context.getApplicationContext();
AndroidSyncSettings.updateAccount(context, getSignedInUser());
@@ -115,33 +110,4 @@ public class ChromeSigninController {
public void removeListener(Listener listener) {
mListeners.removeObserver(listener);
}
-
- /**
- * Registers for Google Cloud Messaging (GCM) if there is no existing registration.
- */
- public void ensureGcmIsInitialized() {
- if (mGcmInitialized) return;
- mGcmInitialized = true;
- new AsyncTask<Void, Void, Void>() {
- @Override
- protected Void doInBackground(Void... arg0) {
- try {
- String regId = MultiplexingGcmListener.initializeGcm(mApplicationContext);
- if (!regId.isEmpty()) Log.d(TAG, "Already registered with GCM");
- } catch (IllegalStateException exception) {
- Log.w(TAG, "Application manifest does not correctly configure GCM; "
- + "sync notifications will not work", exception);
- } catch (UnsupportedOperationException exception) {
- Log.w(TAG, "Device does not support GCM; sync notifications will not work",
- exception);
- }
- return null;
- }
- }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
-
- @VisibleForTesting
- public boolean isGcmInitialized() {
- return mGcmInitialized;
- }
-}
+} \ No newline at end of file