| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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/base/sync_export.h" | 13 #include "sync/base/sync_export.h" |
| 14 #include "sync/notifier/invalidation_handler.h" | 14 #include "sync/notifier/invalidation_handler.h" |
| 15 #include "sync/notifier/invalidation_util.h" | 15 #include "sync/notifier/invalidation_util.h" |
| 16 #include "sync/notifier/object_id_invalidation_map.h" | |
| 17 | 16 |
| 18 namespace invalidation { | 17 namespace invalidation { |
| 19 class ObjectId; | 18 class ObjectId; |
| 20 } // namespace invalidation | 19 } // namespace invalidation |
| 21 | 20 |
| 22 namespace syncer { | 21 namespace syncer { |
| 23 | 22 |
| 23 class ObjectIdInvalidationMap; |
| 24 |
| 24 // A helper class for implementations of the Invalidator interface. It helps | 25 // A helper class for implementations of the Invalidator interface. It helps |
| 25 // keep track of registered handlers and which object ID registrations are | 26 // keep track of registered handlers and which object ID registrations are |
| 26 // associated with which handlers, so implementors can just reuse the logic | 27 // associated with which handlers, so implementors can just reuse the logic |
| 27 // here to dispatch invalidations and other interesting notifications. | 28 // here to dispatch invalidations and other interesting notifications. |
| 28 class SYNC_EXPORT InvalidatorRegistrar { | 29 class SYNC_EXPORT InvalidatorRegistrar { |
| 29 public: | 30 public: |
| 30 InvalidatorRegistrar(); | 31 InvalidatorRegistrar(); |
| 31 | 32 |
| 32 // It is an error to have registered handlers on destruction. | 33 // It is an error to have registered handlers on destruction. |
| 33 ~InvalidatorRegistrar(); | 34 ~InvalidatorRegistrar(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // InvalidationHandler::OnInvalidatorStateChange(), this returns the | 70 // InvalidationHandler::OnInvalidatorStateChange(), this returns the |
| 70 // updated state. | 71 // updated state. |
| 71 InvalidatorState GetInvalidatorState() const; | 72 InvalidatorState GetInvalidatorState() const; |
| 72 | 73 |
| 73 bool IsHandlerRegisteredForTest(InvalidationHandler* handler) const; | 74 bool IsHandlerRegisteredForTest(InvalidationHandler* handler) const; |
| 74 | 75 |
| 75 // Needed for death tests. | 76 // Needed for death tests. |
| 76 void DetachFromThreadForTest(); | 77 void DetachFromThreadForTest(); |
| 77 | 78 |
| 78 private: | 79 private: |
| 79 typedef std::map<invalidation::ObjectId, InvalidationHandler*, | 80 typedef std::map<InvalidationHandler*, ObjectIdSet> HandlerIdsMap; |
| 80 ObjectIdLessThan> | |
| 81 IdHandlerMap; | |
| 82 | |
| 83 InvalidationHandler* ObjectIdToHandler(const invalidation::ObjectId& id); | |
| 84 | 81 |
| 85 base::ThreadChecker thread_checker_; | 82 base::ThreadChecker thread_checker_; |
| 86 ObserverList<InvalidationHandler> handlers_; | 83 ObserverList<InvalidationHandler> handlers_; |
| 87 IdHandlerMap id_to_handler_map_; | 84 HandlerIdsMap handler_to_ids_map_; |
| 88 InvalidatorState state_; | 85 InvalidatorState state_; |
| 89 | 86 |
| 90 DISALLOW_COPY_AND_ASSIGN(InvalidatorRegistrar); | 87 DISALLOW_COPY_AND_ASSIGN(InvalidatorRegistrar); |
| 91 }; | 88 }; |
| 92 | 89 |
| 93 } // namespace syncer | 90 } // namespace syncer |
| 94 | 91 |
| 95 #endif // SYNC_NOTIFIER_INVALIDATOR_REGISTRAR_H_ | 92 #endif // SYNC_NOTIFIER_INVALIDATOR_REGISTRAR_H_ |
| OLD | NEW |