Bug 521923 - Stop client-side Windows "throttling". r=jmathies

This commit is contained in:
David Dahl 2009-11-11 11:26:10 +01:00
parent 601b8f05da
commit df0c0ee8d7

View File

@ -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));