Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(734)

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/environment_data_collection.cc

Issue 1505813003: Lower the priority of environment and process data collection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update include Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
12 #include "base/threading/sequenced_worker_pool.h"
11 #include "chrome/common/channel_info.h" 13 #include "chrome/common/channel_info.h"
12 #include "chrome/common/safe_browsing/csd.pb.h" 14 #include "chrome/common/safe_browsing/csd.pb.h"
13 #include "components/version_info/version_info.h" 15 #include "components/version_info/version_info.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);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(base::SequencedWorkerPool::GetWorkerPoolForCurrentThread());
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);
grt (UTC plus 2) 2015/12/14 21:10:25 it would be hella bad if someone accidentally adde
gab 2015/12/15 16:49:38 That sounds like a great idea to me, also keeps al
proberge 2015/12/16 15:19:38 Done.
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698