| OLD | NEW |
| (Empty) |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 // | |
| 5 // Interface to the invalidator, which is an object that receives | |
| 6 // invalidations for registered object IDs. The corresponding | |
| 7 // InvalidationHandler is notifier when such an event occurs. | |
| 8 | |
| 9 #ifndef SYNC_NOTIFIER_INVALIDATOR_H_ | |
| 10 #define SYNC_NOTIFIER_INVALIDATOR_H_ | |
| 11 | |
| 12 #include <string> | |
| 13 | |
| 14 #include "base/callback.h" | |
| 15 #include "sync/base/sync_export.h" | |
| 16 #include "sync/internal_api/public/base/invalidator_state.h" | |
| 17 #include "sync/internal_api/public/base/model_type.h" | |
| 18 #include "sync/notifier/invalidation_util.h" | |
| 19 | |
| 20 namespace syncer { | |
| 21 class InvalidationHandler; | |
| 22 | |
| 23 class SYNC_EXPORT Invalidator { | |
| 24 public: | |
| 25 Invalidator(); | |
| 26 virtual ~Invalidator(); | |
| 27 | |
| 28 // Clients should follow the pattern below: | |
| 29 // | |
| 30 // When starting the client: | |
| 31 // | |
| 32 // invalidator->RegisterHandler(client_handler); | |
| 33 // | |
| 34 // When the set of IDs to register changes for the client during its lifetime | |
| 35 // (i.e., between calls to RegisterHandler(client_handler) and | |
| 36 // UnregisterHandler(client_handler): | |
| 37 // | |
| 38 // invalidator->UpdateRegisteredIds(client_handler, client_ids); | |
| 39 // | |
| 40 // When shutting down the client for profile shutdown: | |
| 41 // | |
| 42 // invalidator->UnregisterHandler(client_handler); | |
| 43 // | |
| 44 // Note that there's no call to UpdateRegisteredIds() -- this is because the | |
| 45 // invalidation API persists registrations across browser restarts. | |
| 46 // | |
| 47 // When permanently shutting down the client, e.g. when disabling the related | |
| 48 // feature: | |
| 49 // | |
| 50 // invalidator->UpdateRegisteredIds(client_handler, ObjectIdSet()); | |
| 51 // invalidator->UnregisterHandler(client_handler); | |
| 52 // | |
| 53 // It is an error to have registered handlers when an invalidator is | |
| 54 // destroyed; clients must ensure that they unregister themselves | |
| 55 // before then. | |
| 56 | |
| 57 // Starts sending notifications to |handler|. |handler| must not be NULL, | |
| 58 // and it must not already be registered. | |
| 59 virtual void RegisterHandler(InvalidationHandler* handler) = 0; | |
| 60 | |
| 61 // Updates the set of ObjectIds associated with |handler|. |handler| must | |
| 62 // not be NULL, and must already be registered. An ID must be registered for | |
| 63 // at most one handler. | |
| 64 virtual void UpdateRegisteredIds(InvalidationHandler* handler, | |
| 65 const ObjectIdSet& ids) = 0; | |
| 66 | |
| 67 // Stops sending notifications to |handler|. |handler| must not be NULL, and | |
| 68 // it must already be registered. Note that this doesn't unregister the IDs | |
| 69 // associated with |handler|. | |
| 70 virtual void UnregisterHandler(InvalidationHandler* handler) = 0; | |
| 71 | |
| 72 // Returns the current invalidator state. When called from within | |
| 73 // InvalidationHandler::OnInvalidatorStateChange(), this must return | |
| 74 // the updated state. | |
| 75 virtual InvalidatorState GetInvalidatorState() const = 0; | |
| 76 | |
| 77 // The observers won't be notified of any notifications until | |
| 78 // UpdateCredentials is called at least once. It can be called more than | |
| 79 // once. | |
| 80 virtual void UpdateCredentials( | |
| 81 const std::string& email, const std::string& token) = 0; | |
| 82 | |
| 83 // Requests internal detailed status to be posted back to the callback. | |
| 84 virtual void RequestDetailedStatus( | |
| 85 base::Callback<void(const base::DictionaryValue&)> callback) const = 0; | |
| 86 }; | |
| 87 } // namespace syncer | |
| 88 | |
| 89 #endif // SYNC_NOTIFIER_INVALIDATOR_H_ | |
| OLD | NEW |