summaryrefslogtreecommitdiffstats
path: root/chrome/common/pref_service.cc
diff options
context:
space:
mode:
authorrobertshield@google.com <robertshield@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-04 03:22:32 +0000
committerrobertshield@google.com <robertshield@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-04 03:22:32 +0000
commit0bb1a6204af17f50ad0577f811a2c044b2bf62ff (patch)
treea300fc9b01eaddd694d6fb58322862719c5661e7 /chrome/common/pref_service.cc
parentbff6ef77683a85e61c5a916ade6c2f85b29e6f62 (diff)
downloadchromium_src-0bb1a6204af17f50ad0577f811a2c044b2bf62ff.zip
chromium_src-0bb1a6204af17f50ad0577f811a2c044b2bf62ff.tar.gz
chromium_src-0bb1a6204af17f50ad0577f811a2c044b2bf62ff.tar.bz2
Add a set of long-running metrics to Chrome that are sent up only at uninstall time via the uninstall survey page.These uninstall metrics are collected according to the same opt-in policy as the existing UMA code. They are stored along with other prefs in the browser's Local State file. At uninstall time, the Local State file is copied to a temporary location during the file deletion stage and then read to extract the uninstall metrics. If the user selected to have metrics reported, the uninstall metrics are then sent up to the uninstall survey page that is currently opened.
Review URL: http://codereview.chromium.org/27092 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10859 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/pref_service.cc')
-rw-r--r--chrome/common/pref_service.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/chrome/common/pref_service.cc b/chrome/common/pref_service.cc
index fd6cef7..b5bbb55 100644
--- a/chrome/common/pref_service.cc
+++ b/chrome/common/pref_service.cc
@@ -610,6 +610,53 @@ void PrefService::SetFilePath(const wchar_t* path, const FilePath& value) {
FireObserversIfChanged(path, old_value.get());
}
+void PrefService::SetInt64(const wchar_t* path, int64 value) {
+ DCHECK(CalledOnValidThread());
+
+ const Preference* pref = FindPreference(path);
+ if (!pref) {
+ DCHECK(false) << "Trying to write an unregistered pref: " << path;
+ return;
+ }
+ if (pref->type() != Value::TYPE_STRING) {
+ DCHECK(false) << "Wrong type for SetInt64: " << path;
+ return;
+ }
+
+ scoped_ptr<Value> old_value(GetPrefCopy(path));
+ bool rv = persistent_->SetString(path, Int64ToWString(value));
+ DCHECK(rv);
+
+ FireObserversIfChanged(path, old_value.get());
+}
+
+int64 PrefService::GetInt64(const wchar_t* path) const {
+ DCHECK(CalledOnValidThread());
+
+ std::wstring result;
+ if (transient_->GetString(path, &result))
+ return StringToInt64(WideToUTF16Hack(result));
+
+ const Preference* pref = FindPreference(path);
+ if (!pref) {
+#if defined(OS_WIN)
+ DCHECK(false) << "Trying to read an unregistered pref: " << path;
+#else
+ // TODO(port): remove this exception
+#endif
+ return StringToInt64(WideToUTF16Hack(result));
+ }
+ bool rv = pref->GetValue()->GetAsString(&result);
+ DCHECK(rv);
+ return StringToInt64(WideToUTF16Hack(result));
+}
+
+void PrefService::RegisterInt64Pref(const wchar_t* path, int64 default_value) {
+ Preference* pref = new Preference(persistent_.get(), path,
+ Value::CreateStringValue(Int64ToWString(default_value)));
+ RegisterPreference(pref);
+}
+
DictionaryValue* PrefService::GetMutableDictionary(const wchar_t* path) {
DCHECK(CalledOnValidThread());