| 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); |
| 123 state_ = state; | 124 state_ = state; |
| 124 FOR_EACH_OBSERVER(InvalidationHandler, handlers_, | 125 FOR_EACH_OBSERVER(InvalidationHandler, handlers_, |
| 125 OnInvalidatorStateChange(state)); | 126 OnInvalidatorStateChange(state)); |
| 126 } | 127 } |
| 127 | 128 |
| 128 InvalidatorState InvalidatorRegistrar::GetInvalidatorState() const { | 129 InvalidatorState InvalidatorRegistrar::GetInvalidatorState() const { |
| 129 DCHECK(thread_checker_.CalledOnValidThread()); | 130 DCHECK(thread_checker_.CalledOnValidThread()); |
| 130 return state_; | 131 return state_; |
| 131 } | 132 } |
| 132 | 133 |
| 133 bool InvalidatorRegistrar::IsHandlerRegisteredForTest( | 134 bool InvalidatorRegistrar::IsHandlerRegisteredForTest( |
| 134 InvalidationHandler* handler) const { | 135 InvalidationHandler* handler) const { |
| 135 DCHECK(thread_checker_.CalledOnValidThread()); | 136 DCHECK(thread_checker_.CalledOnValidThread()); |
| 136 return handlers_.HasObserver(handler); | 137 return handlers_.HasObserver(handler); |
| 137 } | 138 } |
| 138 | 139 |
| 139 void InvalidatorRegistrar::DetachFromThreadForTest() { | 140 void InvalidatorRegistrar::DetachFromThreadForTest() { |
| 140 DCHECK(thread_checker_.CalledOnValidThread()); | 141 DCHECK(thread_checker_.CalledOnValidThread()); |
| 141 thread_checker_.DetachFromThread(); | 142 thread_checker_.DetachFromThread(); |
| 142 } | 143 } |
| 143 | 144 |
| 144 InvalidationHandler* InvalidatorRegistrar::ObjectIdToHandler( | 145 InvalidationHandler* InvalidatorRegistrar::ObjectIdToHandler( |
| 145 const invalidation::ObjectId& id) { | 146 const invalidation::ObjectId& id) { |
| 146 DCHECK(thread_checker_.CalledOnValidThread()); | 147 DCHECK(thread_checker_.CalledOnValidThread()); |
| 147 IdHandlerMap::const_iterator it = id_to_handler_map_.find(id); | 148 IdHandlerMap::const_iterator it = id_to_handler_map_.find(id); |
| 148 return (it == id_to_handler_map_.end()) ? NULL : it->second; | 149 return (it == id_to_handler_map_.end()) ? NULL : it->second; |
| 149 } | 150 } |
| 150 | 151 |
| 151 } // namespace syncer | 152 } // namespace syncer |
| OLD | NEW |