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 "components/prefs/pref_notifier_impl.h" | 5 #include "components/prefs/pref_notifier_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "components/prefs/pref_service.h" | 9 #include "components/prefs/pref_service.h" |
10 | 10 |
11 PrefNotifierImpl::PrefNotifierImpl() : pref_service_(nullptr) {} | 11 PrefNotifierImpl::PrefNotifierImpl() : pref_service_(nullptr) {} |
12 | 12 |
13 PrefNotifierImpl::PrefNotifierImpl(PrefService* service) | 13 PrefNotifierImpl::PrefNotifierImpl(PrefService* service) |
14 : pref_service_(service) { | 14 : pref_service_(service) { |
15 } | 15 } |
16 | 16 |
17 PrefNotifierImpl::~PrefNotifierImpl() { | 17 PrefNotifierImpl::~PrefNotifierImpl() { |
18 DCHECK(thread_checker_.CalledOnValidThread()); | 18 DCHECK(thread_checker_.CalledOnValidThread()); |
19 | 19 |
20 // Verify that there are no pref observers when we shut down. | 20 // Verify that there are no pref observers when we shut down. |
21 for (const auto& observer_list : pref_observers_) { | 21 for (const auto& observer_list : pref_observers_) { |
22 PrefObserverList::Iterator obs_iterator(observer_list.second.get()); | 22 if (observer_list.second->begin() != observer_list.second->end()) |
Pam (message me for reviews)
2016/10/14 20:35:26
Why not observer_list.second->size() ?
dcheng
2016/10/14 20:38:40
size() isn't exposed by ObserverList. Since Observ
| |
23 if (obs_iterator.GetNext()) { | |
24 LOG(WARNING) << "Pref observer found at shutdown."; | 23 LOG(WARNING) << "Pref observer found at shutdown."; |
25 } | |
26 } | 24 } |
27 | 25 |
28 // Same for initialization observers. | 26 // Same for initialization observers. |
29 if (!init_observers_.empty()) | 27 if (!init_observers_.empty()) |
30 LOG(WARNING) << "Init observer found at shutdown."; | 28 LOG(WARNING) << "Init observer found at shutdown."; |
31 | 29 |
32 pref_observers_.clear(); | 30 pref_observers_.clear(); |
33 init_observers_.clear(); | 31 init_observers_.clear(); |
34 } | 32 } |
35 | 33 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 | 95 |
98 FOR_EACH_OBSERVER(PrefObserver, | 96 FOR_EACH_OBSERVER(PrefObserver, |
99 *(observer_iterator->second), | 97 *(observer_iterator->second), |
100 OnPreferenceChanged(pref_service_, path)); | 98 OnPreferenceChanged(pref_service_, path)); |
101 } | 99 } |
102 | 100 |
103 void PrefNotifierImpl::SetPrefService(PrefService* pref_service) { | 101 void PrefNotifierImpl::SetPrefService(PrefService* pref_service) { |
104 DCHECK(pref_service_ == nullptr); | 102 DCHECK(pref_service_ == nullptr); |
105 pref_service_ = pref_service; | 103 pref_service_ = pref_service; |
106 } | 104 } |
OLD | NEW |