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

Unified Diff: chrome/service/service_process_prefs.cc

Issue 10958052: Removed unnecessary returning by reference. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/service/service_process_prefs.cc
diff --git a/chrome/service/service_process_prefs.cc b/chrome/service/service_process_prefs.cc
index b925e2bed8d6926cba7c8a365e6c75636048433d..38c0d507de3392604f88d8ef8dc89f3b67774a0d 100644
--- a/chrome/service/service_process_prefs.cc
+++ b/chrome/service/service_process_prefs.cc
@@ -22,11 +22,15 @@ void ServiceProcessPrefs::WritePrefs() {
prefs_->CommitPendingWrite();
}
-void ServiceProcessPrefs::GetString(const std::string& key,
- std::string* result) const {
+std::string ServiceProcessPrefs::GetString(const std::string& key,
+ const std::string& default) const {
const Value* value;
- if (prefs_->GetValue(key, &value) == PersistentPrefStore::READ_OK)
- value->GetAsString(result);
+ std::string result;
+ if (prefs_->GetValue(key, &value) != PersistentPrefStore::READ_OK ||
+ !value->GetAsString(&result)) {
+ return default;
+ }
+ return result;
}
void ServiceProcessPrefs::SetString(const std::string& key,
@@ -34,28 +38,45 @@ void ServiceProcessPrefs::SetString(const std::string& key,
prefs_->SetValue(key, Value::CreateStringValue(value));
}
-void ServiceProcessPrefs::GetBoolean(const std::string& key,
- bool* result) const {
+bool ServiceProcessPrefs::GetBoolean(const std::string& key,
+ bool default) const {
const Value* value;
- if (prefs_->GetValue(key, &value) == PersistentPrefStore::READ_OK)
- value->GetAsBoolean(result);
+ bool result = false;
+ if (prefs_->GetValue(key, &value) != PersistentPrefStore::READ_OK ||
+ !value->GetAsBoolean(&result)) {
+ return default;
+ }
+ return result;
}
void ServiceProcessPrefs::SetBoolean(const std::string& key, bool value) {
prefs_->SetValue(key, Value::CreateBooleanValue(value));
}
-void ServiceProcessPrefs::GetDictionary(const std::string& key,
- const DictionaryValue** result) const {
+const DictionaryValue* ServiceProcessPrefs::GetDictionary(
+ const std::string& key) const {
const Value* value;
+ const DictionaryValue* result = NULL;
if (prefs_->GetValue(key, &value) != PersistentPrefStore::READ_OK ||
!value->IsType(Value::TYPE_DICTIONARY)) {
- return;
+ return NULL;
}
- *result = static_cast<const DictionaryValue*>(value);
+ return static_cast<const DictionaryValue*>(value);
+}
+
+const base::ListValue* ServiceProcessPrefs::GetList(
+ const std::string& key) const {
+ const Value* value;
+ if (prefs_->GetValue(key, &value) != PersistentPrefStore::READ_OK ||
+ !value->IsType(Value::TYPE_LIST)) {
+ return NULL;
+ }
+
+ return static_cast<const ListValue*>(value);
}
void ServiceProcessPrefs::RemovePref(const std::string& key) {
prefs_->RemoveValue(key);
}
+
« chrome/service/cloud_print/connector_settings.cc ('K') | « chrome/service/service_process_prefs.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698