| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Interface to the invalidator, which is an object that receives | 5 // Interface to the invalidator, which is an object that receives |
| 6 // invalidations for registered object IDs. The corresponding | 6 // invalidations for registered object IDs. The corresponding |
| 7 // InvalidationHandler is notifier when such an event occurs. | 7 // InvalidationHandler is notifier when such an event occurs. |
| 8 | 8 |
| 9 #ifndef SYNC_NOTIFIER_INVALIDATOR_H_ | 9 #ifndef SYNC_NOTIFIER_INVALIDATOR_H_ |
| 10 #define SYNC_NOTIFIER_INVALIDATOR_H_ | 10 #define SYNC_NOTIFIER_INVALIDATOR_H_ |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "sync/internal_api/public/base/model_type.h" | 14 #include "sync/internal_api/public/base/model_type.h" |
| 15 #include "sync/notifier/invalidation_util.h" | 15 #include "sync/notifier/invalidation_util.h" |
| 16 #include "sync/notifier/invalidator_state.h" |
| 16 #include "sync/notifier/object_id_state_map.h" | 17 #include "sync/notifier/object_id_state_map.h" |
| 17 | 18 |
| 18 namespace syncer { | 19 namespace syncer { |
| 19 class InvalidationHandler; | 20 class InvalidationHandler; |
| 20 | 21 |
| 21 class Invalidator { | 22 class Invalidator { |
| 22 public: | 23 public: |
| 23 Invalidator() {} | 24 Invalidator() {} |
| 24 virtual ~Invalidator() {} | 25 virtual ~Invalidator() {} |
| 25 | 26 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 42 // Note that there's no call to UpdateRegisteredIds() -- this is because the | 43 // Note that there's no call to UpdateRegisteredIds() -- this is because the |
| 43 // invalidation API persists registrations across browser restarts. | 44 // invalidation API persists registrations across browser restarts. |
| 44 // | 45 // |
| 45 // When permanently shutting down the client, e.g. when disabling the related | 46 // When permanently shutting down the client, e.g. when disabling the related |
| 46 // feature: | 47 // feature: |
| 47 // | 48 // |
| 48 // invalidator->UpdateRegisteredIds(client_handler, ObjectIdSet()); | 49 // invalidator->UpdateRegisteredIds(client_handler, ObjectIdSet()); |
| 49 // invalidator->UnregisterHandler(client_handler); | 50 // invalidator->UnregisterHandler(client_handler); |
| 50 | 51 |
| 51 // Starts sending notifications to |handler|. |handler| must not be NULL, | 52 // Starts sending notifications to |handler|. |handler| must not be NULL, |
| 52 // and it must already be registered. | 53 // and it must not already be registered. |
| 53 virtual void RegisterHandler(InvalidationHandler* handler) = 0; | 54 virtual void RegisterHandler(InvalidationHandler* handler) = 0; |
| 54 | 55 |
| 55 // Updates the set of ObjectIds associated with |handler|. |handler| must | 56 // Updates the set of ObjectIds associated with |handler|. |handler| must |
| 56 // not be NULL, and must already be registered. An ID must be registered for | 57 // not be NULL, and must already be registered. An ID must be registered for |
| 57 // at most one handler. | 58 // at most one handler. |
| 58 virtual void UpdateRegisteredIds(InvalidationHandler* handler, | 59 virtual void UpdateRegisteredIds(InvalidationHandler* handler, |
| 59 const ObjectIdSet& ids) = 0; | 60 const ObjectIdSet& ids) = 0; |
| 60 | 61 |
| 61 // Stops sending notifications to |handler|. |handler| must not be NULL, and | 62 // Stops sending notifications to |handler|. |handler| must not be NULL, and |
| 62 // it must already be registered. Note that this doesn't unregister the IDs | 63 // it must already be registered. Note that this doesn't unregister the IDs |
| 63 // associated with |handler|. | 64 // associated with |handler|. |
| 64 virtual void UnregisterHandler(InvalidationHandler* handler) = 0; | 65 virtual void UnregisterHandler(InvalidationHandler* handler) = 0; |
| 65 | 66 |
| 67 // Returns the current invalidator state. When called from within |
| 68 // InvalidationHandler::OnInvalidatorStateChange(), this must return |
| 69 // the updated state. |
| 70 virtual InvalidatorState GetInvalidatorState() const = 0; |
| 71 |
| 66 // SetUniqueId must be called once, before any call to | 72 // SetUniqueId must be called once, before any call to |
| 67 // UpdateCredentials. |unique_id| should be a non-empty globally | 73 // UpdateCredentials. |unique_id| should be a non-empty globally |
| 68 // unique string. | 74 // unique string. |
| 69 virtual void SetUniqueId(const std::string& unique_id) = 0; | 75 virtual void SetUniqueId(const std::string& unique_id) = 0; |
| 70 | 76 |
| 71 // SetState must be called once, before any call to | 77 // SetState must be called once, before any call to |
| 72 // UpdateCredentials. |state| may be empty. | 78 // UpdateCredentials. |state| may be empty. |
| 73 // Deprecated in favour of InvalidationStateTracker persistence. | 79 // Deprecated in favour of InvalidationStateTracker persistence. |
| 74 virtual void SetStateDeprecated(const std::string& state) = 0; | 80 virtual void SetStateDeprecated(const std::string& state) = 0; |
| 75 | 81 |
| 76 // The observers won't be notified of any notifications until | 82 // The observers won't be notified of any notifications until |
| 77 // UpdateCredentials is called at least once. It can be called more than | 83 // UpdateCredentials is called at least once. It can be called more than |
| 78 // once. | 84 // once. |
| 79 virtual void UpdateCredentials( | 85 virtual void UpdateCredentials( |
| 80 const std::string& email, const std::string& token) = 0; | 86 const std::string& email, const std::string& token) = 0; |
| 81 | 87 |
| 82 // This is here only to support the old p2p notification implementation, | 88 // This is here only to support the old p2p notification implementation, |
| 83 // which is still used by sync integration tests. | 89 // which is still used by sync integration tests. |
| 84 // TODO(akalin): Remove this once we move the integration tests off p2p | 90 // TODO(akalin): Remove this once we move the integration tests off p2p |
| 85 // notifications. | 91 // notifications. |
| 86 virtual void SendNotification(const ObjectIdStateMap& id_state_map) = 0; | 92 virtual void SendInvalidation(const ObjectIdStateMap& id_state_map) = 0; |
| 87 }; | 93 }; |
| 88 } // namespace syncer | 94 } // namespace syncer |
| 89 | 95 |
| 90 #endif // SYNC_NOTIFIER_INVALIDATOR_H_ | 96 #endif // SYNC_NOTIFIER_INVALIDATOR_H_ |
| OLD | NEW |