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

Unified Diff: base/prefs/public/pref_change_registrar.cc

Issue 11368098: Draft change to use base::Closure instead of PrefObserver in PrefChangeRegistrar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: base/prefs/public/pref_change_registrar.cc
diff --git a/base/prefs/public/pref_change_registrar.cc b/base/prefs/public/pref_change_registrar.cc
index 3f94b044d8633e0a007bfe196287b9eb3b0b1a1f..1bd3d1aa2f17fc5ff9ffe705fc527751dbb79071 100644
--- a/base/prefs/public/pref_change_registrar.cc
+++ b/base/prefs/public/pref_change_registrar.cc
@@ -4,7 +4,9 @@
#include "base/prefs/public/pref_change_registrar.h"
+#include "base/bind.h"
#include "base/logging.h"
+#include "base/prefs/public/pref_observer.h"
#include "base/prefs/public/pref_service_base.h"
PrefChangeRegistrar::PrefChangeRegistrar() : service_(NULL) {}
@@ -23,6 +25,11 @@ void PrefChangeRegistrar::Init(PrefServiceBase* service) {
}
void PrefChangeRegistrar::Add(const char* path, PrefObserver* obs) {
+ return Add(path, base::Bind(&PrefObserver::OnPreferenceChanged,
+ base::Unretained(obs), service_, path));
+}
+
+void PrefChangeRegistrar::Add(const char* path, const base::Closure& obs) {
if (!service_) {
NOTREACHED();
return;
@@ -37,6 +44,14 @@ void PrefChangeRegistrar::Add(const char* path, PrefObserver* obs) {
}
void PrefChangeRegistrar::Remove(const char* path, PrefObserver* obs) {
+ // Need to bind the callback the exact same way, although it will
+ // never be called, so that it matches the callback bound via
+ // AddPrefObserver.
+ return Remove(path, base::Bind(&PrefObserver::OnPreferenceChanged,
+ base::Unretained(obs), service_, path));
Mattias Nissler (ping if slow) 2012/11/06 13:26:48 Hm, comparing callbacks... not sure whether that's
+}
+
+void PrefChangeRegistrar::Remove(const char* path, const base::Closure& obs) {
if (!service_) {
NOTREACHED();
return;

Powered by Google App Engine
This is Rietveld 408576698