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

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

Issue 10874096: [Sync] Rework Invalidator-related unit tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 3 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
« no previous file with comments | « sync/notifier/invalidator.h ('k') | sync/notifier/invalidator_registrar.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 26 matching lines...) Expand all
37 // not be NULL, and must already be registered. An ID must be registered for 37 // not be NULL, and must already be registered. An ID must be registered for
38 // at most one handler. 38 // at most one handler.
39 void UpdateRegisteredIds(InvalidationHandler* handler, 39 void UpdateRegisteredIds(InvalidationHandler* handler,
40 const ObjectIdSet& ids); 40 const ObjectIdSet& ids);
41 41
42 // Stops sending notifications to |handler|. |handler| must not be NULL, and 42 // Stops sending notifications to |handler|. |handler| must not be NULL, and
43 // it must already be registered. Note that this doesn't unregister the IDs 43 // it must already be registered. Note that this doesn't unregister the IDs
44 // associated with |handler|. 44 // associated with |handler|.
45 void UnregisterHandler(InvalidationHandler* handler); 45 void UnregisterHandler(InvalidationHandler* handler);
46 46
47 ObjectIdSet GetRegisteredIds(InvalidationHandler* handler) const;
48
47 // Returns the set of all IDs that are registered to some handler (even 49 // Returns the set of all IDs that are registered to some handler (even
48 // handlers that have been unregistered). 50 // handlers that have been unregistered).
49 ObjectIdSet GetAllRegisteredIds() const; 51 ObjectIdSet GetAllRegisteredIds() const;
50 52
51 // Sorts incoming invalidations into a bucket for each handler and then 53 // Sorts incoming invalidations into a bucket for each handler and then
52 // dispatches the batched invalidations to the corresponding handler. 54 // dispatches the batched invalidations to the corresponding handler.
53 // Invalidations for IDs with no corresponding handler are dropped, as are 55 // Invalidations for IDs with no corresponding handler are dropped, as are
54 // invalidations for handlers that are not added. 56 // invalidations for handlers that are not added.
55 void DispatchInvalidationsToHandlers(const ObjectIdStateMap& id_state_map, 57 void DispatchInvalidationsToHandlers(const ObjectIdStateMap& id_state_map,
56 IncomingNotificationSource source); 58 IncomingNotificationSource source);
57 59
58 // Calls the given handler method for each handler that has registered IDs. 60 // Calls the given handler method for each handler that has registered IDs.
59 void EmitOnNotificationsEnabled(); 61 void EmitOnNotificationsEnabled();
60 void EmitOnNotificationsDisabled(NotificationsDisabledReason reason); 62 void EmitOnNotificationsDisabled(NotificationsDisabledReason reason);
61 63
62 bool IsHandlerRegisteredForTest(InvalidationHandler* handler) const; 64 bool IsHandlerRegisteredForTest(InvalidationHandler* handler) const;
63 ObjectIdSet GetRegisteredIdsForTest(InvalidationHandler* handler) const;
64 65
65 // Needed for death tests. 66 // Needed for death tests.
66 void DetachFromThreadForTest(); 67 void DetachFromThreadForTest();
67 68
68 private: 69 private:
69 typedef std::map<invalidation::ObjectId, InvalidationHandler*, 70 typedef std::map<invalidation::ObjectId, InvalidationHandler*,
70 ObjectIdLessThan> 71 ObjectIdLessThan>
71 IdHandlerMap; 72 IdHandlerMap;
72 73
73 InvalidationHandler* ObjectIdToHandler(const invalidation::ObjectId& id); 74 InvalidationHandler* ObjectIdToHandler(const invalidation::ObjectId& id);
74 75
75 base::ThreadChecker thread_checker_; 76 base::ThreadChecker thread_checker_;
76 ObserverList<InvalidationHandler> handlers_; 77 ObserverList<InvalidationHandler> handlers_;
77 IdHandlerMap id_to_handler_map_; 78 IdHandlerMap id_to_handler_map_;
78 79
79 DISALLOW_COPY_AND_ASSIGN(InvalidatorRegistrar); 80 DISALLOW_COPY_AND_ASSIGN(InvalidatorRegistrar);
80 }; 81 };
81 82
82 } // namespace syncer 83 } // namespace syncer
83 84
84 #endif // SYNC_NOTIFIER_INVALIDATOR_REGISTRAR_H_ 85 #endif // SYNC_NOTIFIER_INVALIDATOR_REGISTRAR_H_
OLDNEW
« no previous file with comments | « sync/notifier/invalidator.h ('k') | sync/notifier/invalidator_registrar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698