| 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/bind.h" |
| 10 #include "base/callback_helpers.h" |
| 9 #include "base/cpu.h" | 11 #include "base/cpu.h" |
| 10 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
| 13 #include "base/threading/platform_thread.h" |
| 14 #include "base/threading/sequenced_worker_pool.h" |
| 11 #include "chrome/common/channel_info.h" | 15 #include "chrome/common/channel_info.h" |
| 12 #include "chrome/common/safe_browsing/csd.pb.h" | 16 #include "chrome/common/safe_browsing/csd.pb.h" |
| 13 #include "components/version_info/version_info.h" | 17 #include "components/version_info/version_info.h" |
| 14 | 18 |
| 15 namespace safe_browsing { | 19 namespace safe_browsing { |
| 16 | 20 |
| 17 // Populates |process| with platform-specific data related to the chrome browser | 21 // Populates |process| with platform-specific data related to the chrome browser |
| 18 // process. | 22 // process. |
| 19 void CollectPlatformProcessData( | 23 void CollectPlatformProcessData( |
| 20 ClientIncidentReport_EnvironmentData_Process* process); | 24 ClientIncidentReport_EnvironmentData_Process* process); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 59 |
| 56 process->set_chrome_update_channel( | 60 process->set_chrome_update_channel( |
| 57 MapChannelToProtobuf(chrome::GetChannel())); | 61 MapChannelToProtobuf(chrome::GetChannel())); |
| 58 | 62 |
| 59 CollectPlatformProcessData(process); | 63 CollectPlatformProcessData(process); |
| 60 } | 64 } |
| 61 | 65 |
| 62 } // namespace | 66 } // namespace |
| 63 | 67 |
| 64 void CollectEnvironmentData(ClientIncidentReport_EnvironmentData* data) { | 68 void CollectEnvironmentData(ClientIncidentReport_EnvironmentData* data) { |
| 69 // Toggling priority only makes sense in a thread pool. |
| 70 DCHECK(base::SequencedWorkerPool::GetWorkerPoolForCurrentThread()); |
| 71 // Reset priority when done with this task. |
| 72 base::ScopedClosureRunner restore_priority( |
| 73 base::Bind(&base::PlatformThread::SetCurrentThreadPriority, |
| 74 base::PlatformThread::GetCurrentThreadPriority())); |
| 75 // Lower priority for this task. |
| 76 base::PlatformThread::SetCurrentThreadPriority( |
| 77 base::ThreadPriority::BACKGROUND); |
| 78 |
| 65 // OS | 79 // OS |
| 66 { | 80 { |
| 67 ClientIncidentReport_EnvironmentData_OS* os = data->mutable_os(); | 81 ClientIncidentReport_EnvironmentData_OS* os = data->mutable_os(); |
| 68 os->set_os_name(base::SysInfo::OperatingSystemName()); | 82 os->set_os_name(base::SysInfo::OperatingSystemName()); |
| 69 os->set_os_version(base::SysInfo::OperatingSystemVersion()); | 83 os->set_os_version(base::SysInfo::OperatingSystemVersion()); |
| 70 CollectPlatformOSData(os); | 84 CollectPlatformOSData(os); |
| 71 } | 85 } |
| 72 | 86 |
| 73 // Machine | 87 // Machine |
| 74 { | 88 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 91 // implementations. | 105 // implementations. |
| 92 } | 106 } |
| 93 | 107 |
| 94 void CollectPlatformOSData(ClientIncidentReport_EnvironmentData_OS* os_data) { | 108 void CollectPlatformOSData(ClientIncidentReport_EnvironmentData_OS* os_data) { |
| 95 // Empty implementation for platforms that do not (yet) have their own | 109 // Empty implementation for platforms that do not (yet) have their own |
| 96 // implementations. | 110 // implementations. |
| 97 } | 111 } |
| 98 #endif | 112 #endif |
| 99 | 113 |
| 100 } // namespace safe_browsing | 114 } // namespace safe_browsing |
| OLD | NEW |