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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 InvalidationHandler* handler = NULL; | 112 InvalidationHandler* handler = NULL; |
113 while ((handler = it.GetNext()) != NULL) { | 113 while ((handler = it.GetNext()) != NULL) { |
114 DispatchMap::const_iterator dispatch_it = dispatch_map.find(handler); | 114 DispatchMap::const_iterator dispatch_it = dispatch_map.find(handler); |
115 if (dispatch_it != dispatch_map.end()) | 115 if (dispatch_it != dispatch_map.end()) |
116 handler->OnIncomingInvalidation(dispatch_it->second); | 116 handler->OnIncomingInvalidation(dispatch_it->second); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 void InvalidatorRegistrar::UpdateInvalidatorState(InvalidatorState state) { | 120 void InvalidatorRegistrar::UpdateInvalidatorState(InvalidatorState state) { |
121 DCHECK(thread_checker_.CalledOnValidThread()); | 121 DCHECK(thread_checker_.CalledOnValidThread()); |
122 DVLOG(1) << "New invalidator state: " << InvalidatorStateToString(state_) | 122 DVLOG(1) << "New invalidator state: " << InvalidatorStateToString(state_); |
123 << " -> " << InvalidatorStateToString(state); | |
124 state_ = state; | 123 state_ = state; |
125 FOR_EACH_OBSERVER(InvalidationHandler, handlers_, | 124 FOR_EACH_OBSERVER(InvalidationHandler, handlers_, |
126 OnInvalidatorStateChange(state)); | 125 OnInvalidatorStateChange(state)); |
127 } | 126 } |
128 | 127 |
129 InvalidatorState InvalidatorRegistrar::GetInvalidatorState() const { | 128 InvalidatorState InvalidatorRegistrar::GetInvalidatorState() const { |
130 DCHECK(thread_checker_.CalledOnValidThread()); | 129 DCHECK(thread_checker_.CalledOnValidThread()); |
131 return state_; | 130 return state_; |
132 } | 131 } |
133 | 132 |
134 bool InvalidatorRegistrar::IsHandlerRegisteredForTest( | 133 bool InvalidatorRegistrar::IsHandlerRegisteredForTest( |
135 InvalidationHandler* handler) const { | 134 InvalidationHandler* handler) const { |
136 DCHECK(thread_checker_.CalledOnValidThread()); | 135 DCHECK(thread_checker_.CalledOnValidThread()); |
137 return handlers_.HasObserver(handler); | 136 return handlers_.HasObserver(handler); |
138 } | 137 } |
139 | 138 |
140 void InvalidatorRegistrar::DetachFromThreadForTest() { | 139 void InvalidatorRegistrar::DetachFromThreadForTest() { |
141 DCHECK(thread_checker_.CalledOnValidThread()); | 140 DCHECK(thread_checker_.CalledOnValidThread()); |
142 thread_checker_.DetachFromThread(); | 141 thread_checker_.DetachFromThread(); |
143 } | 142 } |
144 | 143 |
145 InvalidationHandler* InvalidatorRegistrar::ObjectIdToHandler( | 144 InvalidationHandler* InvalidatorRegistrar::ObjectIdToHandler( |
146 const invalidation::ObjectId& id) { | 145 const invalidation::ObjectId& id) { |
147 DCHECK(thread_checker_.CalledOnValidThread()); | 146 DCHECK(thread_checker_.CalledOnValidThread()); |
148 IdHandlerMap::const_iterator it = id_to_handler_map_.find(id); | 147 IdHandlerMap::const_iterator it = id_to_handler_map_.find(id); |
149 return (it == id_to_handler_map_.end()) ? NULL : it->second; | 148 return (it == id_to_handler_map_.end()) ? NULL : it->second; |
150 } | 149 } |
151 | 150 |
152 } // namespace syncer | 151 } // namespace syncer |
OLD | NEW |