refactor: migrate base::ThreadPool() as trait to base::ThreadPool:: API (#22555)

This commit is contained in:
Shelley Vohr 2020-03-09 16:13:59 +00:00 committed by GitHub
parent 2159b4af4f
commit 3b08736ae2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 24 additions and 24 deletions

View file

@ -8,6 +8,7 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/task/thread_pool.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "content/public/browser/tracing_controller.h" #include "content/public/browser/tracing_controller.h"
#include "shell/common/gin_converters/callback_converter.h" #include "shell/common/gin_converters/callback_converter.h"
@ -86,10 +87,8 @@ v8::Local<v8::Promise> StopRecording(gin_helper::Arguments* args) {
StopTracing(std::move(promise), base::make_optional(path)); StopTracing(std::move(promise), base::make_optional(path));
} else { } else {
// use a temporary file. // use a temporary file.
base::PostTaskAndReplyWithResult( base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
{base::ThreadPool(), base::MayBlock(),
base::TaskPriority::USER_VISIBLE},
base::BindOnce(CreateTemporaryFileOnIO), base::BindOnce(CreateTemporaryFileOnIO),
base::BindOnce(StopTracing, std::move(promise))); base::BindOnce(StopTracing, std::move(promise)));
} }

View file

@ -7,6 +7,7 @@
#include <utility> #include <utility>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/task/thread_pool.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "components/net_log/chrome_net_log.h" #include "components/net_log/chrome_net_log.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
@ -52,8 +53,8 @@ scoped_refptr<base::SequencedTaskRunner> CreateFileTaskRunner() {
// //
// These operations can be skipped on shutdown since FileNetLogObserver's API // These operations can be skipped on shutdown since FileNetLogObserver's API
// doesn't require things to have completed until notified of completion. // doesn't require things to have completed until notified of completion.
return base::CreateSequencedTaskRunner( return base::ThreadPool::CreateSequencedTaskRunner(
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}); base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN});
} }

View file

