Remove aura enum from DesktopMediaID to fix desktop mirroring audio (CrOS).
[chromium-blink-merge.git] / chrome / browser / safe_browsing / incident_reporting / environment_data_collection.cc
blob5869b16b2992e44ca3fc26afacfc912a110d5def
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
3 // found in the LICENSE file.
5 #include "chrome/browser/safe_browsing/incident_reporting/environment_data_collection.h"
7 #include <string>
9 #include "base/cpu.h"
10 #include "base/sys_info.h"
11 #include "chrome/common/channel_info.h"
12 #include "chrome/common/safe_browsing/csd.pb.h"
13 #include "components/version_info/version_info.h"
15 namespace safe_browsing {
17 // Populates |process| with platform-specific data related to the chrome browser
18 // process.
19 void CollectPlatformProcessData(
20 ClientIncidentReport_EnvironmentData_Process* process);
22 namespace {
24 ClientIncidentReport_EnvironmentData_Process_Channel MapChannelToProtobuf(
25 version_info::Channel channel) {
26 typedef ClientIncidentReport_EnvironmentData_Process Process;
27 switch (channel) {
28 case version_info::Channel::CANARY:
29 return Process::CHANNEL_CANARY;
30 case version_info::Channel::DEV:
31 return Process::CHANNEL_DEV;
32 case version_info::Channel::BETA:
33 return Process::CHANNEL_BETA;
34 case version_info::Channel::STABLE:
35 return Process::CHANNEL_STABLE;
36 default:
37 return Process::CHANNEL_UNKNOWN;
41 // Populates |process| with data related to the chrome browser process.
42 void CollectProcessData(ClientIncidentReport_EnvironmentData_Process* process) {
43 // TODO(grt): Move this logic into VersionInfo (it also appears in
44 // ChromeMetricsServiceClient).
45 std::string version(version_info::GetVersionNumber());
46 #if defined(ARCH_CPU_64_BITS)
47 version += "-64";
48 #endif // defined(ARCH_CPU_64_BITS)
49 if (!version_info::IsOfficialBuild())
50 version += "-devel";
51 process->set_version(version);
53 process->set_chrome_update_channel(
54 MapChannelToProtobuf(chrome::GetChannel()));
56 CollectPlatformProcessData(process);
59 } // namespace
61 void CollectEnvironmentData(ClientIncidentReport_EnvironmentData* data) {
62 // OS
64 ClientIncidentReport_EnvironmentData_OS* os = data->mutable_os();
65 os->set_os_name(base::SysInfo::OperatingSystemName());
66 os->set_os_version(base::SysInfo::OperatingSystemVersion());
69 // Machine
71 base::CPU cpu_info;
72 ClientIncidentReport_EnvironmentData_Machine* machine =
73 data->mutable_machine();
74 machine->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture());
75 machine->set_cpu_vendor(cpu_info.vendor_name());
76 machine->set_cpuid(cpu_info.signature());
79 // Process
80 CollectProcessData(data->mutable_process());
83 #if !defined(OS_WIN)
84 void CollectPlatformProcessData(
85 ClientIncidentReport_EnvironmentData_Process* process) {
86 // Empty implementation for platforms that do not (yet) have their own
87 // implementations.
89 #endif
91 } // namespace safe_browsing