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

Unified Diff: chrome/browser/metrics/chromeos_metrics_provider.cc

Issue 2958353002: [Cleanup] Migrate the StatisticsProvider to use the TaskScheduler (Closed)
Patch Set: rewrap a line Created 3 years, 6 months 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
Index: chrome/browser/metrics/chromeos_metrics_provider.cc
diff --git a/chrome/browser/metrics/chromeos_metrics_provider.cc b/chrome/browser/metrics/chromeos_metrics_provider.cc
index aea298f281fba75884d59cbcfc4c62ef8b98875b..bf60a3cf2f113c3b14b492c8719493acb152d983 100644
--- a/chrome/browser/metrics/chromeos_metrics_provider.cc
+++ b/chrome/browser/metrics/chromeos_metrics_provider.cc
@@ -11,6 +11,9 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/task_scheduler/post_task.h"
+#include "base/task_scheduler/task_traits.h"
+#include "base/threading/thread_restrictions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/arc/arc_session_manager.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
@@ -23,7 +26,6 @@
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
-#include "content/public/browser/browser_thread.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/bluetooth_device.h"
@@ -167,18 +169,20 @@ void ChromeOSMetricsProvider::OnDidCreateMetricsLog() {
void ChromeOSMetricsProvider::InitTaskGetHardwareClass(
const base::Closure& callback) {
- // Run the (potentially expensive) task on the FILE thread to avoid blocking
+ // Run the (potentially expensive) task in the background to avoid blocking
// the UI thread.
- content::BrowserThread::PostTaskAndReply(
- content::BrowserThread::FILE,
+ base::PostTaskWithTraitsAndReply(
FROM_HERE,
- base::Bind(&ChromeOSMetricsProvider::InitTaskGetHardwareClassOnFileThread,
- weak_ptr_factory_.GetWeakPtr()),
+ {base::MayBlock(), base::TaskPriority::BACKGROUND,
+ base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN},
+ base::BindOnce(
+ &ChromeOSMetricsProvider::InitTaskGetHardwareClassOnBackgroundThread,
+ weak_ptr_factory_.GetWeakPtr()),
callback);
}
-void ChromeOSMetricsProvider::InitTaskGetHardwareClassOnFileThread() {
- DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
+void ChromeOSMetricsProvider::InitTaskGetHardwareClassOnBackgroundThread() {
+ base::ThreadRestrictions::AssertWaitAllowed();
chromeos::system::StatisticsProvider::GetInstance()->GetMachineStatistic(
"hardware_class", &hardware_class_);
}
« no previous file with comments | « chrome/browser/metrics/chromeos_metrics_provider.h ('k') | chrome/browser/ui/webui/chromeos/login/l10n_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698