Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/browser/safe_browsing/incident_reporting/environment_data_colle ction.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/environment_data_colle ction.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/cpu.h" | 9 #include "base/cpu.h" |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| 11 #include "base/threading/platform_thread.h" | |
| 11 #include "chrome/common/channel_info.h" | 12 #include "chrome/common/channel_info.h" |
| 12 #include "chrome/common/safe_browsing/csd.pb.h" | 13 #include "chrome/common/safe_browsing/csd.pb.h" |
| 13 #include "components/version_info/version_info.h" | 14 #include "components/version_info/version_info.h" |
| 15 #include "content/public/browser/browser_thread.h" | |
| 14 | 16 |
| 15 namespace safe_browsing { | 17 namespace safe_browsing { |
| 16 | 18 |
| 17 // Populates |process| with platform-specific data related to the chrome browser | 19 // Populates |process| with platform-specific data related to the chrome browser |
| 18 // process. | 20 // process. |
| 19 void CollectPlatformProcessData( | 21 void CollectPlatformProcessData( |
| 20 ClientIncidentReport_EnvironmentData_Process* process); | 22 ClientIncidentReport_EnvironmentData_Process* process); |
| 21 | 23 |
| 22 // Populates |os_data| with platform-specific data related to the OS. | 24 // Populates |os_data| with platform-specific data related to the OS. |
| 23 void CollectPlatformOSData(ClientIncidentReport_EnvironmentData_OS* os_data); | 25 void CollectPlatformOSData(ClientIncidentReport_EnvironmentData_OS* os_data); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 | 57 |
| 56 process->set_chrome_update_channel( | 58 process->set_chrome_update_channel( |
| 57 MapChannelToProtobuf(chrome::GetChannel())); | 59 MapChannelToProtobuf(chrome::GetChannel())); |
| 58 | 60 |
| 59 CollectPlatformProcessData(process); | 61 CollectPlatformProcessData(process); |
| 60 } | 62 } |
| 61 | 63 |
| 62 } // namespace | 64 } // namespace |
| 63 | 65 |
| 64 void CollectEnvironmentData(ClientIncidentReport_EnvironmentData* data) { | 66 void CollectEnvironmentData(ClientIncidentReport_EnvironmentData* data) { |
| 67 // Toggling priority only makes sense in a thread pool. | |
| 68 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | |
|
grt (UTC plus 2)
2015/12/09 14:35:25
i don't like the dependence on BrowserThread here.
gab
2015/12/09 21:51:01
Yea that works :-) (interestingly this call was re
proberge
2015/12/10 21:00:57
This doesn't run if there's no incident, but most
| |
| 69 // Lower priority for this task. | |
| 70 auto previous_priority = base::PlatformThread::GetCurrentThreadPriority(); | |
| 71 base::PlatformThread::SetCurrentThreadPriority( | |
| 72 base::ThreadPriority::BACKGROUND); | |
| 73 | |
| 65 // OS | 74 // OS |
| 66 { | 75 { |
| 67 ClientIncidentReport_EnvironmentData_OS* os = data->mutable_os(); | 76 ClientIncidentReport_EnvironmentData_OS* os = data->mutable_os(); |
| 68 os->set_os_name(base::SysInfo::OperatingSystemName()); | 77 os->set_os_name(base::SysInfo::OperatingSystemName()); |
| 69 os->set_os_version(base::SysInfo::OperatingSystemVersion()); | 78 os->set_os_version(base::SysInfo::OperatingSystemVersion()); |
| 70 CollectPlatformOSData(os); | 79 CollectPlatformOSData(os); |
| 71 } | 80 } |
| 72 | 81 |
| 73 // Machine | 82 // Machine |
| 74 { | 83 { |
| 75 base::CPU cpu_info; | 84 base::CPU cpu_info; |
| 76 ClientIncidentReport_EnvironmentData_Machine* machine = | 85 ClientIncidentReport_EnvironmentData_Machine* machine = |
| 77 data->mutable_machine(); | 86 data->mutable_machine(); |
| 78 machine->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture()); | 87 machine->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture()); |
| 79 machine->set_cpu_vendor(cpu_info.vendor_name()); | 88 machine->set_cpu_vendor(cpu_info.vendor_name()); |
| 80 machine->set_cpuid(cpu_info.signature()); | 89 machine->set_cpuid(cpu_info.signature()); |
| 81 } | 90 } |
| 82 | 91 |
| 83 // Process | 92 // Process |
| 84 CollectProcessData(data->mutable_process()); | 93 CollectProcessData(data->mutable_process()); |
| 94 | |
| 95 // Reset the thread priority. | |
| 96 base::PlatformThread::SetCurrentThreadPriority(previous_priority); | |
| 85 } | 97 } |
| 86 | 98 |
| 87 #if !defined(OS_WIN) | 99 #if !defined(OS_WIN) |
| 88 void CollectPlatformProcessData( | 100 void CollectPlatformProcessData( |
| 89 ClientIncidentReport_EnvironmentData_Process* process) { | 101 ClientIncidentReport_EnvironmentData_Process* process) { |
| 90 // Empty implementation for platforms that do not (yet) have their own | 102 // Empty implementation for platforms that do not (yet) have their own |
| 91 // implementations. | 103 // implementations. |
| 92 } | 104 } |
| 93 | 105 |
| 94 void CollectPlatformOSData(ClientIncidentReport_EnvironmentData_OS* os_data) { | 106 void CollectPlatformOSData(ClientIncidentReport_EnvironmentData_OS* os_data) { |
| 95 // Empty implementation for platforms that do not (yet) have their own | 107 // Empty implementation for platforms that do not (yet) have their own |
| 96 // implementations. | 108 // implementations. |
| 97 } | 109 } |
| 98 #endif | 110 #endif |
| 99 | 111 |
| 100 } // namespace safe_browsing | 112 } // namespace safe_browsing |
| OLD | NEW |