Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: chrome/browser/prefs/pref_notifier_impl.cc

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/prefs/pref_notifier_impl.h" 5 #include "chrome/browser/prefs/pref_notifier_impl.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "chrome/browser/prefs/pref_service.h" 8 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/common/chrome_notification_types.h" 9 #include "chrome/common/chrome_notification_types.h"
10 #include "content/public/browser/notification_observer.h" 10 #include "content/public/browser/notification_observer.h"
11 #include "content/common/notification_service.h" 11 #include "content/public/browser/notification_service.h"
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(CalledOnValidThread()); 18 DCHECK(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 (PrefObserverMap::iterator it = pref_observers_.begin(); 21 for (PrefObserverMap::iterator it = pref_observers_.begin();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 observer_list->RemoveObserver(obs); 71 observer_list->RemoveObserver(obs);
72 } 72 }
73 73
74 void PrefNotifierImpl::OnPreferenceChanged(const std::string& path) { 74 void PrefNotifierImpl::OnPreferenceChanged(const std::string& path) {
75 FireObservers(path); 75 FireObservers(path);
76 } 76 }
77 77
78 void PrefNotifierImpl::OnInitializationCompleted(bool succeeded) { 78 void PrefNotifierImpl::OnInitializationCompleted(bool succeeded) {
79 DCHECK(CalledOnValidThread()); 79 DCHECK(CalledOnValidThread());
80 80
81 NotificationService::current()->Notify( 81 content::NotificationService::current()->Notify(
82 chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED, 82 chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED,
83 content::Source<PrefService>(pref_service_), 83 content::Source<PrefService>(pref_service_),
84 content::Details<bool>(&succeeded)); 84 content::Details<bool>(&succeeded));
85 } 85 }
86 86
87 void PrefNotifierImpl::FireObservers(const std::string& path) { 87 void PrefNotifierImpl::FireObservers(const std::string& path) {
88 DCHECK(CalledOnValidThread()); 88 DCHECK(CalledOnValidThread());
89 89
90 // Only send notifications for registered preferences. 90 // Only send notifications for registered preferences.
91 if (!pref_service_->FindPreference(path.c_str())) 91 if (!pref_service_->FindPreference(path.c_str()))
92 return; 92 return;
93 93
94 const PrefObserverMap::iterator observer_iterator = 94 const PrefObserverMap::iterator observer_iterator =
95 pref_observers_.find(path); 95 pref_observers_.find(path);
96 if (observer_iterator == pref_observers_.end()) 96 if (observer_iterator == pref_observers_.end())
97 return; 97 return;
98 98
99 NotificationObserverList::Iterator it(*(observer_iterator->second)); 99 NotificationObserverList::Iterator it(*(observer_iterator->second));
100 content::NotificationObserver* observer; 100 content::NotificationObserver* observer;
101 while ((observer = it.GetNext()) != NULL) { 101 while ((observer = it.GetNext()) != NULL) {
102 observer->Observe(chrome::NOTIFICATION_PREF_CHANGED, 102 observer->Observe(chrome::NOTIFICATION_PREF_CHANGED,
103 content::Source<PrefService>(pref_service_), 103 content::Source<PrefService>(pref_service_),
104 content::Details<const std::string>(&path)); 104 content::Details<const std::string>(&path));
105 } 105 }
106 } 106 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_model_associator.cc ('k') | chrome/browser/prefs/pref_notifier_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698