From 5b7238f3b28df82e39b5b7d773a78e6e0f88f055 Mon Sep 17 00:00:00 2001 From: "tfarina@chromium.org" Date: Mon, 22 Apr 2013 15:56:40 +0000 Subject: base/prefs: Make use of ThreadCheck in favor of less inheritance. TEST=base_unittests --gtest_filter=*Prefs* R=mnissler@chromium.org,joi@chromium.org Review URL: https://chromiumcodereview.appspot.com/14393002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195517 0039d316-1c4b-4281-b951-d872f2087c98 --- base/prefs/pref_notifier_impl.cc | 8 ++++---- base/prefs/pref_notifier_impl.h | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'base/prefs') diff --git a/base/prefs/pref_notifier_impl.cc b/base/prefs/pref_notifier_impl.cc index 1fa495d..c02a7b3 100644 --- a/base/prefs/pref_notifier_impl.cc +++ b/base/prefs/pref_notifier_impl.cc @@ -17,7 +17,7 @@ PrefNotifierImpl::PrefNotifierImpl(PrefService* service) } PrefNotifierImpl::~PrefNotifierImpl() { - DCHECK(CalledOnValidThread()); + DCHECK(thread_checker_.CalledOnValidThread()); // Verify that there are no pref observers when we shut down. for (PrefObserverMap::iterator it = pref_observers_.begin(); @@ -58,7 +58,7 @@ void PrefNotifierImpl::AddPrefObserver(const char* path, void PrefNotifierImpl::RemovePrefObserver(const char* path, PrefObserver* obs) { - DCHECK(CalledOnValidThread()); + DCHECK(thread_checker_.CalledOnValidThread()); const PrefObserverMap::iterator observer_iterator = pref_observers_.find(path); @@ -79,7 +79,7 @@ void PrefNotifierImpl::OnPreferenceChanged(const std::string& path) { } void PrefNotifierImpl::OnInitializationCompleted(bool succeeded) { - DCHECK(CalledOnValidThread()); + DCHECK(thread_checker_.CalledOnValidThread()); // We must make a copy of init_observers_ and clear it before we run // observers, or we can end up in this method re-entrantly before @@ -95,7 +95,7 @@ void PrefNotifierImpl::OnInitializationCompleted(bool succeeded) { } void PrefNotifierImpl::FireObservers(const std::string& path) { - DCHECK(CalledOnValidThread()); + DCHECK(thread_checker_.CalledOnValidThread()); // Only send notifications for registered preferences. if (!pref_service_->FindPreference(path.c_str())) diff --git a/base/prefs/pref_notifier_impl.h b/base/prefs/pref_notifier_impl.h index 8e6f090..8f5120a 100644 --- a/base/prefs/pref_notifier_impl.h +++ b/base/prefs/pref_notifier_impl.h @@ -15,14 +15,13 @@ #include "base/prefs/base_prefs_export.h" #include "base/prefs/pref_notifier.h" #include "base/prefs/pref_observer.h" -#include "base/threading/non_thread_safe.h" +#include "base/threading/thread_checker.h" class PrefService; // The PrefNotifier implementation used by the PrefService. class BASE_PREFS_EXPORT PrefNotifierImpl - : public NON_EXPORTED_BASE(PrefNotifier), - public base::NonThreadSafe { + : public NON_EXPORTED_BASE(PrefNotifier) { public: PrefNotifierImpl(); explicit PrefNotifierImpl(PrefService* pref_service); @@ -66,6 +65,8 @@ class BASE_PREFS_EXPORT PrefNotifierImpl PrefObserverMap pref_observers_; PrefInitObserverList init_observers_; + base::ThreadChecker thread_checker_; + DISALLOW_COPY_AND_ASSIGN(PrefNotifierImpl); }; -- cgit v1.1