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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/cpu.h" | 11 #include "base/cpu.h" |
| 12 #include "base/logging.h" | |
| 12 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 13 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 14 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 16 #include "chrome/common/channel_info.h" | 17 #include "chrome/common/channel_info.h" |
| 17 #include "chrome/common/safe_browsing/csd.pb.h" | 18 #include "chrome/common/safe_browsing/csd.pb.h" |
| 18 #include "components/version_info/version_info.h" | 19 #include "components/version_info/version_info.h" |
| 20 #include "content/public/browser/browser_thread.h" | |
| 19 | 21 |
| 20 namespace safe_browsing { | 22 namespace safe_browsing { |
| 21 | 23 |
| 22 // Populates |process| with platform-specific data related to the chrome browser | 24 // Populates |process| with platform-specific data related to the chrome browser |
| 23 // process. | 25 // process. |
| 24 void CollectPlatformProcessData( | 26 void CollectPlatformProcessData( |
| 25 ClientIncidentReport_EnvironmentData_Process* process); | 27 ClientIncidentReport_EnvironmentData_Process* process); |
| 26 | 28 |
| 27 // Populates |os_data| with platform-specific data related to the OS. | 29 // Populates |os_data| with platform-specific data related to the OS. |
| 28 void CollectPlatformOSData(ClientIncidentReport_EnvironmentData_OS* os_data); | 30 void CollectPlatformOSData(ClientIncidentReport_EnvironmentData_OS* os_data); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 process->set_chrome_update_channel( | 63 process->set_chrome_update_channel( |
| 62 MapChannelToProtobuf(chrome::GetChannel())); | 64 MapChannelToProtobuf(chrome::GetChannel())); |
| 63 | 65 |
| 64 CollectPlatformProcessData(process); | 66 CollectPlatformProcessData(process); |
| 65 } | 67 } |
| 66 | 68 |
| 67 } // namespace | 69 } // namespace |
| 68 | 70 |
| 69 void CollectEnvironmentData(ClientIncidentReport_EnvironmentData* data) { | 71 void CollectEnvironmentData(ClientIncidentReport_EnvironmentData* data) { |
| 70 // Toggling priority only makes sense in a thread pool. | 72 // Toggling priority only makes sense in a thread pool. |
| 71 DCHECK(base::SequencedWorkerPool::GetWorkerPoolForCurrentThread()); | 73 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
|
gab
2016/09/30 15:48:56
I think such a call site once again argues for som
gab
2016/09/30 19:21:03
Thinking about this some more, WDYT of DCHECK(!bas
gab
2016/10/03 19:47:34
ping ^^?
| |
| 72 // Reset priority when done with this task. | 74 // Reset priority when done with this task. |
| 75 // TODO(fdoray): Post this task to the TaskScheduler with a BACKGROUND | |
| 76 // priority instead of toggling the priority within the task. | |
| 73 base::ScopedClosureRunner restore_priority( | 77 base::ScopedClosureRunner restore_priority( |
| 74 base::Bind(&base::PlatformThread::SetCurrentThreadPriority, | 78 base::Bind(&base::PlatformThread::SetCurrentThreadPriority, |
| 75 base::PlatformThread::GetCurrentThreadPriority())); | 79 base::PlatformThread::GetCurrentThreadPriority())); |
| 76 // Lower priority for this task. | 80 // Lower priority for this task. |
| 77 base::PlatformThread::SetCurrentThreadPriority( | 81 base::PlatformThread::SetCurrentThreadPriority( |
| 78 base::ThreadPriority::BACKGROUND); | 82 base::ThreadPriority::BACKGROUND); |
| 79 | 83 |
| 80 // OS | 84 // OS |
| 81 { | 85 { |
| 82 ClientIncidentReport_EnvironmentData_OS* os = data->mutable_os(); | 86 ClientIncidentReport_EnvironmentData_OS* os = data->mutable_os(); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 106 // implementations. | 110 // implementations. |
| 107 } | 111 } |
| 108 | 112 |
| 109 void CollectPlatformOSData(ClientIncidentReport_EnvironmentData_OS* os_data) { | 113 void CollectPlatformOSData(ClientIncidentReport_EnvironmentData_OS* os_data) { |
| 110 // Empty implementation for platforms that do not (yet) have their own | 114 // Empty implementation for platforms that do not (yet) have their own |
| 111 // implementations. | 115 // implementations. |
| 112 } | 116 } |
| 113 #endif | 117 #endif |
| 114 | 118 |
| 115 } // namespace safe_browsing | 119 } // namespace safe_browsing |
| OLD | NEW |