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

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
« no previous file with comments | « chrome/service/service_process_prefs.h ('k') | chrome/service/service_process_prefs_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e1aca1a1f7abe99d8f503be362b5858fb41cc902 100644
--- a/chrome/service/service_process_prefs.cc
+++ b/chrome/service/service_process_prefs.cc
@@ -22,11 +22,16 @@ 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_value) 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_value;
+ }
+ return result;
}
void ServiceProcessPrefs::SetString(const std::string& key,
@@ -34,28 +39,44 @@ 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_value) 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_value;
+ }
+ 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;
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);
}
+
« no previous file with comments | « chrome/service/service_process_prefs.h ('k') | chrome/service/service_process_prefs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698