diff options
author | Zeno Albisser <zeno.albisser@digia.com> | 2013-08-15 21:46:11 +0200 |
---|---|---|
committer | Zeno Albisser <zeno.albisser@digia.com> | 2013-08-15 21:46:11 +0200 |
commit | 679147eead574d186ebf3069647b4c23e8ccace6 (patch) | |
tree | fc247a0ac8ff119f7c8550879ebb6d3dd8d1ff69 /chromium/sync/notifier/invalidator.h | |
download | qtwebengine-chromium-679147eead574d186ebf3069647b4c23e8ccace6.tar.gz |
Initial import.
Diffstat (limited to 'chromium/sync/notifier/invalidator.h')
-rw-r--r-- | chromium/sync/notifier/invalidator.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/chromium/sync/notifier/invalidator.h b/chromium/sync/notifier/invalidator.h new file mode 100644 index 00000000000..ccb69222083 --- /dev/null +++ b/chromium/sync/notifier/invalidator.h @@ -0,0 +1,89 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Interface to the invalidator, which is an object that receives +// invalidations for registered object IDs. The corresponding +// InvalidationHandler is notifier when such an event occurs. + +#ifndef SYNC_NOTIFIER_INVALIDATOR_H_ +#define SYNC_NOTIFIER_INVALIDATOR_H_ + +#include <string> + +#include "sync/base/sync_export.h" +#include "sync/internal_api/public/base/model_type.h" +#include "sync/notifier/invalidation_util.h" +#include "sync/notifier/invalidator_state.h" +#include "sync/notifier/object_id_invalidation_map.h" + +namespace syncer { +class InvalidationHandler; + +class SYNC_EXPORT Invalidator { + public: + Invalidator() {} + virtual ~Invalidator() {} + + // Clients should follow the pattern below: + // + // When starting the client: + // + // invalidator->RegisterHandler(client_handler); + // + // When the set of IDs to register changes for the client during its lifetime + // (i.e., between calls to RegisterHandler(client_handler) and + // UnregisterHandler(client_handler): + // + // invalidator->UpdateRegisteredIds(client_handler, client_ids); + // + // When shutting down the client for profile shutdown: + // + // invalidator->UnregisterHandler(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: + // + // invalidator->UpdateRegisteredIds(client_handler, ObjectIdSet()); + // invalidator->UnregisterHandler(client_handler); + // + // It is an error to have registered handlers when an invalidator is + // destroyed; clients must ensure that they unregister themselves + // before then. + + // Starts sending notifications to |handler|. |handler| must not be NULL, + // and it must not already be registered. + virtual void RegisterHandler(InvalidationHandler* handler) = 0; + + // 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. + virtual void UpdateRegisteredIds(InvalidationHandler* handler, + const ObjectIdSet& ids) = 0; + + // 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|. + virtual void UnregisterHandler(InvalidationHandler* handler) = 0; + + // Acknowledge that an invalidation for |id| was handled. + virtual void Acknowledge(const invalidation::ObjectId& id, + const AckHandle& ack_handle) = 0; + + // Returns the current invalidator state. When called from within + // InvalidationHandler::OnInvalidatorStateChange(), this must return + // the updated state. + virtual InvalidatorState GetInvalidatorState() const = 0; + + // The observers won't be notified of any notifications until + // UpdateCredentials is called at least once. It can be called more than + // once. + virtual void UpdateCredentials( + const std::string& email, const std::string& token) = 0; +}; +} // namespace syncer + +#endif // SYNC_NOTIFIER_INVALIDATOR_H_ |