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 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 DCHECK(thread_checker_.CalledOnValidThread()); | 86 DCHECK(thread_checker_.CalledOnValidThread()); |
87 | 87 |
88 // Only send notifications for registered preferences. | 88 // Only send notifications for registered preferences. |
89 if (!pref_service_->FindPreference(path)) | 89 if (!pref_service_->FindPreference(path)) |
90 return; | 90 return; |
91 | 91 |
92 auto observer_iterator = pref_observers_.find(path); | 92 auto observer_iterator = pref_observers_.find(path); |
93 if (observer_iterator == pref_observers_.end()) | 93 if (observer_iterator == pref_observers_.end()) |
94 return; | 94 return; |
95 | 95 |
96 FOR_EACH_OBSERVER(PrefObserver, | 96 for (PrefObserver& observer : *(observer_iterator->second)) |
97 *(observer_iterator->second), | 97 observer.OnPreferenceChanged(pref_service_, path); |
98 OnPreferenceChanged(pref_service_, path)); | |
99 } | 98 } |
100 | 99 |
101 void PrefNotifierImpl::SetPrefService(PrefService* pref_service) { | 100 void PrefNotifierImpl::SetPrefService(PrefService* pref_service) { |
102 DCHECK(pref_service_ == nullptr); | 101 DCHECK(pref_service_ == nullptr); |
103 pref_service_ = pref_service; | 102 pref_service_ = pref_service; |
104 } | 103 } |
OLD | NEW |