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

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: Merge 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 typedef std::map<invalidation::ObjectId,
31 SyncNotifierObserver*,
32 ObjectIdLessThan> ObjectIdObserverMap;
33
34 // Updates the mapping of object IDs to observers and returns all the keys,
35 // e.g. object IDs, that are currently in the map.
36 ObjectIdSet UpdateObjectIdObserverMap();
37
38 // Helper that sorts incoming invalidations into a bucket for each observer
39 // and then dispatches the batched invalidations to each respective observer.
40 void DispatchInvalidationsToObservers(const ObjectIdPayloadMap& id_payloads,
41 IncomingNotificationSource source);
42
43 // Note that this is non-const because FOR_EACH_OBSERVER() may mutate the
44 // original observer list.
45 ObserverList<SyncNotifierObserver>& observers() { return observers_; }
46
47 private:
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