Commit 22d14d5a authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

Migrate off base::ThreadPool()-as-a-trait in /services/device/usb

This CL is a logical no-op.

It manually covers the use cases the script
(https://crbug.com/1026641#c22) didn't cover in
https://chromium-review.googlesource.com/c/chromium/src/+/2026350.

A few of the affected files were also migrated to
content::GetUIThreadTaskRunner() whenever surrounding code consistency
was at stake (but the bulk of that migration is staged to happen after
this one so this wasn't a priority in this batch).

Most files intentionally kept base/task/post_task.h as an include. It is
still required because of a cyclical dependency during the migration
preventing base/task/thread_pool.h from implicitly providing
base/task/task_traits.h to its users (callers that explicitly store
TaskTraits and include task_traits.h don't have this problem). The
post_task.h include will be cleaned up in a later phase.

This CL was uploaded by git cl split.

R=odejesush@chromium.org

Bug: 1026641
Change-Id: I6fd3ee2edef8a427eb43444f643b750693e58b81
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079081
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Reviewed-by: default avatarOvidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745514}
parent 8209d844
......@@ -8,7 +8,7 @@
#include "base/feature_list.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "build/build_config.h"
#include "components/device_event_log/device_event_log.h"
......@@ -64,7 +64,7 @@ std::unique_ptr<UsbService> UsbService::Create() {
// static
scoped_refptr<base::SequencedTaskRunner>
UsbService::CreateBlockingTaskRunner() {
return base::CreateSequencedTaskRunner(kBlockingTaskTraits);
return base::ThreadPool::CreateSequencedTaskRunner(kBlockingTaskTraits);
}
UsbService::~UsbService() {
......
......@@ -50,10 +50,10 @@ class UsbService {
virtual void WillDestroyUsbService();
};
// These task traits are to be used for posting blocking tasks to the task
// scheduler.
// These task traits are to be used for posting blocking tasks to the thread
// pool.
static constexpr base::TaskTraits kBlockingTaskTraits = {
base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE,
base::MayBlock(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN};
// Returns nullptr when initialization fails.
......
......@@ -22,7 +22,7 @@
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "base/threading/scoped_blocking_call.h"
#include "build/build_config.h"
#include "components/device_event_log/device_event_log.h"
......@@ -232,7 +232,7 @@ void OnDeviceOpenedReadDescriptors(
UsbServiceImpl::UsbServiceImpl()
: task_runner_(base::SequencedTaskRunnerHandle::Get()) {
weak_self_ = weak_factory_.GetWeakPtr();
base::PostTaskAndReplyWithResult(
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, kBlockingTaskTraits,
base::BindOnce(&InitializeUsbContextBlocking),
base::BindOnce(&UsbServiceImpl::OnUsbContext,
......@@ -332,7 +332,7 @@ void UsbServiceImpl::RefreshDevices() {
pending_path_enumerations_.pop();
}
base::PostTaskAndReplyWithResult(
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, kBlockingTaskTraits,
base::BindOnce(&GetDeviceListBlocking, device_path, context_),
base::BindOnce(&UsbServiceImpl::OnDeviceList,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment