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

Unified Diff: chrome/browser/prefs/pref_service.cc

Issue 11307005: Improve performance of registering font preferences (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Removed redundant enum, left over from earlier version of code. Created 8 years, 2 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/browser/prefs/pref_service.h ('k') | chrome/browser/ui/prefs/prefs_tab_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « chrome/browser/prefs/pref_service.h ('k') | chrome/browser/ui/prefs/prefs_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698