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/invalidator_registrar.h" | 5 #include "sync/notifier/invalidator_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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 DCHECK(thread_checker_.CalledOnValidThread()); | 81 DCHECK(thread_checker_.CalledOnValidThread()); |
82 ObjectIdSet registered_ids; | 82 ObjectIdSet registered_ids; |
83 for (IdHandlerMap::const_iterator it = id_to_handler_map_.begin(); | 83 for (IdHandlerMap::const_iterator it = id_to_handler_map_.begin(); |
84 it != id_to_handler_map_.end(); ++it) { | 84 it != id_to_handler_map_.end(); ++it) { |
85 registered_ids.insert(it->first); | 85 registered_ids.insert(it->first); |
86 } | 86 } |
87 return registered_ids; | 87 return registered_ids; |
88 } | 88 } |
89 | 89 |
90 void InvalidatorRegistrar::DispatchInvalidationsToHandlers( | 90 void InvalidatorRegistrar::DispatchInvalidationsToHandlers( |
91 const ObjectIdStateMap& id_state_map, | 91 const ObjectIdInvalidationMap& invalidation_map, |
92 IncomingInvalidationSource source) { | 92 IncomingInvalidationSource source) { |
93 DCHECK(thread_checker_.CalledOnValidThread()); | 93 DCHECK(thread_checker_.CalledOnValidThread()); |
94 // If we have no handlers, there's nothing to do. | 94 // If we have no handlers, there's nothing to do. |
95 if (!handlers_.might_have_observers()) { | 95 if (!handlers_.might_have_observers()) { |
96 return; | 96 return; |
97 } | 97 } |
98 | 98 |
99 typedef std::map<InvalidationHandler*, ObjectIdStateMap> DispatchMap; | 99 typedef std::map<InvalidationHandler*, ObjectIdInvalidationMap> DispatchMap; |
100 DispatchMap dispatch_map; | 100 DispatchMap dispatch_map; |
101 for (ObjectIdStateMap::const_iterator it = id_state_map.begin(); | 101 for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin(); |
102 it != id_state_map.end(); ++it) { | 102 it != invalidation_map.end(); ++it) { |
103 InvalidationHandler* const handler = ObjectIdToHandler(it->first); | 103 InvalidationHandler* const handler = ObjectIdToHandler(it->first); |
104 // Filter out invalidations for IDs with no handler. | 104 // Filter out invalidations for IDs with no handler. |
105 if (handler) | 105 if (handler) |
106 dispatch_map[handler].insert(*it); | 106 dispatch_map[handler].insert(*it); |
107 } | 107 } |
108 | 108 |
109 // Emit invalidations only for handlers in |handlers_|. | 109 // Emit invalidations only for handlers in |handlers_|. |
110 ObserverListBase<InvalidationHandler>::Iterator it(handlers_); | 110 ObserverListBase<InvalidationHandler>::Iterator it(handlers_); |
111 InvalidationHandler* handler = NULL; | 111 InvalidationHandler* handler = NULL; |
112 while ((handler = it.GetNext()) != NULL) { | 112 while ((handler = it.GetNext()) != NULL) { |
(...skipping 27 matching lines...) Expand all Loading... |
140 } | 140 } |
141 | 141 |
142 InvalidationHandler* InvalidatorRegistrar::ObjectIdToHandler( | 142 InvalidationHandler* InvalidatorRegistrar::ObjectIdToHandler( |
143 const invalidation::ObjectId& id) { | 143 const invalidation::ObjectId& id) { |
144 DCHECK(thread_checker_.CalledOnValidThread()); | 144 DCHECK(thread_checker_.CalledOnValidThread()); |
145 IdHandlerMap::const_iterator it = id_to_handler_map_.find(id); | 145 IdHandlerMap::const_iterator it = id_to_handler_map_.find(id); |
146 return (it == id_to_handler_map_.end()) ? NULL : it->second; | 146 return (it == id_to_handler_map_.end()) ? NULL : it->second; |
147 } | 147 } |
148 | 148 |
149 } // namespace syncer | 149 } // namespace syncer |
OLD | NEW |