summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/profile_sync_service.h
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-16 01:26:17 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-16 01:26:17 +0000
commit6517c45b4e76fe4ef381da7b3559db8afdf65fc2 (patch)
tree2c650653d6ee941ca671d3215b4abdea0f301415 /chrome/browser/sync/profile_sync_service.h
parent257745de825487cc6bb520e0f420ffa51003e0a1 (diff)
downloadchromium_src-6517c45b4e76fe4ef381da7b3559db8afdf65fc2.zip
chromium_src-6517c45b4e76fe4ef381da7b3559db8afdf65fc2.tar.gz
chromium_src-6517c45b4e76fe4ef381da7b3559db8afdf65fc2.tar.bz2
[Sync] (Merge to 1229) 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 TBR=tim@chromium.org Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=150990 Review URL: https://chromiumcodereview.appspot.com/10824161 Review URL: https://chromiumcodereview.appspot.com/10825379 git-svn-id: svn://svn.chromium.org/chrome/branches/1229/src@151820 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/profile_sync_service.h')
-rw-r--r--chrome/browser/sync/profile_sync_service.h58
1 files changed, 48 insertions, 10 deletions
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 3e3e14c..6e8ea6e 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -38,7 +38,7 @@
#include "sync/internal_api/public/util/experiments.h"
#include "sync/internal_api/public/util/unrecoverable_error_handler.h"
#include "sync/js/sync_js_controller.h"
-#include "sync/notifier/sync_notifier_helper.h"
+#include "sync/notifier/sync_notifier_registrar.h"
class Profile;
class ProfileSyncComponentsFactory;
@@ -552,15 +552,56 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// been cleared yet. Virtual for testing purposes.
virtual bool waiting_for_auth() const;
- // Updates the set of ObjectIds associated with a given |handler|.
- // Passing an empty ObjectIdSet will unregister |handler|.
- // There should be at most one handler registered per object id.
+ // Invalidation clients should follow the pattern below:
//
- // The handler -> registered ids map is persisted across restarts of
- // sync.
+ // When starting the client:
+ //
+ // pss->RegisterInvalidationHandler(client_handler);
+ //
+ // When the set of IDs to register changes for the client during its lifetime
+ // (i.e., between calls to RegisterInvalidationHandler(client_handler) and
+ // UnregisterInvalidationHandler(client_handler):
+ //
+ // pss->UpdateRegisteredInvalidationIds(client_handler, client_ids);
+ //
+ // When shutting down the client for browser shutdown:
+ //
+ // pss->UnregisterInvalidationHandler(client_handler);
+ //
+ // Note that there's no call to UpdateRegisteredIds() -- this is because the
+ // invalidation API persists registrations across browser restarts.
+ //
+ // When permanently shutting down the client, e.g. when disabling the related
+ // feature:
+ //
+ // pss->UpdateRegisteredInvalidationIds(client_handler, ObjectIdSet());
+ // pss->UnregisterInvalidationHandler(client_handler);
+
+ // NOTE(akalin): Invalidations that come in during browser shutdown may get
+ // dropped. This won't matter once we have an Acknowledge API, though: see
+ // http://crbug.com/78462 and http://crbug.com/124149.
+
+ // Starts sending notifications to |handler|. |handler| must not be NULL,
+ // and it must already be registered.
+ //
+ // Handler registrations are persisted across restarts of sync.
+ void RegisterInvalidationHandler(syncer::SyncNotifierObserver* handler);
+
+ // Updates the set of ObjectIds associated with |handler|. |handler| must
+ // not be NULL, and must already be registered. An ID must be registered for
+ // at most one handler.
+ //
+ // Registered IDs are persisted across restarts of sync.
void UpdateRegisteredInvalidationIds(syncer::SyncNotifierObserver* handler,
const syncer::ObjectIdSet& ids);
+ // Stops sending notifications to |handler|. |handler| must not be NULL, and
+ // it must already be registered. Note that this doesn't unregister the IDs
+ // associated with |handler|.
+ //
+ // Handler registrations are persisted across restarts of sync.
+ void UnregisterInvalidationHandler(syncer::SyncNotifierObserver* handler);
+
// ProfileKeyedService implementation.
virtual void Shutdown() OVERRIDE;
@@ -835,11 +876,8 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// Factory the backend will use to build the SyncManager.
syncer::SyncManagerFactory sync_manager_factory_;
- // The set of all registered IDs.
- syncer::ObjectIdSet all_registered_ids_;
-
// Dispatches invalidations to handlers.
- syncer::SyncNotifierHelper notifier_helper_;
+ syncer::SyncNotifierRegistrar notifier_registrar_;
DISALLOW_COPY_AND_ASSIGN(ProfileSyncService);
};