Chromium Code Reviews| Index: chrome/browser/prefs/pref_service.cc |
| diff --git a/chrome/browser/prefs/pref_service.cc b/chrome/browser/prefs/pref_service.cc |
| index cca8041c850284e277887d6be536316148ee68bd..79068885668c085549c03f1d0de2107545b796d2 100644 |
| --- a/chrome/browser/prefs/pref_service.cc |
| +++ b/chrome/browser/prefs/pref_service.cc |
| @@ -471,6 +471,15 @@ void PrefService::RegisterStringPref(const char* path, |
| sync_status); |
| } |
| +void PrefService::RegisterStringPrefIfNew(const char* path, |
| + const std::string& default_value, |
| + PrefSyncStatus sync_status) { |
| + DCHECK(IsProfilePrefService(this)); |
| + RegisterPreferenceIfNew(path, |
| + Value::CreateStringValue(default_value), |
| + sync_status); |
| + } |
| + |
| void PrefService::RegisterFilePathPref(const char* path, |
| const FilePath& default_value, |
| PrefSyncStatus sync_status) { |
| @@ -779,19 +788,17 @@ void PrefService::RemovePrefObserver(const char* path, |
| pref_notifier_->RemovePrefObserver(path, obs); |
| } |
| -void PrefService::RegisterPreference(const char* path, |
| - Value* default_value, |
| - PrefSyncStatus sync_status) { |
| +void PrefService::RegisterNewPreference(const char* path, |
| + Value* default_value, |
| + PrefSyncStatus sync_status) { |
| + // Note: The perfomance of this method is critical to startup performance, |
| + // at least on Android, so do not introduce extra checks unless they are |
| + // compiled out of official builds. |
| DCHECK(CalledOnValidThread()); |
| // The main code path takes ownership, but most don't. We'll be safe. |
| scoped_ptr<Value> scoped_value(default_value); |
| - if (FindPreference(path)) { |
| - NOTREACHED() << "Tried to register duplicate pref " << path; |
|
Bernhard Bauer
2012/10/30 14:34:16
Seeing as this is just a NOTREACHED (which would i
|
| - return; |
| - } |
| - |
| base::Value::Type orig_type = default_value->GetType(); |
| DCHECK(orig_type != Value::TYPE_NULL && orig_type != Value::TYPE_BINARY) << |
| "invalid preference type: " << orig_type; |
| @@ -821,6 +828,27 @@ void PrefService::RegisterPreference(const char* path, |
| pref_sync_associator_->RegisterPref(path); |
| } |
| +void PrefService::RegisterPreference(const char* path, |
| + Value* default_value, |
| + PrefSyncStatus sync_status) { |
| + if (default_store_->GetType(path) != Value::TYPE_NULL) { |
| + // Preference already exists |
| + NOTREACHED() << "Tried to register duplicate pref " << path; |
| + return; |
| + } |
| + RegisterNewPreference(path, default_value, sync_status); |
| +} |
| + |
| +void PrefService::RegisterPreferenceIfNew(const char* path, |
| + Value* default_value, |
| + PrefSyncStatus sync_status) { |
| + if (default_store_->GetType(path) != Value::TYPE_NULL) { |
| + // Preference already exists |
| + return; |
| + } |
| + RegisterNewPreference(path, default_value, sync_status); |
| +} |
| + |
| void PrefService::UnregisterPreference(const char* path) { |
| DCHECK(CalledOnValidThread()); |