diff options
author | robertshield@google.com <robertshield@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-04 03:22:32 +0000 |
---|---|---|
committer | robertshield@google.com <robertshield@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-04 03:22:32 +0000 |
commit | 0bb1a6204af17f50ad0577f811a2c044b2bf62ff (patch) | |
tree | a300fc9b01eaddd694d6fb58322862719c5661e7 /chrome/common | |
parent | bff6ef77683a85e61c5a916ade6c2f85b29e6f62 (diff) | |
download | chromium_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')
-rw-r--r-- | chrome/common/pref_names.cc | 12 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 7 | ||||
-rw-r--r-- | chrome/common/pref_service.cc | 47 | ||||
-rw-r--r-- | chrome/common/pref_service.h | 7 | ||||
-rw-r--r-- | chrome/common/pref_service_unittest.cc | 8 |
5 files changed, 80 insertions, 1 deletions
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index bda65f9..e120347 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -369,6 +369,18 @@ const wchar_t kStabilityPluginLaunches[] = L"launches"; const wchar_t kStabilityPluginInstances[] = L"instances"; const wchar_t kStabilityPluginCrashes[] = L"crashes"; +// The keys below are strictly increasing counters over the lifetime of +// a chrome installation. They are (optionally) sent up to the uninstall +// survey in the event of uninstallation. +const wchar_t kUninstallMetricsPageLoadCount[] = + L"uninstall_metrics.page_load_count"; +const wchar_t kUninstallLaunchCount[] = L"uninstall_metrics.launch_count"; +const wchar_t kUninstallMetricsUptimeSec[] = L"uninstall_metrics.uptime_sec"; +const wchar_t kUninstallLastLaunchTimeSec[] = + L"uninstall_metrics.last_launch_time_sec"; +const wchar_t kUninstallLastObservedRunTimeSec[] = + L"uninstall_metrics.last_observed_running_time_sec"; + // If true, the user will be prompted to manually launch renderer processes. const wchar_t kStartRenderersManually[] = L"renderer.start_manually"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 49367fd..718fb9a 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -123,6 +123,13 @@ extern const wchar_t kStabilityPluginLaunches[]; extern const wchar_t kStabilityPluginInstances[]; extern const wchar_t kStabilityPluginCrashes[]; +extern const wchar_t kUninstallMetricsPageLoadCount[]; +extern const wchar_t kUninstallLaunchCount[]; + +extern const wchar_t kUninstallMetricsUptimeSec[]; +extern const wchar_t kUninstallLastLaunchTimeSec[]; +extern const wchar_t kUninstallLastObservedRunTimeSec[]; + extern const wchar_t kStartRenderersManually[]; extern const wchar_t kBrowserWindowPlacement[]; extern const wchar_t kTaskManagerWindowPlacement[]; 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()); diff --git a/chrome/common/pref_service.h b/chrome/common/pref_service.h index 0a7690c..f5377d2 100644 --- a/chrome/common/pref_service.h +++ b/chrome/common/pref_service.h @@ -156,6 +156,13 @@ class PrefService : public NonThreadSafe { void SetString(const wchar_t* path, const std::wstring& value); void SetFilePath(const wchar_t* path, const FilePath& value); + // Int64 helper methods that actually store the given value as a string. + // Note that if obtaining the named value via GetDictionary or GetList, the + // Value type will be TYPE_STRING. + void SetInt64(const wchar_t* path, int64 value); + int64 GetInt64(const wchar_t* path) const; + void RegisterInt64Pref(const wchar_t* path, int64 default_value); + // Used to set the value of dictionary or list values in the pref tree. This // will create a dictionary or list if one does not exist in the pref tree. // This method returns NULL only if you're requesting an unregistered pref or diff --git a/chrome/common/pref_service_unittest.cc b/chrome/common/pref_service_unittest.cc index 2a43e69..e690579a 100644 --- a/chrome/common/pref_service_unittest.cc +++ b/chrome/common/pref_service_unittest.cc @@ -16,7 +16,7 @@ namespace { class PrefServiceTest : public testing::Test { -protected: + protected: virtual void SetUp() { // Name a subdirectory of the temp directory. ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); @@ -98,9 +98,11 @@ TEST_F(PrefServiceTest, Basic) { // Register test prefs. const wchar_t kNewWindowsInTabs[] = L"tabs.new_windows_in_tabs"; const wchar_t kMaxTabs[] = L"tabs.max_tabs"; + const wchar_t kLongIntPref[] = L"long_int.pref"; prefs.RegisterStringPref(prefs::kHomePage, L""); prefs.RegisterBooleanPref(kNewWindowsInTabs, false); prefs.RegisterIntegerPref(kMaxTabs, 0); + prefs.RegisterStringPref(kLongIntPref, L"2147483648"); std::wstring microsoft(L"http://www.microsoft.com"); std::wstring cnn(L"http://www.cnn.com"); @@ -130,6 +132,10 @@ TEST_F(PrefServiceTest, Basic) { prefs.SetInteger(kMaxTabs, 10); EXPECT_EQ(10, prefs.GetInteger(kMaxTabs)); + EXPECT_EQ(2147483648LL, prefs.GetInt64(kLongIntPref)); + prefs.SetInt64(kLongIntPref, 214748364842LL); + EXPECT_EQ(214748364842LL, prefs.GetInt64(kLongIntPref)); + EXPECT_EQ(FilePath::StringType(FILE_PATH_LITERAL("/usr/local/")), prefs.GetFilePath(kSomeDirectory).value()); prefs.SetFilePath(kSomeDirectory, some_path); |