@ -1949,9 +1949,8 @@ void WebContents::Print(gin_helper::Arguments* args) {
settings.SetIntKey(printing::kSettingDpiVertical, dpi); settings.SetIntKey(printing::kSettingDpiVertical, dpi);
} }
base::PostTaskAndReplyWithResult( base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_BLOCKING},
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_BLOCKING},
base::BindOnce(&GetDefaultPrinterAsync), base::BindOnce(&GetDefaultPrinterAsync),
base::BindOnce(&WebContents::OnGetDefaultPrinter, base::BindOnce(&WebContents::OnGetDefaultPrinter,
weak_factory_.GetWeakPtr(), std::move(settings), weak_factory_.GetWeakPtr(), std::move(settings),

View file

@ -13,6 +13,7 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/json/json_reader.h" #include "base/json/json_reader.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "base/threading/scoped_blocking_call.h" #include "base/threading/scoped_blocking_call.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "chrome/browser/ssl/security_state_tab_helper.h" #include "chrome/browser/ssl/security_state_tab_helper.h"
@ -183,8 +184,8 @@ bool IsDevToolsFileSystemAdded(content::WebContents* web_contents,
CommonWebContentsDelegate::CommonWebContentsDelegate() CommonWebContentsDelegate::CommonWebContentsDelegate()
: devtools_file_system_indexer_(new DevToolsFileSystemIndexer), : devtools_file_system_indexer_(new DevToolsFileSystemIndexer),
file_task_runner_(base::CreateSequencedTaskRunner( file_task_runner_(
{base::ThreadPool(), base::MayBlock()})), base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})),
weak_factory_(this) {} weak_factory_(this) {}
CommonWebContentsDelegate::~CommonWebContentsDelegate() = default; CommonWebContentsDelegate::~CommonWebContentsDelegate() = default;

View file

@ -226,9 +226,9 @@ bool ElectronDownloadManagerDelegate::DetermineDownloadTarget(
base::FilePath default_download_path = base::FilePath default_download_path =
browser_context->prefs()->GetFilePath(prefs::kDownloadDefaultDirectory); browser_context->prefs()->GetFilePath(prefs::kDownloadDefaultDirectory);
base::PostTaskAndReplyWithResult( base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT, {base::MayBlock(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}, base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN},
base::BindOnce(&CreateDownloadPath, download->GetURL(), base::BindOnce(&CreateDownloadPath, download->GetURL(),
download->GetContentDisposition(), download->GetContentDisposition(),

View file

@ -11,6 +11,7 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "content/public/browser/file_url_loader.h" #include "content/public/browser/file_url_loader.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
@ -304,8 +305,8 @@ void CreateAsarURLLoader(
network::mojom::URLLoaderRequest loader, network::mojom::URLLoaderRequest loader,
mojo::PendingRemote<network::mojom::URLLoaderClient> client, mojo::PendingRemote<network::mojom::URLLoaderClient> client,
scoped_refptr<net::HttpResponseHeaders> extra_response_headers) { scoped_refptr<net::HttpResponseHeaders> extra_response_headers) {
auto task_runner = base::CreateSequencedTaskRunner( auto task_runner = base::ThreadPool::CreateSequencedTaskRunner(
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}); base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN});
task_runner->PostTask( task_runner->PostTask(
FROM_HERE, FROM_HERE,

View file

@ -131,10 +131,8 @@ int ViewsDelegate::GetAppbarAutohideEdges(HMONITOR monitor,
if (monitor && !in_autohide_edges_callback_) { if (monitor && !in_autohide_edges_callback_) {
// TODO(robliao): Annotate this task with .WithCOM() once supported. // TODO(robliao): Annotate this task with .WithCOM() once supported.
// https://crbug.com/662122 // https://crbug.com/662122
base::PostTaskAndReplyWithResult( base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_BLOCKING},
{base::ThreadPool(), base::MayBlock(),
base::TaskPriority::USER_BLOCKING},
base::BindOnce(&GetAppbarAutohideEdgesOnWorkerThread, monitor), base::BindOnce(&GetAppbarAutohideEdgesOnWorkerThread, monitor),
base::BindOnce(&ViewsDelegate::OnGotAppbarAutohideEdges, base::BindOnce(&ViewsDelegate::OnGotAppbarAutohideEdges,
weak_factory_.GetWeakPtr(), std::move(callback), monitor, weak_factory_.GetWeakPtr(), std::move(callback), monitor,

View file

@ -24,6 +24,7 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "base/threading/scoped_blocking_call.h" #include "base/threading/scoped_blocking_call.h"
#include "base/win/registry.h" #include "base/win/registry.h"
#include "base/win/scoped_co_mem.h" #include "base/win/scoped_co_mem.h"
@ -317,8 +318,8 @@ std::string OpenPathOnThread(const base::FilePath& full_path) {
namespace platform_util { namespace platform_util {
void ShowItemInFolder(const base::FilePath& full_path) { void ShowItemInFolder(const base::FilePath& full_path) {
base::CreateCOMSTATaskRunner( base::ThreadPool::CreateSingleThreadTaskRunner(
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_BLOCKING}) {base::MayBlock(), base::TaskPriority::USER_BLOCKING})
->PostTask(FROM_HERE, ->PostTask(FROM_HERE,
base::BindOnce(&ShowItemInFolderOnWorkerThread, full_path)); base::BindOnce(&ShowItemInFolderOnWorkerThread, full_path));
} }
@ -327,7 +328,7 @@ void OpenPath(const base::FilePath& full_path, OpenCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
base::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
base::CreateCOMSTATaskRunner({base::ThreadPool(), base::MayBlock(), base::ThreadPool::CreateSingleThreadTaskRunner(({base::MayBlock(),
base::TaskPriority::USER_BLOCKING}) base::TaskPriority::USER_BLOCKING})
.get(), .get(),
FROM_HERE, base::BindOnce(&OpenPathOnThread, full_path), FROM_HERE, base::BindOnce(&OpenPathOnThread, full_path),
@ -338,8 +339,8 @@ void OpenExternal(const GURL& url,
const OpenExternalOptions& options, const OpenExternalOptions& options,
OpenCallback callback) { OpenCallback callback) {
base::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
base::CreateCOMSTATaskRunner({base::ThreadPool(), base::MayBlock(), base::ThreadPool::CreateCOMSTATaskRunner(
base::TaskPriority::USER_BLOCKING}) {base::MayBlock(), base::TaskPriority::USER_BLOCKING})
.get(), .get(),
FROM_HERE, base::BindOnce(&OpenExternalOnWorkerThread, url, options), FROM_HERE, base::BindOnce(&OpenExternalOnWorkerThread, url, options),
std::move(callback)); std::move(callback));