Skip to content

Commit

Permalink
refactor: migrate base::ThreadPool() as trait to base::ThreadPool:: A…
Browse files Browse the repository at this point in the history
…PI (#22607)
  • Loading branch information
trop[bot] committed Mar 24, 2020
1 parent 9ee656f commit 9695790
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
7 changes: 3 additions & 4 deletions shell/browser/api/electron_api_content_tracing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "base/files/file_util.h"
#include "base/optional.h"
#include "base/task/thread_pool.h"
#include "base/threading/thread_restrictions.h"
#include "content/public/browser/tracing_controller.h"
#include "shell/common/gin_converters/callback_converter.h"
Expand Down Expand Up @@ -86,10 +87,8 @@ v8::Local<v8::Promise> StopRecording(gin_helper::Arguments* args) {
StopTracing(std::move(promise), base::make_optional(path));
} else {
// use a temporary file.
base::PostTaskAndReplyWithResult(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(),
base::TaskPriority::USER_VISIBLE},
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
base::BindOnce(CreateTemporaryFileOnIO),
base::BindOnce(StopTracing, std::move(promise)));
}
Expand Down
5 changes: 3 additions & 2 deletions shell/browser/api/electron_api_net_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <utility>

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

Expand Down
5 changes: 2 additions & 3 deletions shell/browser/api/electron_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1941,9 +1941,8 @@ void WebContents::Print(gin_helper::Arguments* args) {
settings.SetIntKey(printing::kSettingDpiVertical, dpi);
}

base::PostTaskAndReplyWithResult(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_BLOCKING},
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_BLOCKING},
base::BindOnce(&GetDefaultPrinterAsync),
base::BindOnce(&WebContents::OnGetDefaultPrinter,
weak_factory_.GetWeakPtr(), std::move(settings),
Expand Down
5 changes: 3 additions & 2 deletions shell/browser/common_web_contents_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "base/files/file_util.h"
#include "base/json/json_reader.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
Expand Down Expand Up @@ -183,8 +184,8 @@ bool IsDevToolsFileSystemAdded(content::WebContents* web_contents,

CommonWebContentsDelegate::CommonWebContentsDelegate()
: devtools_file_system_indexer_(new DevToolsFileSystemIndexer),
file_task_runner_(base::CreateSequencedTaskRunner(
{base::ThreadPool(), base::MayBlock()})),
file_task_runner_(
base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})),
weak_factory_(this) {}

CommonWebContentsDelegate::~CommonWebContentsDelegate() = default;
Expand Down
4 changes: 2 additions & 2 deletions shell/browser/electron_download_manager_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ bool ElectronDownloadManagerDelegate::DetermineDownloadTarget(
base::FilePath default_download_path =
browser_context->prefs()->GetFilePath(prefs::kDownloadDefaultDirectory);

base::PostTaskAndReplyWithResult(
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT,
{base::MayBlock(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN},
base::BindOnce(&CreateDownloadPath, download->GetURL(),
download->GetContentDisposition(),
Expand Down
5 changes: 3 additions & 2 deletions shell/browser/net/asar/asar_url_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "base/strings/stringprintf.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "content/public/browser/file_url_loader.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
Expand Down Expand Up @@ -304,8 +305,8 @@ void CreateAsarURLLoader(
network::mojom::URLLoaderRequest loader,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
scoped_refptr<net::HttpResponseHeaders> extra_response_headers) {
auto task_runner = base::CreateSequencedTaskRunner(
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE,
auto task_runner = base::ThreadPool::CreateSequencedTaskRunner(
{base::MayBlock(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN});
task_runner->PostTask(
FROM_HERE,
Expand Down
6 changes: 2 additions & 4 deletions shell/browser/ui/views/electron_views_delegate_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,8 @@ int ViewsDelegate::GetAppbarAutohideEdges(HMONITOR monitor,
if (monitor && !in_autohide_edges_callback_) {
// TODO(robliao): Annotate this task with .WithCOM() once supported.
// https://crbug.com/662122
base::PostTaskAndReplyWithResult(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(),
base::TaskPriority::USER_BLOCKING},
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_BLOCKING},
base::BindOnce(&GetAppbarAutohideEdgesOnWorkerThread, monitor),
base::BindOnce(&ViewsDelegate::OnGotAppbarAutohideEdges,
weak_factory_.GetWeakPtr(), std::move(callback), monitor,
Expand Down
13 changes: 7 additions & 6 deletions shell/common/platform_util_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "base/strings/string_util.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 "base/win/registry.h"
#include "base/win/scoped_co_mem.h"
Expand Down Expand Up @@ -317,8 +318,8 @@ std::string OpenPathOnThread(const base::FilePath& full_path) {
namespace platform_util {

void ShowItemInFolder(const base::FilePath& full_path) {
base::CreateCOMSTATaskRunner(
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_BLOCKING})
base::ThreadPool::CreateSingleThreadTaskRunner(
{base::MayBlock(), base::TaskPriority::USER_BLOCKING})
->PostTask(FROM_HERE,
base::BindOnce(&ShowItemInFolderOnWorkerThread, full_path));
}
Expand All @@ -327,8 +328,8 @@ void OpenPath(const base::FilePath& full_path, OpenCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);

base::PostTaskAndReplyWithResult(
base::CreateCOMSTATaskRunner({base::ThreadPool(), base::MayBlock(),
base::TaskPriority::USER_BLOCKING})
base::ThreadPool::CreateCOMSTATaskRunner(
{base::MayBlock(), base::TaskPriority::USER_BLOCKING})
.get(),
FROM_HERE, base::BindOnce(&OpenPathOnThread, full_path),
std::move(callback));
Expand All @@ -338,8 +339,8 @@ void OpenExternal(const GURL& url,
const OpenExternalOptions& options,
OpenCallback callback) {
base::PostTaskAndReplyWithResult(
base::CreateCOMSTATaskRunner({base::ThreadPool(), base::MayBlock(),
base::TaskPriority::USER_BLOCKING})
base::ThreadPool::CreateCOMSTATaskRunner(
{base::MayBlock(), base::TaskPriority::USER_BLOCKING})
.get(),
FROM_HERE, base::BindOnce(&OpenExternalOnWorkerThread, url, options),
std::move(callback));
Expand Down

0 comments on commit 9695790

Please sign in to comment.