OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SYNC_NOTIFIER_INVALIDATION_NOTIFIER_BASE_H_ | |
6 #define SYNC_NOTIFIER_INVALIDATION_NOTIFIER_BASE_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/observer_list.h" | |
12 #include "sync/notifier/invalidation_util.h" | |
13 #include "sync/notifier/object_id_payload_map.h" | |
14 #include "sync/notifier/sync_notifier.h" | |
15 #include "sync/notifier/sync_notifier_observer.h" | |
16 | |
17 namespace syncer { | |
18 | |
19 // Logic shared between InvalidationNotifier and | |
20 // NonBlockingInvalidationNotifier. | |
21 class InvalidationNotifierBase : public SyncNotifier { | |
22 public: | |
23 InvalidationNotifierBase(); | |
24 virtual ~InvalidationNotifierBase(); | |
25 | |
26 virtual void AddHandler(SyncNotifierObserver* observer) OVERRIDE; | |
27 virtual void RemoveHandler(SyncNotifierObserver* observer) OVERRIDE; | |
28 | |
29 protected: | |
30 // Updates the mapping of object IDs to observers and returns all the keys, | |
31 // e.g. object IDs, that are currently in the map. | |
32 ObjectIdSet UpdateObjectIdObserverMap(); | |
33 | |
34 // Helper that sorts incoming invalidations into a bucket for each observer | |
35 // and then dispatches the batched invalidations to each respective observer. | |
36 void DispatchInvalidationsToObservers(const ObjectIdPayloadMap& id_payloads, | |
37 IncomingNotificationSource source); | |
38 | |
39 // Note that this is non-const because FOR_EACH_OBSERVER() may mutate the | |
40 // original observer list. | |
41 ObserverList<SyncNotifierObserver>& observers() { return observers_; } | |
akalin
2012/07/11 00:10:24
should return a pointer
dcheng
2012/07/11 05:45:28
Done.
| |
42 | |
43 private: | |
44 typedef std::map<invalidation::ObjectId, | |
45 SyncNotifierObserver*, | |
46 ObjectIdLessThan> ObjectIdObserverMap; | |
47 | |
48 ObserverList<SyncNotifierObserver> observers_; | |
49 ObjectIdObserverMap id_to_observer_map_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(InvalidationNotifierBase); | |
52 }; | |
53 | |
54 } // namespace syncer | |
55 | |
56 #endif // SYNC_NOTIFIER_INVALIDATION_NOTIFIER_BASE_H_ | |
OLD | NEW |