summaryrefslogtreecommitdiffstats
path: root/sync/internal_api/public
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-10 04:07:19 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-10 04:07:19 +0000
commit6529382867932acbf83e49bc107fbe4ea28ad311 (patch)
tree9baba790501b4c0e95b59ca72b5c769ca5a28190 /sync/internal_api/public
parentbfe14502edd281a935198917fc49e30fbef47792 (diff)
downloadchromium_src-6529382867932acbf83e49bc107fbe4ea28ad311.zip
chromium_src-6529382867932acbf83e49bc107fbe4ea28ad311.tar.gz
chromium_src-6529382867932acbf83e49bc107fbe4ea28ad311.tar.bz2
[Sync] Avoid unregistering object IDs on shutdown
Add RegisterHandler() and UnregisterHandler(), which should be called before and after calls to UpdateRegisteredIds(). Use UnregisterHandler() on shutdown instead of UpdateRegisteredIds(_, ObjectIdSet()). Make SyncNotifierHelper non-thread-safe. Fix test breakages that this revealed. Also add GetAllRegisteredIds() instead of making it the return value of UpdateRegisteredIds(). Propagate UpdateRegisteredIds()/RegisterHandler()/UnregisterHandler() all the way up to ProfileSyncService. Make FakeSyncManager be created on the sync thread. Clean up SyncBackendHost startup/shutdown behavior a bit. BUG=140325 Review URL: https://chromiumcodereview.appspot.com/10824161 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150990 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api/public')
-rw-r--r--sync/internal_api/public/sync_manager.h11
-rw-r--r--sync/internal_api/public/test/fake_sync_manager.h43
2 files changed, 33 insertions, 21 deletions
diff --git a/sync/internal_api/public/sync_manager.h b/sync/internal_api/public/sync_manager.h
index 0cb6a4c..01d919c 100644
--- a/sync/internal_api/public/sync_manager.h
+++ b/sync/internal_api/public/sync_manager.h
@@ -407,12 +407,19 @@ class SyncManager {
virtual void UpdateEnabledTypes(
const ModelTypeSet& enabled_types) = 0;
- // Forwards to the underlying notifier (see
- // SyncNotifier::UpdateRegisteredIds()).
+ // Forwards to the underlying notifier (see comments in sync_notifier.h).
+ virtual void RegisterInvalidationHandler(
+ SyncNotifierObserver* handler) = 0;
+
+ // Forwards to the underlying notifier (see comments in sync_notifier.h).
virtual void UpdateRegisteredInvalidationIds(
SyncNotifierObserver* handler,
const ObjectIdSet& ids) = 0;
+ // Forwards to the underlying notifier (see comments in sync_notifier.h).
+ virtual void UnregisterInvalidationHandler(
+ SyncNotifierObserver* handler) = 0;
+
// Put the syncer in normal mode ready to perform nudges and polls.
virtual void StartSyncingNormally(
const ModelSafeRoutingInfo& routing_info) = 0;
diff --git a/sync/internal_api/public/test/fake_sync_manager.h b/sync/internal_api/public/test/fake_sync_manager.h
index 12f3f70..71fe35e 100644
--- a/sync/internal_api/public/test/fake_sync_manager.h
+++ b/sync/internal_api/public/test/fake_sync_manager.h
@@ -10,7 +10,7 @@
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "sync/internal_api/public/sync_manager.h"
-#include "sync/notifier/sync_notifier_helper.h"
+#include "sync/notifier/sync_notifier_registrar.h"
namespace base {
class SequencedTaskRunner;
@@ -20,25 +20,23 @@ namespace syncer {
class FakeSyncManager : public SyncManager {
public:
- explicit FakeSyncManager();
+ // |initial_sync_ended_types|: The set of types that have initial_sync_ended
+ // set to true. This value will be used by InitialSyncEndedTypes() until the
+ // next configuration is performed.
+ //
+ // |progress_marker_types|: The set of types that have valid progress
+ // markers. This will be used by GetTypesWithEmptyProgressMarkerToken() until
+ // the next configuration is performed.
+ //
+ // |configure_fail_types|: The set of types that will fail
+ // configuration. Once ConfigureSyncer is called, the
+ // |initial_sync_ended_types_| and |progress_marker_types_| will be updated
+ // to include those types that didn't fail.
+ FakeSyncManager(ModelTypeSet initial_sync_ended_types,
+ ModelTypeSet progress_marker_types,
+ ModelTypeSet configure_fail_types);
virtual ~FakeSyncManager();
- // The set of types that have initial_sync_ended set to true. This value will
- // be used by InitialSyncEndedTypes() until the next configuration is
- // performed.
- void set_initial_sync_ended_types(ModelTypeSet types);
-
- // The set of types that have valid progress markers. This will be used by
- // GetTypesWithEmptyProgressMarkerToken() until the next configuration is
- // performed.
- void set_progress_marker_types(ModelTypeSet types);
-
- // The set of types that will fail configuration. Once ConfigureSyncer is
- // called, the |initial_sync_ended_types_| and
- // |progress_marker_types_| will be updated to include those types
- // that didn't fail.
- void set_configure_fail_types(ModelTypeSet types);
-
// Returns those types that have been cleaned (purged from the directory)
// since the last call to GetAndResetCleanedTypes(), or since startup if never
// called.
@@ -63,6 +61,9 @@ class FakeSyncManager : public SyncManager {
// Posts a method to disable notifications on the sync thread.
void DisableNotifications(NotificationsDisabledReason reason);
+ // Block until the sync thread has finished processing any pending messages.
+ void WaitForSyncThread();
+
// SyncManager implementation.
// Note: we treat whatever message loop this is called from as the sync
// loop for purposes of callbacks.
@@ -94,9 +95,13 @@ class FakeSyncManager : public SyncManager {
virtual bool PurgePartiallySyncedTypes() OVERRIDE;
virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE;
virtual void UpdateEnabledTypes(const ModelTypeSet& types) OVERRIDE;
+ virtual void RegisterInvalidationHandler(
+ SyncNotifierObserver* handler) OVERRIDE;
virtual void UpdateRegisteredInvalidationIds(
SyncNotifierObserver* handler,
const ObjectIdSet& ids) OVERRIDE;
+ virtual void UnregisterInvalidationHandler(
+ SyncNotifierObserver* handler) OVERRIDE;
virtual void StartSyncingNormally(
const ModelSafeRoutingInfo& routing_info) OVERRIDE;
virtual void SetEncryptionPassphrase(const std::string& passphrase,
@@ -150,7 +155,7 @@ class FakeSyncManager : public SyncManager {
ModelTypeSet enabled_types_;
// Faked notifier state.
- SyncNotifierHelper notifier_helper_;
+ SyncNotifierRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(FakeSyncManager);
};