Commit 16071a83 authored by Etienne Pierre-doray's avatar Etienne Pierre-doray Committed by Commit Bot

[base] Require task posters to specify an explicit destination on ChromeOs

This patch makes it a requirement for all task traits to specify their
thread affinity on ChromeOs. Previously task traits that did not name a specific
thread would implicitly run on the thread pool, which could be
surprising. To make this more obvious, thread pool tasks must now use
the base::ThreadPool() trait.

Previous patch applied the checks on all platforms except ChromeOs which was failing:
https://chromium-review.googlesource.com/c/chromium/src/+/1769080
This CL enables the check on ChromeOs:
joelhockey@ fixed the chromeos build in
https://chromium-review.googlesource.com/c/chromium/src/+/1767447

Bug: 968047
Change-Id: I18efe212b94fe35f55e446c76ce2c3f20cc259f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1771976Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690825}
parent d480bee7
...@@ -256,10 +256,6 @@ class BASE_EXPORT TaskTraits { ...@@ -256,10 +256,6 @@ class BASE_EXPORT TaskTraits {
with_base_sync_primitives_( with_base_sync_primitives_(
trait_helpers::HasTrait<WithBaseSyncPrimitives, ArgTypes...>()), trait_helpers::HasTrait<WithBaseSyncPrimitives, ArgTypes...>()),
use_thread_pool_(trait_helpers::HasTrait<ThreadPool, ArgTypes...>()) { use_thread_pool_(trait_helpers::HasTrait<ThreadPool, ArgTypes...>()) {
#if !defined(OS_CHROMEOS)
// TODO(https://crbug.com/968047): Enable on Chrome OS in a separate CL.
// Initially disabled to keep the rule enforced on other platforms if the
// CL that enables it on Chrome OS is reverted.
constexpr bool has_thread_pool = constexpr bool has_thread_pool =
trait_helpers::HasTrait<ThreadPool, ArgTypes...>(); trait_helpers::HasTrait<ThreadPool, ArgTypes...>();
constexpr bool has_extension = constexpr bool has_extension =
...@@ -268,7 +264,6 @@ class BASE_EXPORT TaskTraits { ...@@ -268,7 +264,6 @@ class BASE_EXPORT TaskTraits {
has_thread_pool ^ has_extension, has_thread_pool ^ has_extension,
"Traits must explicitly specify a destination (e.g. ThreadPool or a " "Traits must explicitly specify a destination (e.g. ThreadPool or a "
"named thread like BrowserThread)"); "named thread like BrowserThread)");
#endif
} }
constexpr TaskTraits(const TaskTraits& other) = default; constexpr TaskTraits(const TaskTraits& other) = default;
......
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