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

Side by Side 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: Adding support for sampling crashes in Chrome on Windows. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/install_static/install_util.h" 5 #include "chrome/install_static/install_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <assert.h> 8 #include <assert.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <iostream> 10 #include <iostream>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 const wchar_t kRegValueUsageStats[] = L"usagestats"; 48 const wchar_t kRegValueUsageStats[] = L"usagestats";
49 const wchar_t kUninstallArgumentsField[] = L"UninstallArguments"; 49 const wchar_t kUninstallArgumentsField[] = L"UninstallArguments";
50 const wchar_t kMetricsReportingEnabled[] = L"MetricsReportingEnabled"; 50 const wchar_t kMetricsReportingEnabled[] = L"MetricsReportingEnabled";
51 51
52 const wchar_t kAppGuidCanary[] = L"{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}"; 52 const wchar_t kAppGuidCanary[] = L"{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}";
53 const wchar_t kAppGuidGoogleChrome[] = 53 const wchar_t kAppGuidGoogleChrome[] =
54 L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; 54 L"{8A69D345-D564-463c-AFF1-A69D9E530F96}";
55 const wchar_t kAppGuidGoogleBinaries[] = 55 const wchar_t kAppGuidGoogleBinaries[] =
56 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}"; 56 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}";
57 57
58 const wchar_t kChromeMetrics[] = L"\\MetricsReporting";
Alexei Svitkine (slow) 2016/08/10 21:49:33 Are just using this for the one sub-key? Seems str
jwd 2016/08/11 21:41:02 Done.
59 const wchar_t kChromeStatsSampleKey[] = L"usagestatsinsample";
Alexei Svitkine (slow) 2016/08/10 21:49:33 I know there's no comments here currently, but ple
jwd 2016/08/11 21:41:02 Done.
60
58 const wchar_t kHeadless[] = L"CHROME_HEADLESS"; 61 const wchar_t kHeadless[] = L"CHROME_HEADLESS";
59 const wchar_t kShowRestart[] = L"CHROME_CRASHED"; 62 const wchar_t kShowRestart[] = L"CHROME_CRASHED";
60 const wchar_t kRestartInfo[] = L"CHROME_RESTART"; 63 const wchar_t kRestartInfo[] = L"CHROME_RESTART";
61 const wchar_t kRtlLocale[] = L"RIGHT_TO_LEFT"; 64 const wchar_t kRtlLocale[] = L"RIGHT_TO_LEFT";
62 65
63 const char kGpuProcess[] = "gpu-process"; 66 const char kGpuProcess[] = "gpu-process";
64 const char kPpapiPluginProcess[] = "ppapi"; 67 const char kPpapiPluginProcess[] = "ppapi";
65 const char kRendererProcess[] = "renderer"; 68 const char kRendererProcess[] = "renderer";
66 const char kUtilityProcess[] = "utility"; 69 const char kUtilityProcess[] = "utility";
67 const char kProcessType[] = "type"; 70 const char kProcessType[] = "type";
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // Second, try kRegPathClientState. 267 // Second, try kRegPathClientState.
265 full_key_path = kRegPathClientState; 268 full_key_path = kRegPathClientState;
266 full_key_path.append(1, L'\\'); 269 full_key_path.append(1, L'\\');
267 full_key_path.append(app_guid); 270 full_key_path.append(app_guid);
268 return (nt::QueryRegValueDWORD((system_install ? nt::HKLM : nt::HKCU), 271 return (nt::QueryRegValueDWORD((system_install ? nt::HKLM : nt::HKCU),
269 full_key_path.c_str(), kRegValueUsageStats, 272 full_key_path.c_str(), kRegValueUsageStats,
270 &out_value) && 273 &out_value) &&
271 out_value == 1); 274 out_value == 1);
272 } 275 }
273 276
277 bool GetCollectStatsInSampleImpl(const std::wstring& exe_path) {
278 std::wstring registry_path = L"Software\\";
Alexei Svitkine (slow) 2016/08/10 21:49:33 Seems strange to have this hardcoded. Can this be
jwd 2016/08/11 21:41:02 Done.
279 registry_path += GetChromeInstallSubDirectory();
280 registry_path += kChromeMetrics;
281
282 DWORD out_value = 0;
283 return (nt::QueryRegValueDWORD(nt::HKCU, registry_path.c_str(),
284 kChromeStatsSampleKey, &out_value) &&
285 out_value == 1);
Alexei Svitkine (slow) 2016/08/10 21:49:33 What happens if the registry key isn't set? Would
jwd 2016/08/11 21:41:02 Done.
286 }
287
274 // Returns true if the |source| string matches the |pattern|. The pattern 288 // Returns true if the |source| string matches the |pattern|. The pattern
275 // may contain wildcards like '?' which matches one character or a '*' 289 // may contain wildcards like '?' which matches one character or a '*'
276 // which matches 0 or more characters. 290 // which matches 0 or more characters.
277 // Please note that pattern matches the whole string. If you want to find 291 // Please note that pattern matches the whole string. If you want to find
278 // something in the middle of the string then you need to specify the pattern 292 // something in the middle of the string then you need to specify the pattern
279 // as '*xyz*'. 293 // as '*xyz*'.
280 // |source_index| is the index of the current character being matched in 294 // |source_index| is the index of the current character being matched in
281 // |source|. 295 // |source|.
282 // |pattern_index| is the index of the current pattern character in |pattern| 296 // |pattern_index| is the index of the current pattern character in |pattern|
283 // which is matched with source. 297 // which is matched with source.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } 419 }
406 420
407 bool GetCollectStatsConsent() { 421 bool GetCollectStatsConsent() {
408 return GetCollectStatsConsentImpl(GetCurrentProcessExePath()); 422 return GetCollectStatsConsentImpl(GetCurrentProcessExePath());
409 } 423 }
410 424
411 bool GetCollectStatsConsentForTesting(const std::wstring& exe_path) { 425 bool GetCollectStatsConsentForTesting(const std::wstring& exe_path) {
412 return GetCollectStatsConsentImpl(exe_path); 426 return GetCollectStatsConsentImpl(exe_path);
413 } 427 }
414 428
429 bool GetCollectStatsInSample() {
430 return GetCollectStatsInSampleImpl(GetCurrentProcessExePath());
431 }
432
415 bool ReportingIsEnforcedByPolicy(bool* metrics_is_enforced_by_policy) { 433 bool ReportingIsEnforcedByPolicy(bool* metrics_is_enforced_by_policy) {
416 DWORD value = 0; 434 DWORD value = 0;
417 435
418 // First, try HKLM. 436 // First, try HKLM.
419 if (nt::QueryRegValueDWORD(nt::HKLM, kRegPathChromePolicy, 437 if (nt::QueryRegValueDWORD(nt::HKLM, kRegPathChromePolicy,
420 kMetricsReportingEnabled, &value)) { 438 kMetricsReportingEnabled, &value)) {
421 *metrics_is_enforced_by_policy = (value != 0); 439 *metrics_is_enforced_by_policy = (value != 0);
422 return true; 440 return true;
423 } 441 }
424 442
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 switch_value_end_offset = command_line_copy.length(); 867 switch_value_end_offset = command_line_copy.length();
850 868
851 std::string switch_value = command_line_copy.substr( 869 std::string switch_value = command_line_copy.substr(
852 switch_value_start_offset, 870 switch_value_start_offset,
853 switch_value_end_offset - (switch_offset + switch_token.length())); 871 switch_value_end_offset - (switch_offset + switch_token.length()));
854 TrimT<std::string>(&switch_value); 872 TrimT<std::string>(&switch_value);
855 return switch_value; 873 return switch_value;
856 } 874 }
857 875
858 } // namespace install_static 876 } // namespace install_static
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698