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

Unified 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: Move comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/incident_reporting/environment_data_collection.cc
diff --git a/chrome/browser/safe_browsing/incident_reporting/environment_data_collection.cc b/chrome/browser/safe_browsing/incident_reporting/environment_data_collection.cc
index f207502a3ac742370b8253646d1c654def211c02..36bfe318cb98fabb6e56d4fdd194a31d3152ed0a 100644
--- a/chrome/browser/safe_browsing/incident_reporting/environment_data_collection.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/environment_data_collection.cc
@@ -6,8 +6,12 @@
#include <string>
+#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/cpu.h"
#include "base/sys_info.h"
+#include "base/threading/platform_thread.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/safe_browsing/csd.pb.h"
#include "components/version_info/version_info.h"
@@ -62,6 +66,16 @@ void CollectProcessData(ClientIncidentReport_EnvironmentData_Process* process) {
} // namespace
void CollectEnvironmentData(ClientIncidentReport_EnvironmentData* data) {
+ // Toggling priority only makes sense in a thread pool.
+ DCHECK(base::SequencedWorkerPool::GetWorkerPoolForCurrentThread());
+ // Reset priority when done with this task.
+ base::ScopedClosureRunner restore_priority(
+ base::Bind(&base::PlatformThread::SetCurrentThreadPriority,
+ base::PlatformThread::GetCurrentThreadPriority()));
+ // Lower priority for this task.
+ base::PlatformThread::SetCurrentThreadPriority(
+ base::ThreadPriority::BACKGROUND);
+
// OS
{
ClientIncidentReport_EnvironmentData_OS* os = data->mutable_os();
« 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