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 #include "sync/notifier/sync_notifier_registrar.h" | 5 #include "sync/notifier/sync_notifier_registrar.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 DCHECK(thread_checker_.CalledOnValidThread()); | 67 DCHECK(thread_checker_.CalledOnValidThread()); |
68 ObjectIdSet registered_ids; | 68 ObjectIdSet registered_ids; |
69 for (IdHandlerMap::const_iterator it = id_to_handler_map_.begin(); | 69 for (IdHandlerMap::const_iterator it = id_to_handler_map_.begin(); |
70 it != id_to_handler_map_.end(); ++it) { | 70 it != id_to_handler_map_.end(); ++it) { |
71 registered_ids.insert(it->first); | 71 registered_ids.insert(it->first); |
72 } | 72 } |
73 return registered_ids; | 73 return registered_ids; |
74 } | 74 } |
75 | 75 |
76 void SyncNotifierRegistrar::DispatchInvalidationsToHandlers( | 76 void SyncNotifierRegistrar::DispatchInvalidationsToHandlers( |
77 const ObjectIdPayloadMap& id_payloads, | 77 const ObjectIdStateMap& id_state_map, |
78 IncomingNotificationSource source) { | 78 IncomingNotificationSource source) { |
79 DCHECK(thread_checker_.CalledOnValidThread()); | 79 DCHECK(thread_checker_.CalledOnValidThread()); |
80 // If we have no handlers, there's nothing to do. | 80 // If we have no handlers, there's nothing to do. |
81 if (!handlers_.might_have_observers()) { | 81 if (!handlers_.might_have_observers()) { |
82 return; | 82 return; |
83 } | 83 } |
84 | 84 |
85 typedef std::map<SyncNotifierObserver*, ObjectIdPayloadMap> DispatchMap; | 85 typedef std::map<SyncNotifierObserver*, ObjectIdStateMap> DispatchMap; |
86 DispatchMap dispatch_map; | 86 DispatchMap dispatch_map; |
87 for (ObjectIdPayloadMap::const_iterator it = id_payloads.begin(); | 87 for (ObjectIdStateMap::const_iterator it = id_state_map.begin(); |
88 it != id_payloads.end(); ++it) { | 88 it != id_state_map.end(); ++it) { |
89 SyncNotifierObserver* const handler = ObjectIdToHandler(it->first); | 89 SyncNotifierObserver* const handler = ObjectIdToHandler(it->first); |
90 // Filter out invalidations for IDs with no handler. | 90 // Filter out invalidations for IDs with no handler. |
91 if (handler) | 91 if (handler) |
92 dispatch_map[handler].insert(*it); | 92 dispatch_map[handler].insert(*it); |
93 } | 93 } |
94 | 94 |
95 // Emit invalidations only for handlers in |handlers_|. | 95 // Emit invalidations only for handlers in |handlers_|. |
96 ObserverListBase<SyncNotifierObserver>::Iterator it(handlers_); | 96 ObserverListBase<SyncNotifierObserver>::Iterator it(handlers_); |
97 SyncNotifierObserver* handler = NULL; | 97 SyncNotifierObserver* handler = NULL; |
98 while ((handler = it.GetNext()) != NULL) { | 98 while ((handler = it.GetNext()) != NULL) { |
(...skipping 21 matching lines...) Expand all Loading... |
120 } | 120 } |
121 | 121 |
122 SyncNotifierObserver* SyncNotifierRegistrar::ObjectIdToHandler( | 122 SyncNotifierObserver* SyncNotifierRegistrar::ObjectIdToHandler( |
123 const invalidation::ObjectId& id) { | 123 const invalidation::ObjectId& id) { |
124 DCHECK(thread_checker_.CalledOnValidThread()); | 124 DCHECK(thread_checker_.CalledOnValidThread()); |
125 IdHandlerMap::const_iterator it = id_to_handler_map_.find(id); | 125 IdHandlerMap::const_iterator it = id_to_handler_map_.find(id); |
126 return (it == id_to_handler_map_.end()) ? NULL : it->second; | 126 return (it == id_to_handler_map_.end()) ? NULL : it->second; |
127 } | 127 } |
128 | 128 |
129 } // namespace syncer | 129 } // namespace syncer |
OLD | NEW |