Change PrefStore::ReadResult to a boolean.
The third value in the enum (READ_USE_DEFAULT) isn't used anymore.
[email protected],[email protected],[email protected]
BUG=none
Review URL: https://chromiumcodereview.appspot.com/11365112
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166706 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/prefs/command_line_pref_store_unittest.cc b/chrome/browser/prefs/command_line_pref_store_unittest.cc
index bc1edb9..5d2c939 100644
--- a/chrome/browser/prefs/command_line_pref_store_unittest.cc
+++ b/chrome/browser/prefs/command_line_pref_store_unittest.cc
@@ -32,7 +32,7 @@
void VerifyProxyMode(ProxyPrefs::ProxyMode expected_mode) {
const Value* value = NULL;
- ASSERT_EQ(PrefStore::READ_OK, GetValue(prefs::kProxy, &value));
+ ASSERT_TRUE(GetValue(prefs::kProxy, &value));
ASSERT_EQ(Value::TYPE_DICTIONARY, value->GetType());
ProxyConfigDictionary dict(static_cast<const DictionaryValue*>(value));
ProxyPrefs::ProxyMode actual_mode;
@@ -43,8 +43,7 @@
void VerifySSLCipherSuites(const char* const* ciphers,
size_t cipher_count) {
const Value* value = NULL;
- ASSERT_EQ(PrefStore::READ_OK,
- GetValue(prefs::kCipherSuiteBlacklist, &value));
+ ASSERT_TRUE(GetValue(prefs::kCipherSuiteBlacklist, &value));
ASSERT_EQ(Value::TYPE_LIST, value->GetType());
const ListValue* list_value = static_cast<const ListValue*>(value);
ASSERT_EQ(cipher_count, list_value->GetSize());
@@ -68,8 +67,7 @@
scoped_refptr<CommandLinePrefStore> store = new CommandLinePrefStore(&cl);
const Value* actual = NULL;
- EXPECT_EQ(PrefStore::READ_OK,
- store->GetValue(prefs::kApplicationLocale, &actual));
+ EXPECT_TRUE(store->GetValue(prefs::kApplicationLocale, &actual));
std::string result;
EXPECT_TRUE(actual->GetAsString(&result));
EXPECT_EQ("hi-MOM", result);
@@ -93,8 +91,8 @@
scoped_refptr<CommandLinePrefStore> store = new CommandLinePrefStore(&cl);
const Value* actual = NULL;
- EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(unknown_bool, &actual));
- EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(unknown_string, &actual));
+ EXPECT_FALSE(store->GetValue(unknown_bool, &actual));
+ EXPECT_FALSE(store->GetValue(unknown_string, &actual));
}
// Tests a complex command line with multiple known and unknown switches.
@@ -108,13 +106,13 @@
new TestCommandLinePrefStore(&cl);
const Value* actual = NULL;
- EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(unknown_bool, &actual));
- EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(unknown_string, &actual));
+ EXPECT_FALSE(store->GetValue(unknown_bool, &actual));
+ EXPECT_FALSE(store->GetValue(unknown_string, &actual));
store->VerifyProxyMode(ProxyPrefs::MODE_FIXED_SERVERS);
const Value* value = NULL;
- ASSERT_EQ(PrefStore::READ_OK, store->GetValue(prefs::kProxy, &value));
+ ASSERT_TRUE(store->GetValue(prefs::kProxy, &value));
ASSERT_EQ(Value::TYPE_DICTIONARY, value->GetType());
ProxyConfigDictionary dict(static_cast<const DictionaryValue*>(value));
diff --git a/chrome/browser/prefs/pref_service.cc b/chrome/browser/prefs/pref_service.cc
index 1eb80b4..06d5b79 100644
--- a/chrome/browser/prefs/pref_service.cc
+++ b/chrome/browser/prefs/pref_service.cc
@@ -731,7 +731,7 @@
// Look for an existing preference in the user store. If it doesn't
// exist, return NULL.
base::Value* value = NULL;
- if (user_pref_store_->GetMutableValue(path, &value) != PrefStore::READ_OK)
+ if (!user_pref_store_->GetMutableValue(path, &value))
return NULL;
if (!value->IsType(pref->GetType())) {
@@ -746,7 +746,7 @@
DCHECK(CalledOnValidThread());
// Lookup the preference in the default store.
const base::Value* value = NULL;
- if (default_store_->GetValue(path, &value) != PrefStore::READ_OK) {
+ if (!default_store_->GetValue(path, &value)) {
NOTREACHED() << "Default value missing for pref: " << path;
return NULL;
}
@@ -789,7 +789,7 @@
// The main code path takes ownership, but most don't. We'll be safe.
scoped_ptr<Value> scoped_value(default_value);
- DCHECK(!FindPreference(path)) << "Tried to register duplicate pref " << path;
+ CHECK(!FindPreference(path)) << "Tried to register duplicate pref " << path;
base::Value::Type orig_type = default_value->GetType();
DCHECK(orig_type != Value::TYPE_NULL && orig_type != Value::TYPE_BINARY) <<
@@ -824,10 +824,8 @@
DCHECK(CalledOnValidThread());
PreferenceMap::iterator it = prefs_map_.find(path);
- if (it == prefs_map_.end()) {
- NOTREACHED() << "Trying to unregister an unregistered pref: " << path;
- return;
- }
+ CHECK(it != prefs_map_.end()) << "Trying to unregister an unregistered pref: "
+ << path;
prefs_map_.erase(it);
default_store_->RemoveDefaultValue(path);
@@ -932,7 +930,7 @@
// Look for an existing preference in the user store. If it doesn't
// exist or isn't the correct type, create a new user preference.
Value* value = NULL;
- if (user_pref_store_->GetMutableValue(path, &value) != PrefStore::READ_OK ||
+ if (!user_pref_store_->GetMutableValue(path, &value) ||
!value->IsType(type)) {
if (type == Value::TYPE_DICTIONARY) {
value = new DictionaryValue;
diff --git a/chrome/browser/prefs/pref_value_store.cc b/chrome/browser/prefs/pref_value_store.cc
index b023d8b3..7797077e 100644
--- a/chrome/browser/prefs/pref_value_store.cc
+++ b/chrome/browser/prefs/pref_value_store.cc
@@ -214,23 +214,11 @@
// Only return true if we find a value and it is the correct type, so stale
// values with the incorrect type will be ignored.
const PrefStore* store = GetPrefStore(static_cast<PrefStoreType>(store_type));
- if (store) {
- switch (store->GetValue(name, out_value)) {
- case PrefStore::READ_USE_DEFAULT:
- store = GetPrefStore(DEFAULT_STORE);
- if (!store || store->GetValue(name, out_value) != PrefStore::READ_OK) {
- *out_value = NULL;
- return false;
- }
- // Fall through...
- case PrefStore::READ_OK:
- return true;
- case PrefStore::READ_NO_VALUE:
- break;
- }
- }
+ if (store && store->GetValue(name, out_value))
+ return true;
- // No valid value found for the given preference name: set the return false.
+ // No valid value found for the given preference name: set the return value
+ // to false.
*out_value = NULL;
return false;
}