Prefs is meant to store lightweight state that reflects user preferences (e.g. chrome://settings, position of windows on last exit, etc.). Browser-wide prefs are stored in Local State (g_browser_process->local_state()
) and per-profile prefs are stored in Preferences (Profile::GetPrefs()
). The base::PrefService
API is used to read/write registered prefs. Prefs are saved as JSON and any modification forces serialization of the entire JSON dictionary. The LOSSY_PREF
flag can be used when registering a pref to indicate that modifications to it shouldn't schedule a write (in which case the write will be bundled with the next change that does schedule a write or wait until the final write on shutdown; the update is lost in case of a crash).
Prefs are not for:
LOSSY_PREF
flag)pref_names.cc
local to your component (typically inside a prefs::
C++ namespace nested in your component's namespace)