Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: sync/notifier/invalidation_notifier_base.h

Issue 10702074: Refactor sync-specific parts out of SyncNotifier/SyncNotifierObserver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor cleanup Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698