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

Unified Diff: sync/android/java/src/org/chromium/sync/notifier/InvalidationService.java

Issue 54923003: Support for shared invalidator client IDs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile issue Created 7 years, 1 month 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: sync/android/java/src/org/chromium/sync/notifier/InvalidationService.java
diff --git a/sync/android/java/src/org/chromium/sync/notifier/InvalidationService.java b/sync/android/java/src/org/chromium/sync/notifier/InvalidationService.java
index ea3e73a9bbcfe63425e8ef89871a3ca21ffbe4e2..cd8b60538397d177c833bed94cd410c9423f0351 100644
--- a/sync/android/java/src/org/chromium/sync/notifier/InvalidationService.java
+++ b/sync/android/java/src/org/chromium/sync/notifier/InvalidationService.java
@@ -75,6 +75,11 @@ public class InvalidationService extends AndroidListener {
*/
@Nullable private static byte[] sClientId;
+ /**
+ * A ID that uniquely identifies this client. Used for reflection blocking.
+ */
+ @Nullable private byte[] mClientName;
+
@Override
public void onHandleIntent(Intent intent) {
// Ensure that a client is or is not running, as appropriate, and that it is for the
@@ -85,6 +90,17 @@ public class InvalidationService extends AndroidListener {
Account account = intent.hasExtra(InvalidationIntentProtocol.EXTRA_ACCOUNT) ?
(Account) intent.getParcelableExtra(InvalidationIntentProtocol.EXTRA_ACCOUNT)
: null;
+
+ // Any intents sent to the InvalidationService should include the EXTRA_CLIENT_NAME. The
+ // call to ensureClientStartState() might need a client name, and would break if we don't
+ // have one.
+ //
+ // Intents that are addressed to the AndroidListener portion of this class do not need to
+ // include the EXTRA_CLIENT_NAME.
+ if (intent.hasExtra(InvalidationIntentProtocol.EXTRA_CLIENT_NAME)) {
+ mClientName = intent.getByteArrayExtra(InvalidationIntentProtocol.EXTRA_CLIENT_NAME);
+ }
+
ensureAccount(account);
ensureClientStartState();
@@ -265,7 +281,8 @@ public class InvalidationService extends AndroidListener {
* {@link InvalidationPreferences#setAccount}.
*/
private void startClient() {
- Intent startIntent = AndroidListener.createStartIntent(this, CLIENT_TYPE, getClientName());
+ assert (mClientName != null);
+ Intent startIntent = AndroidListener.createStartIntent(this, CLIENT_TYPE, mClientName);
startService(startIntent);
setIsClientStarted(true);
}
@@ -496,13 +513,6 @@ public class InvalidationService extends AndroidListener {
return "oauth2:" + SyncStatusHelper.CHROME_SYNC_OAUTH2_SCOPE;
}
- /** Returns the client name used for the notification client. */
- private static byte[] getClientName() {
- // TODO(dsmyers): we should use the same client name as the native sync code.
- // Bug: https://code.google.com/p/chromium/issues/detail?id=172391
- return Long.toString(RANDOM.nextLong()).getBytes();
- }
-
private static void setClientId(byte[] clientId) {
sClientId = clientId;
}

Powered by Google App Engine
This is Rietveld 408576698