Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8779)

Unified Diff: chrome/install_static/install_util.cc

Issue 2221833005: Adding support for sampling crashes in Chrome on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scottmg's comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/install_static/install_util.cc
diff --git a/chrome/install_static/install_util.cc b/chrome/install_static/install_util.cc
index c31b90e8927cd71f4cedf026d3b44da0f2112046..a9965159a5d60b4cf168d3710ddfe697bf85e7ab 100644
--- a/chrome/install_static/install_util.cc
+++ b/chrome/install_static/install_util.cc
@@ -55,6 +55,8 @@ const wchar_t kAppGuidGoogleChrome[] =
const wchar_t kAppGuidGoogleBinaries[] =
L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}";
+const wchar_t kChromeStatsSampleKey[] = L"UsageStatsInSample";
Alexei Svitkine (slow) 2016/08/12 17:47:48 How about using a similar variable naming conventi
jwd 2016/08/12 20:04:30 Done.
+
const wchar_t kHeadless[] = L"CHROME_HEADLESS";
const wchar_t kShowRestart[] = L"CHROME_CRASHED";
const wchar_t kRestartInfo[] = L"CHROME_RESTART";
@@ -234,6 +236,12 @@ bool RecursiveDirectoryCreate(const std::wstring& full_path) {
return true;
}
+std::wstring GetChromeInstallRegistryPath() {
+ std::wstring registry_path = L"Software\\";
+ registry_path += GetChromeInstallSubDirectory();
+ return registry_path;
+}
+
bool GetCollectStatsConsentImpl(const std::wstring& exe_path) {
bool enabled = true;
bool controlled_by_policy = ReportingIsEnforcedByPolicy(&enabled);
@@ -412,6 +420,33 @@ bool GetCollectStatsConsentForTesting(const std::wstring& exe_path) {
return GetCollectStatsConsentImpl(exe_path);
}
+bool GetCollectStatsInSample() {
+ std::wstring registry_path = GetChromeInstallRegistryPath();
+
+ DWORD out_value = 0;
+ if (!nt::QueryRegValueDWORD(nt::HKCU, registry_path.c_str(),
+ kChromeStatsSampleKey, &out_value)) {
+ // If reading the value failed, treat it as though sampling isn't in effect,
+ // implicitly meaning this install in in-sample.
Alexei Svitkine (slow) 2016/08/12 17:47:48 Nit: "this install in sample" -> "this install is
jwd 2016/08/12 20:04:30 Done.
+ return true;
+ }
+ return out_value == 1;
+}
+
+bool SetCollectStatsInSample(bool in_sample) {
+ std::wstring registry_path = GetChromeInstallRegistryPath();
+
+ HANDLE key_handle = INVALID_HANDLE_VALUE;
+ if (!nt::CreateRegKey(nt::HKCU, registry_path.c_str(), KEY_SET_VALUE,
+ &key_handle)) {
+ nt::CloseRegKey(key_handle);
+ return false;
+ }
+
+ return nt::SetRegValueDWORD(key_handle, kChromeStatsSampleKey,
+ in_sample ? 1 : 0);
+}
+
bool ReportingIsEnforcedByPolicy(bool* metrics_is_enforced_by_policy) {
DWORD value = 0;
@@ -678,8 +713,7 @@ std::wstring GetChromeInstallSubDirectory() {
}
std::wstring GetBrowserCrashDumpAttemptsRegistryPath() {
- std::wstring registry_path = L"Software\\";
- registry_path += GetChromeInstallSubDirectory();
+ std::wstring registry_path = GetChromeInstallRegistryPath();
registry_path += kBrowserCrashDumpMetricsSubKey;
return registry_path;
}

Powered by Google App Engine
This is Rietveld 408576698