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

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

Issue 22642004: Ensure we never try to register for the object id "NULL" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.sync.notifier; 5 package org.chromium.sync.notifier;
6 6
7 import android.accounts.Account; 7 import android.accounts.Account;
8 import android.app.PendingIntent; 8 import android.app.PendingIntent;
9 import android.content.ContentResolver; 9 import android.content.ContentResolver;
10 import android.content.Intent; 10 import android.content.Intent;
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 * Reads the saved sync types from storage (if any) and returns a set contai ning the 289 * Reads the saved sync types from storage (if any) and returns a set contai ning the
290 * corresponding object ids. 290 * corresponding object ids.
291 */ 291 */
292 @VisibleForTesting 292 @VisibleForTesting
293 Set<ObjectId> readRegistrationsFromPrefs() { 293 Set<ObjectId> readRegistrationsFromPrefs() {
294 Set<String> savedTypes = new InvalidationPreferences(this).getSavedSynce dTypes(); 294 Set<String> savedTypes = new InvalidationPreferences(this).getSavedSynce dTypes();
295 if (savedTypes == null) { 295 if (savedTypes == null) {
296 return Collections.emptySet(); 296 return Collections.emptySet();
297 } else { 297 } else {
298 Set<ModelType> modelTypes = ModelType.syncTypesToModelTypes(savedTyp es); 298 Set<ModelType> modelTypes = ModelType.syncTypesToModelTypes(savedTyp es);
299 modelTypes = ModelType.stripNonInvalidationTypes(modelTypes);
299 Set<ObjectId> objectIds = Sets.newHashSetWithExpectedSize(modelTypes .size()); 300 Set<ObjectId> objectIds = Sets.newHashSetWithExpectedSize(modelTypes .size());
Yaron 2013/08/08 01:52:16 These 4 lines can be replaced with ModelType.model
nyquist 2013/08/08 17:59:28 Simplified this, and moved logic to modelTypesToOb
300 for (ModelType modelType : modelTypes) { 301 for (ModelType modelType : modelTypes) {
301 objectIds.add(modelType.toObjectId()); 302 objectIds.add(modelType.toObjectId());
302 } 303 }
303 return objectIds; 304 return objectIds;
304 } 305 }
305 } 306 }
306 307
307 /** 308 /**
308 * Sets the types for which notifications are required to {@code syncTypes}. {@code syncTypes} 309 * Sets the types for which notifications are required to {@code syncTypes}. {@code syncTypes}
309 * is either a list of specific types or the special wildcard type 310 * is either a list of specific types or the special wildcard type
(...skipping 21 matching lines...) Expand all
331 if (sClientId == null) { 332 if (sClientId == null) {
332 return; 333 return;
333 } 334 }
334 335
335 // We do have a ready client. Unregister any existing registrations not present in the 336 // We do have a ready client. Unregister any existing registrations not present in the
336 // new set and register any elements in the new set not already present. This call does 337 // new set and register any elements in the new set not already present. This call does
337 // expansion of the ALL_TYPES_TYPE wildcard. 338 // expansion of the ALL_TYPES_TYPE wildcard.
338 // NOTE: syncTypes MUST NOT be used below this line, since it contains a n unexpanded 339 // NOTE: syncTypes MUST NOT be used below this line, since it contains a n unexpanded
339 // wildcard. 340 // wildcard.
340 Set<ModelType> newRegisteredTypes = ModelType.syncTypesToModelTypes(sync Types); 341 Set<ModelType> newRegisteredTypes = ModelType.syncTypesToModelTypes(sync Types);
342 // Some types should never receive notifications.
343 newRegisteredTypes = ModelType.stripNonInvalidationTypes(newRegisteredTy pes);
341 344
342 List<ObjectId> unregistrations = Lists.newArrayList(); 345 List<ObjectId> unregistrations = Lists.newArrayList();
343 List<ObjectId> registrations = Lists.newArrayList(); 346 List<ObjectId> registrations = Lists.newArrayList();
344 computeRegistrationOps(existingRegistrations, 347 computeRegistrationOps(existingRegistrations,
345 ModelType.modelTypesToObjectIds(newRegisteredTypes), registratio ns, 348 ModelType.modelTypesToObjectIds(newRegisteredTypes), registratio ns,
346 unregistrations); 349 unregistrations);
347 unregister(sClientId, unregistrations); 350 unregister(sClientId, unregistrations);
348 register(sClientId, registrations); 351 register(sClientId, registrations);
349 } 352 }
350 353
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 } 458 }
456 459
457 private static void setClientId(byte[] clientId) { 460 private static void setClientId(byte[] clientId) {
458 sClientId = clientId; 461 sClientId = clientId;
459 } 462 }
460 463
461 private static void setIsClientStarted(boolean isStarted) { 464 private static void setIsClientStarted(boolean isStarted) {
462 sIsClientStarted = isStarted; 465 sIsClientStarted = isStarted;
463 } 466 }
464 } 467 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698