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" |
11 | 11 |
12 namespace syncer { | 12 namespace syncer { |
13 | 13 |
14 InvalidatorRegistrar::InvalidatorRegistrar() | 14 InvalidatorRegistrar::InvalidatorRegistrar() |
15 : state_(DEFAULT_INVALIDATION_ERROR) {} | 15 : state_(DEFAULT_INVALIDATION_ERROR) {} |
16 | 16 |
17 InvalidatorRegistrar::~InvalidatorRegistrar() { | 17 InvalidatorRegistrar::~InvalidatorRegistrar() { |
18 DCHECK(thread_checker_.CalledOnValidThread()); | 18 DCHECK(thread_checker_.CalledOnValidThread()); |
| 19 CHECK(!handlers_.might_have_observers()); |
| 20 // |id_to_handler_map_| may be non-empty but that's okay. |
19 } | 21 } |
20 | 22 |
21 void InvalidatorRegistrar::RegisterHandler(InvalidationHandler* handler) { | 23 void InvalidatorRegistrar::RegisterHandler(InvalidationHandler* handler) { |
22 DCHECK(thread_checker_.CalledOnValidThread()); | 24 DCHECK(thread_checker_.CalledOnValidThread()); |
23 CHECK(handler); | 25 CHECK(handler); |
24 CHECK(!handlers_.HasObserver(handler)); | 26 CHECK(!handlers_.HasObserver(handler)); |
25 handlers_.AddObserver(handler); | 27 handlers_.AddObserver(handler); |
26 } | 28 } |
27 | 29 |
28 void InvalidatorRegistrar::UpdateRegisteredIds( | 30 void InvalidatorRegistrar::UpdateRegisteredIds( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 } | 142 } |
141 | 143 |
142 InvalidationHandler* InvalidatorRegistrar::ObjectIdToHandler( | 144 InvalidationHandler* InvalidatorRegistrar::ObjectIdToHandler( |
143 const invalidation::ObjectId& id) { | 145 const invalidation::ObjectId& id) { |
144 DCHECK(thread_checker_.CalledOnValidThread()); | 146 DCHECK(thread_checker_.CalledOnValidThread()); |
145 IdHandlerMap::const_iterator it = id_to_handler_map_.find(id); | 147 IdHandlerMap::const_iterator it = id_to_handler_map_.find(id); |
146 return (it == id_to_handler_map_.end()) ? NULL : it->second; | 148 return (it == id_to_handler_map_.end()) ? NULL : it->second; |
147 } | 149 } |
148 | 150 |
149 } // namespace syncer | 151 } // namespace syncer |
OLD | NEW |