From df0c0ee8d72b519fdce9bab66ad3f57b4d673656 Mon Sep 17 00:00:00 2001 From: David Dahl Date: Wed, 11 Nov 2009 11:26:10 +0100 Subject: [PATCH] Bug 521923 - Stop client-side Windows "throttling". r=jmathies --- .../client/crashreporter_win.cpp | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/toolkit/crashreporter/client/crashreporter_win.cpp b/toolkit/crashreporter/client/crashreporter_win.cpp index 4f86ca21e633..caccb402e8e7 100644 --- a/toolkit/crashreporter/client/crashreporter_win.cpp +++ b/toolkit/crashreporter/client/crashreporter_win.cpp @@ -57,7 +57,8 @@ #include "common/windows/string_utils-inl.h" #define CRASH_REPORTER_VALUE L"Enabled" -#define SUBMIT_REPORT_VALUE L"SubmitReport" +#define SUBMIT_REPORT_VALUE L"SubmitCrashReport" +#define SUBMIT_REPORT_OLD L"SubmitReport" #define INCLUDE_URL_VALUE L"IncludeURL" #define EMAIL_ME_VALUE L"EmailMe" #define EMAIL_VALUE L"Email" @@ -158,6 +159,24 @@ static bool GetBoolValue(HKEY hRegKey, LPCTSTR valueName, DWORD* value) return false; } +// Removes a value from HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER, if it exists. +static void RemoveUnusedValues(const wchar_t* key, LPCTSTR valueName) +{ + HKEY hRegKey; + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_SET_VALUE, &hRegKey) + == ERROR_SUCCESS) { + RegDeleteValue(hRegKey, valueName); + RegCloseKey(hRegKey); + } + + if (RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, KEY_SET_VALUE, &hRegKey) + == ERROR_SUCCESS) { + RegDeleteValue(hRegKey, valueName); + RegCloseKey(hRegKey); + } +} + static bool CheckBoolKey(const wchar_t* key, const wchar_t* valueName, bool* enabled) @@ -190,6 +209,10 @@ static bool CheckBoolKey(const wchar_t* key, static void SetBoolKey(const wchar_t* key, const wchar_t* value, bool enabled) { HKEY hRegKey; + + // remove the old value from the registry if it exists + RemoveUnusedValues(key, SUBMIT_REPORT_OLD); + if (RegCreateKey(HKEY_CURRENT_USER, key, &hRegKey) == ERROR_SUCCESS) { DWORD data = (enabled ? 1 : 0); RegSetValueEx(hRegKey, value, 0, REG_DWORD, (LPBYTE)&data, sizeof(data));