| Index: chrome/browser/metrics/chrome_metrics_services_manager_client.cc
|
| diff --git a/chrome/browser/metrics/chrome_metrics_services_manager_client.cc b/chrome/browser/metrics/chrome_metrics_services_manager_client.cc
|
| index c1224a28180afad63684aa45e5b12ca5efec652b..5329ea6b9374b9e627d0a00946b11ff18919a341 100644
|
| --- a/chrome/browser/metrics/chrome_metrics_services_manager_client.cc
|
| +++ b/chrome/browser/metrics/chrome_metrics_services_manager_client.cc
|
| @@ -25,8 +25,27 @@
|
| #include "components/variations/variations_associated_data.h"
|
| #include "content/public/browser/browser_thread.h"
|
|
|
| +#if defined(OS_WIN)
|
| +#include "base/win/registry.h"
|
| +#include "chrome/common/chrome_constants.h"
|
| +#include "chrome/install_static/install_util.h"
|
| +#include "chrome/installer/util/browser_distribution.h"
|
| +#include "components/crash/content/app/crashpad.h"
|
| +#endif // OS_WIN
|
| +
|
| namespace {
|
|
|
| +#if defined(OS_WIN)
|
| +// Type for the function pointer to enable and disable crash reporting on
|
| +// windows. Needed because the function is loaded from chrome_elf.
|
| +typedef void (*SetUploadConsentPointer)(bool);
|
| +
|
| +// The name of the function used to set the uploads enabled state in
|
| +// components/crash/content/app/crashpad.cc. This is used to call the function
|
| +// exported by the chrome_elf dll.
|
| +const char kCrashpadUpdateConsentFunctionName[] = "SetUploadConsentImpl";
|
| +#endif // OS_WIN
|
| +
|
| // Name of the variations param that defines the sampling rate.
|
| const char kRateParamName[] = "sampling_rate_per_mille";
|
|
|
| @@ -171,6 +190,31 @@ bool ChromeMetricsServicesManagerClient::OnlyDoMetricsRecording() {
|
| cmdline->HasSwitch(switches::kEnableBenchmarking);
|
| }
|
|
|
| +#if defined(OS_WIN)
|
| +void ChromeMetricsServicesManagerClient::UpdateRunningServices(
|
| + bool may_record,
|
| + bool may_upload) {
|
| + // First, set the registry value so that Crashpad will have the sampling state
|
| + // now and for subsequent runs.
|
| + install_static::SetCollectStatsInSample(IsClientInSample());
|
| +
|
| + // Next, get Crashpad to pick up the sampling state for this session.
|
| +
|
| + // The crash reporting is handled by chrome_elf.dll.
|
| + HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName);
|
| + static SetUploadConsentPointer set_upload_consent =
|
| + reinterpret_cast<SetUploadConsentPointer>(
|
| + GetProcAddress(elf_module, kCrashpadUpdateConsentFunctionName));
|
| +
|
| + if (set_upload_consent) {
|
| + // Crashpad will use the kRegUsageStatsInSample registry value to apply
|
| + // sampling correctly, but may_record already reflects the sampling state.
|
| + // This isn't a problem though, since they will be consistent.
|
| + set_upload_consent(may_record && may_upload);
|
| + }
|
| +}
|
| +#endif // defined(OS_WIN)
|
| +
|
| metrics::MetricsStateManager*
|
| ChromeMetricsServicesManagerClient::GetMetricsStateManager() {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
|
|