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

Unified Diff: base/prefs/pref_change_registrar.cc

Issue 753603002: Change preference APIs to take std::string instead of const char*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed all calls to c_str() in prefs. Created 6 years 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
« no previous file with comments | « base/prefs/pref_change_registrar.h ('k') | base/prefs/pref_change_registrar_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/prefs/pref_change_registrar.cc
diff --git a/base/prefs/pref_change_registrar.cc b/base/prefs/pref_change_registrar.cc
index 28ac37403435f7428670cc032f6f603e7f6ecda6..13193484ff449c348be51f94d35474968ae7efe7 100644
--- a/base/prefs/pref_change_registrar.cc
+++ b/base/prefs/pref_change_registrar.cc
@@ -23,12 +23,12 @@ void PrefChangeRegistrar::Init(PrefService* service) {
service_ = service;
}
-void PrefChangeRegistrar::Add(const char* path,
+void PrefChangeRegistrar::Add(const std::string& path,
const base::Closure& obs) {
Add(path, base::Bind(&PrefChangeRegistrar::InvokeUnnamedCallback, obs));
}
-void PrefChangeRegistrar::Add(const char* path,
+void PrefChangeRegistrar::Add(const std::string& path,
const NamedChangeCallback& obs) {
if (!service_) {
NOTREACHED();
@@ -40,7 +40,7 @@ void PrefChangeRegistrar::Add(const char* path,
observers_[path] = obs;
}
-void PrefChangeRegistrar::Remove(const char* path) {
+void PrefChangeRegistrar::Remove(const std::string& path) {
DCHECK(IsObserved(path));
observers_.erase(path);
@@ -50,7 +50,7 @@ void PrefChangeRegistrar::Remove(const char* path) {
void PrefChangeRegistrar::RemoveAll() {
for (ObserverMap::const_iterator it = observers_.begin();
it != observers_.end(); ++it) {
- service_->RemovePrefObserver(it->first.c_str(), this);
+ service_->RemovePrefObserver(it->first, this);
}
observers_.clear();
@@ -67,8 +67,7 @@ bool PrefChangeRegistrar::IsObserved(const std::string& pref) {
bool PrefChangeRegistrar::IsManaged() {
for (ObserverMap::const_iterator it = observers_.begin();
it != observers_.end(); ++it) {
- const PrefService::Preference* pref =
- service_->FindPreference(it->first.c_str());
+ const PrefService::Preference* pref = service_->FindPreference(it->first);
if (pref && pref->IsManaged())
return true;
}
« no previous file with comments | « base/prefs/pref_change_registrar.h ('k') | base/prefs/pref_change_registrar_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698