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_invalidation_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 |
26 // here to dispatch invalidations and other interesting notifications. | 26 // here to dispatch invalidations and other interesting notifications. |
27 class InvalidatorRegistrar { | 27 class InvalidatorRegistrar { |
28 public: | 28 public: |
29 InvalidatorRegistrar(); | 29 InvalidatorRegistrar(); |
| 30 |
| 31 // It is an error to have registered handlers on destruction. |
30 ~InvalidatorRegistrar(); | 32 ~InvalidatorRegistrar(); |
31 | 33 |
32 // Starts sending notifications to |handler|. |handler| must not be NULL, | 34 // Starts sending notifications to |handler|. |handler| must not be NULL, |
33 // and it must already be registered. | 35 // and it must already be registered. |
34 void RegisterHandler(InvalidationHandler* handler); | 36 void RegisterHandler(InvalidationHandler* handler); |
35 | 37 |
36 // Updates the set of ObjectIds associated with |handler|. |handler| must | 38 // Updates the set of ObjectIds associated with |handler|. |handler| must |
37 // not be NULL, and must already be registered. An ID must be registered for | 39 // not be NULL, and must already be registered. An ID must be registered for |
38 // at most one handler. | 40 // at most one handler. |
39 void UpdateRegisteredIds(InvalidationHandler* handler, | 41 void UpdateRegisteredIds(InvalidationHandler* handler, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 ObserverList<InvalidationHandler> handlers_; | 86 ObserverList<InvalidationHandler> handlers_; |
85 IdHandlerMap id_to_handler_map_; | 87 IdHandlerMap id_to_handler_map_; |
86 InvalidatorState state_; | 88 InvalidatorState state_; |
87 | 89 |
88 DISALLOW_COPY_AND_ASSIGN(InvalidatorRegistrar); | 90 DISALLOW_COPY_AND_ASSIGN(InvalidatorRegistrar); |
89 }; | 91 }; |
90 | 92 |
91 } // namespace syncer | 93 } // namespace syncer |
92 | 94 |
93 #endif // SYNC_NOTIFIER_INVALIDATOR_REGISTRAR_H_ | 95 #endif // SYNC_NOTIFIER_INVALIDATOR_REGISTRAR_H_ |
OLD | NEW |