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 "base/prefs/pref_notifier_impl.h" | 5 #include "base/prefs/pref_notifier_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 | 68 |
69 PrefObserverList* observer_list = observer_iterator->second; | 69 PrefObserverList* observer_list = observer_iterator->second; |
70 observer_list->RemoveObserver(obs); | 70 observer_list->RemoveObserver(obs); |
71 } | 71 } |
72 | 72 |
73 void PrefNotifierImpl::AddInitObserver(base::Callback<void(bool)> obs) { | 73 void PrefNotifierImpl::AddInitObserver(base::Callback<void(bool)> obs) { |
74 init_observers_.push_back(obs); | 74 init_observers_.push_back(obs); |
75 } | 75 } |
76 | 76 |
| 77 // TODO(battre): Delete this. See crbug.com/373435. |
| 78 void PrefNotifierImpl::SetPrefServiceDestructionTrace( |
| 79 const std::string& stacktrace) { |
| 80 DCHECK(thread_checker_.CalledOnValidThread()); |
| 81 for (PrefObserverMap::iterator observer_iterator = pref_observers_.begin(); |
| 82 observer_iterator != pref_observers_.end(); |
| 83 ++observer_iterator) { |
| 84 FOR_EACH_OBSERVER(PrefObserver, |
| 85 *(observer_iterator->second), |
| 86 SetPrefServiceDestructionTrace(stacktrace)); |
| 87 } |
| 88 } |
| 89 |
77 void PrefNotifierImpl::OnPreferenceChanged(const std::string& path) { | 90 void PrefNotifierImpl::OnPreferenceChanged(const std::string& path) { |
78 FireObservers(path); | 91 FireObservers(path); |
79 } | 92 } |
80 | 93 |
81 void PrefNotifierImpl::OnInitializationCompleted(bool succeeded) { | 94 void PrefNotifierImpl::OnInitializationCompleted(bool succeeded) { |
82 DCHECK(thread_checker_.CalledOnValidThread()); | 95 DCHECK(thread_checker_.CalledOnValidThread()); |
83 | 96 |
84 // We must make a copy of init_observers_ and clear it before we run | 97 // We must make a copy of init_observers_ and clear it before we run |
85 // observers, or we can end up in this method re-entrantly before | 98 // observers, or we can end up in this method re-entrantly before |
86 // clearing the observers list. | 99 // clearing the observers list. |
(...skipping 21 matching lines...) Expand all Loading... |
108 | 121 |
109 FOR_EACH_OBSERVER(PrefObserver, | 122 FOR_EACH_OBSERVER(PrefObserver, |
110 *(observer_iterator->second), | 123 *(observer_iterator->second), |
111 OnPreferenceChanged(pref_service_, path)); | 124 OnPreferenceChanged(pref_service_, path)); |
112 } | 125 } |
113 | 126 |
114 void PrefNotifierImpl::SetPrefService(PrefService* pref_service) { | 127 void PrefNotifierImpl::SetPrefService(PrefService* pref_service) { |
115 DCHECK(pref_service_ == NULL); | 128 DCHECK(pref_service_ == NULL); |
116 pref_service_ = pref_service; | 129 pref_service_ = pref_service; |
117 } | 130 } |
OLD | NEW |