| 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 #ifndef SYNC_NOTIFIER_INVALIDATOR_REGISTRAR_H_ | 5 #ifndef SYNC_NOTIFIER_INVALIDATOR_REGISTRAR_H_ |
| 6 #define SYNC_NOTIFIER_INVALIDATOR_REGISTRAR_H_ | 6 #define SYNC_NOTIFIER_INVALIDATOR_REGISTRAR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
| 13 #include "sync/notifier/invalidation_handler.h" | 13 #include "sync/notifier/invalidation_handler.h" |
| 14 #include "sync/notifier/invalidation_util.h" | 14 #include "sync/notifier/invalidation_util.h" |
| 15 #include "sync/notifier/object_id_state_map.h" | 15 #include "sync/notifier/object_id_invalidation_map.h" |
| 16 | 16 |
| 17 namespace invalidation { | 17 namespace invalidation { |
| 18 class ObjectId; | 18 class ObjectId; |
| 19 } // namespace invalidation | 19 } // namespace invalidation |
| 20 | 20 |
| 21 namespace syncer { | 21 namespace syncer { |
| 22 | 22 |
| 23 // A helper class for implementations of the Invalidator interface. It helps | 23 // A helper class for implementations of the Invalidator interface. It helps |
| 24 // keep track of registered handlers and which object ID registrations are | 24 // keep track of registered handlers and which object ID registrations are |
| 25 // associated with which handlers, so implementors can just reuse the logic | 25 // associated with which handlers, so implementors can just reuse the logic |
| (...skipping 21 matching lines...) Expand all Loading... |
| 47 ObjectIdSet GetRegisteredIds(InvalidationHandler* handler) const; | 47 ObjectIdSet GetRegisteredIds(InvalidationHandler* handler) const; |
| 48 | 48 |
| 49 // Returns the set of all IDs that are registered to some handler (even | 49 // Returns the set of all IDs that are registered to some handler (even |
| 50 // handlers that have been unregistered). | 50 // handlers that have been unregistered). |
| 51 ObjectIdSet GetAllRegisteredIds() const; | 51 ObjectIdSet GetAllRegisteredIds() const; |
| 52 | 52 |
| 53 // Sorts incoming invalidations into a bucket for each handler and then | 53 // Sorts incoming invalidations into a bucket for each handler and then |
| 54 // dispatches the batched invalidations to the corresponding handler. | 54 // dispatches the batched invalidations to the corresponding handler. |
| 55 // Invalidations for IDs with no corresponding handler are dropped, as are | 55 // Invalidations for IDs with no corresponding handler are dropped, as are |
| 56 // invalidations for handlers that are not added. | 56 // invalidations for handlers that are not added. |
| 57 void DispatchInvalidationsToHandlers(const ObjectIdStateMap& id_state_map, | 57 void DispatchInvalidationsToHandlers( |
| 58 IncomingInvalidationSource source); | 58 const ObjectIdInvalidationMap& invalidation_map, |
| 59 IncomingInvalidationSource source); |
| 59 | 60 |
| 60 // Updates the invalidator state to the given one and then notifies | 61 // Updates the invalidator state to the given one and then notifies |
| 61 // all handlers. Note that the order is important; handlers that | 62 // all handlers. Note that the order is important; handlers that |
| 62 // call GetInvalidatorState() when notified will see the new state. | 63 // call GetInvalidatorState() when notified will see the new state. |
| 63 void UpdateInvalidatorState(InvalidatorState state); | 64 void UpdateInvalidatorState(InvalidatorState state); |
| 64 | 65 |
| 65 // Returns the current invalidator state. When called from within | 66 // Returns the current invalidator state. When called from within |
| 66 // InvalidationHandler::OnInvalidatorStateChange(), this returns the | 67 // InvalidationHandler::OnInvalidatorStateChange(), this returns the |
| 67 // updated state. | 68 // updated state. |
| 68 InvalidatorState GetInvalidatorState() const; | 69 InvalidatorState GetInvalidatorState() const; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 83 ObserverList<InvalidationHandler> handlers_; | 84 ObserverList<InvalidationHandler> handlers_; |
| 84 IdHandlerMap id_to_handler_map_; | 85 IdHandlerMap id_to_handler_map_; |
| 85 InvalidatorState state_; | 86 InvalidatorState state_; |
| 86 | 87 |
| 87 DISALLOW_COPY_AND_ASSIGN(InvalidatorRegistrar); | 88 DISALLOW_COPY_AND_ASSIGN(InvalidatorRegistrar); |
| 88 }; | 89 }; |
| 89 | 90 |
| 90 } // namespace syncer | 91 } // namespace syncer |
| 91 | 92 |
| 92 #endif // SYNC_NOTIFIER_INVALIDATOR_REGISTRAR_H_ | 93 #endif // SYNC_NOTIFIER_INVALIDATOR_REGISTRAR_H_ |
| OLD | NEW |