Commit ef9451af authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

[blink] Migrate worker_pool:: interface away from base::ThreadPool()-as-a-trait

base::ThreadPool:: (API as a destination) is the new desired paradigm.

worker_pool:: was already API-as-destination; can remove redundant
ThreadPool() trait with new API.

R=haraken@chromium.org

Bug: 1026641
Change-Id: Ida08feab710143da2308ef1361550a9aced39d2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2105454
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750565}
parent 60050bad
...@@ -501,8 +501,7 @@ bool ScriptStreamer::TryStartStreaming( ...@@ -501,8 +501,7 @@ bool ScriptStreamer::TryStartStreaming(
// they wait for more input. // they wait for more input.
// TODO(leszeks): Decrease the priority of these tasks where possible. // TODO(leszeks): Decrease the priority of these tasks where possible.
worker_pool::PostTask( worker_pool::PostTask(
FROM_HERE, FROM_HERE, {base::TaskPriority::USER_BLOCKING, base::MayBlock()},
{base::ThreadPool(), base::TaskPriority::USER_BLOCKING, base::MayBlock()},
CrossThreadBindOnce(RunScriptStreamingTask, CrossThreadBindOnce(RunScriptStreamingTask,
WTF::Passed(std::move(script_streaming_task)), WTF::Passed(std::move(script_streaming_task)),
WrapCrossThreadPersistent(this), WrapCrossThreadPersistent(this),
......
...@@ -368,8 +368,7 @@ void MediaStreamAudioProcessor::OnStartDump(base::File dump_file) { ...@@ -368,8 +368,7 @@ void MediaStreamAudioProcessor::OnStartDump(base::File dump_file) {
} else { } else {
// Post the file close to avoid blocking the main thread. // Post the file close to avoid blocking the main thread.
worker_pool::PostTask( worker_pool::PostTask(
FROM_HERE, FROM_HERE, {base::TaskPriority::LOWEST, base::MayBlock()},
{base::ThreadPool(), base::TaskPriority::LOWEST, base::MayBlock()},
CrossThreadBindOnce([](base::File) {}, std::move(dump_file))); CrossThreadBindOnce([](base::File) {}, std::move(dump_file)));
} }
} }
......
...@@ -62,8 +62,7 @@ void AudioServiceAudioProcessorProxy::OnStartDump(base::File dump_file) { ...@@ -62,8 +62,7 @@ void AudioServiceAudioProcessorProxy::OnStartDump(base::File dump_file) {
} else { } else {
// Post the file close to avoid blocking the main thread. // Post the file close to avoid blocking the main thread.
worker_pool::PostTask( worker_pool::PostTask(
FROM_HERE, FROM_HERE, {base::TaskPriority::LOWEST, base::MayBlock()},
{base::ThreadPool(), base::TaskPriority::LOWEST, base::MayBlock()},
CrossThreadBindOnce([](base::File) {}, std::move(dump_file))); CrossThreadBindOnce([](base::File) {}, std::move(dump_file)));
} }
} }
......
...@@ -5,24 +5,22 @@ ...@@ -5,24 +5,22 @@
#include "third_party/blink/renderer/platform/scheduler/public/worker_pool.h" #include "third_party/blink/renderer/platform/scheduler/public/worker_pool.h"
#include "base/location.h" #include "base/location.h"
#include "base/task/post_task.h" #include "base/task/thread_pool.h"
namespace blink { namespace blink {
namespace worker_pool { namespace worker_pool {
void PostTask(const base::Location& location, CrossThreadOnceClosure closure) { void PostTask(const base::Location& location, CrossThreadOnceClosure closure) {
PostTask( PostTask(location, {base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
location, std::move(closure));
{base::ThreadPool(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
std::move(closure));
} }
void PostTask(const base::Location& location, void PostTask(const base::Location& location,
const base::TaskTraits& traits, const base::TaskTraits& traits,
CrossThreadOnceClosure closure) { CrossThreadOnceClosure closure) {
base::PostTask(location, traits, base::ThreadPool::PostTask(location, traits,
ConvertToBaseOnceCallback(std::move(closure))); ConvertToBaseOnceCallback(std::move(closure)));
} }
} // namespace worker_pool } // namespace worker_pool
......
...@@ -15,9 +15,9 @@ namespace blink { ...@@ -15,9 +15,9 @@ namespace blink {
namespace worker_pool { namespace worker_pool {
// These are a thin wrapper around base::ThreadPoolInstance to ensure that all // These are a thin wrapper around base::ThreadPool to ensure that all callers
// callers use CrossThreadBindOnce instead of base::Bind to ensure that // use CrossThreadBindOnce instead of base::Bind to ensure that all
// all non-thread-safe objects are copied properly. // non-thread-safe objects are copied properly.
// //
// All tasks that do not care about which thread they are running on // All tasks that do not care about which thread they are running on
// (e.g. compressing/uncompressing tasks) use this API. // (e.g. compressing/uncompressing tasks) use this API.
......
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