Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 } |
| OLD | NEW |