[base] Rename TaskScheduler to ThreadPool
Reason: with the advent of other scheduling primitives in //base
(i.e. SequenceManager), TaskScheduler was no longer the only component
responsible for scheduling tasks. We will from now on refer to the
whole of //base/task as the "task scheduling infrastructure".
There are other types named "TaskScheduler" outside of base:: so
s/TaskScheduler/ThreadPool/ across the codebase wasn't possible.
Instead, this CL did:
1) base/task/task_scheduler => base/task/thread_pool
(catches all files with includes)
1.1) Careful manual search to add files without includes
(e.g. missing IWYU, docs, etc.)
2) TaskScheduler => ThreadPool in all files affected by (1)
3) task_scheduler => thread_pool in all files affected by (1)
4) "task scheduler" => "thread pool" in all files affected by (1)
4) Move task_scheduler_util like headers in
//content //components and //ios
Also:
* Renamed UMA metrics from TaskScheduler.* to ThreadPool.*
and dropped "Pool" from worker pool name suffixes.
* Renamed TaskScheduler*Worker thread names to ThreadPool*Worker
* In base/android: NativeTaskScheduler => NativeScheduler as it
was referring to the whole of base/task.
TaskSchedulerTest.java => NativePostTaskTest.java (former DNE)
* Intentionally ignoring IWYU violations in this already too large
CL.
In follow-up:
* Rename other types as well:
SchedulerWorker => WorkerThread
SchedulerWorkerPool* => WorkerThreadGroup*
Bug: 951388
Change-Id: I5bc2688b593c7682ef7e56d6b228539970ba107e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1561552
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Ilya Sherman <isherman@chromium.org>
Reviewed-by: Richard Coles <torne@chromium.org>
Reviewed-by: Joe Mason <joenotcharles@google.com>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#650997}
diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc
index 3cc4dc7..5aaf0733 100644
--- a/android_webview/browser/aw_content_browser_client.cc
+++ b/android_webview/browser/aw_content_browser_client.cc
@@ -113,7 +113,7 @@
namespace android_webview {
namespace {
-static bool g_should_create_task_scheduler = true;
+static bool g_should_create_thread_pool = true;
#if DCHECK_IS_ON()
// A boolean value to determine if the NetworkContext has been created yet. This
@@ -905,8 +905,8 @@
url, has_user_gesture, is_redirect, is_main_frame, ignore_navigation);
}
-bool AwContentBrowserClient::ShouldCreateTaskScheduler() {
- return g_should_create_task_scheduler;
+bool AwContentBrowserClient::ShouldCreateThreadPool() {
+ return g_should_create_thread_pool;
}
std::unique_ptr<content::LoginDelegate>
@@ -1055,8 +1055,8 @@
}
// static
-void AwContentBrowserClient::DisableCreatingTaskScheduler() {
- g_should_create_task_scheduler = false;
+void AwContentBrowserClient::DisableCreatingThreadPool() {
+ g_should_create_thread_pool = false;
}
} // namespace android_webview
diff --git a/android_webview/browser/aw_content_browser_client.h b/android_webview/browser/aw_content_browser_client.h
index 939c6819..476e3bf 100644
--- a/android_webview/browser/aw_content_browser_client.h
+++ b/android_webview/browser/aw_content_browser_client.h
@@ -194,7 +194,7 @@
bool is_main_frame,
ui::PageTransition transition,
bool* ignore_navigation) override;
- bool ShouldCreateTaskScheduler() override;
+ bool ShouldCreateThreadPool() override;
std::unique_ptr<content::LoginDelegate> CreateLoginDelegate(
const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents,
@@ -251,7 +251,7 @@
content::SpeechRecognitionManagerDelegate*
CreateSpeechRecognitionManagerDelegate() override;
- static void DisableCreatingTaskScheduler();
+ static void DisableCreatingThreadPool();
private:
safe_browsing::UrlCheckerDelegate* GetSafeBrowsingUrlCheckerDelegate();
diff --git a/android_webview/browser/aw_content_browser_client_unittest.cc b/android_webview/browser/aw_content_browser_client_unittest.cc
index af3e83a..7ae0566 100644
--- a/android_webview/browser/aw_content_browser_client_unittest.cc
+++ b/android_webview/browser/aw_content_browser_client_unittest.cc
@@ -24,13 +24,13 @@
base::test::ScopedFeatureList feature_list_;
};
-TEST_F(AwContentBrowserClientTest, DisableCreatingTaskScheduler) {
+TEST_F(AwContentBrowserClientTest, DisableCreatingThreadPool) {
AwFeatureListCreator aw_feature_list_creator;
AwContentBrowserClient client(&aw_feature_list_creator);
- EXPECT_TRUE(client.ShouldCreateTaskScheduler());
+ EXPECT_TRUE(client.ShouldCreateThreadPool());
- AwContentBrowserClient::DisableCreatingTaskScheduler();
- EXPECT_FALSE(client.ShouldCreateTaskScheduler());
+ AwContentBrowserClient::DisableCreatingThreadPool();
+ EXPECT_FALSE(client.ShouldCreateThreadPool());
}
// Tests that constraints on trust for Symantec-issued certificates are not
diff --git a/ash/wallpaper/wallpaper_controller_unittest.cc b/ash/wallpaper/wallpaper_controller_unittest.cc
index 7dd32eb..52ba597 100644
--- a/ash/wallpaper/wallpaper_controller_unittest.cc
+++ b/ash/wallpaper/wallpaper_controller_unittest.cc
@@ -27,7 +27,7 @@
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/bind_test_util.h"
#include "base/time/time_override.h"
#include "chromeos/constants/chromeos_switches.h"
@@ -211,7 +211,7 @@
TaskObserver task_observer;
base::MessageLoopCurrent::Get()->AddTaskObserver(&task_observer);
// May spin message loop.
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
base::RunLoop().RunUntilIdle();
base::MessageLoopCurrent::Get()->RemoveTaskObserver(&task_observer);
diff --git a/base/BUILD.gn b/base/BUILD.gn
index fadacd7..dc6880f 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -804,64 +804,64 @@
"task/task_features.cc",
"task/task_features.h",
"task/task_observer.h",
- "task/task_scheduler/can_schedule_sequence_observer.h",
- "task/task_scheduler/delayed_task_manager.cc",
- "task/task_scheduler/delayed_task_manager.h",
- "task/task_scheduler/environment_config.cc",
- "task/task_scheduler/environment_config.h",
- "task/task_scheduler/initialization_util.cc",
- "task/task_scheduler/initialization_util.h",
- "task/task_scheduler/platform_native_worker_pool.cc",
- "task/task_scheduler/platform_native_worker_pool.h",
- "task/task_scheduler/platform_native_worker_pool_mac.h",
- "task/task_scheduler/platform_native_worker_pool_mac.mm",
- "task/task_scheduler/platform_native_worker_pool_win.cc",
- "task/task_scheduler/platform_native_worker_pool_win.h",
- "task/task_scheduler/priority_queue.cc",
- "task/task_scheduler/priority_queue.h",
- "task/task_scheduler/scheduler_lock.h",
- "task/task_scheduler/scheduler_lock_impl.cc",
- "task/task_scheduler/scheduler_lock_impl.h",
- "task/task_scheduler/scheduler_parallel_task_runner.cc",
- "task/task_scheduler/scheduler_parallel_task_runner.h",
- "task/task_scheduler/scheduler_sequenced_task_runner.cc",
- "task/task_scheduler/scheduler_sequenced_task_runner.h",
- "task/task_scheduler/scheduler_single_thread_task_runner_manager.cc",
- "task/task_scheduler/scheduler_single_thread_task_runner_manager.h",
- "task/task_scheduler/scheduler_task_runner_delegate.cc",
- "task/task_scheduler/scheduler_task_runner_delegate.h",
- "task/task_scheduler/scheduler_worker.cc",
- "task/task_scheduler/scheduler_worker.h",
- "task/task_scheduler/scheduler_worker_observer.h",
- "task/task_scheduler/scheduler_worker_params.h",
- "task/task_scheduler/scheduler_worker_pool.cc",
- "task/task_scheduler/scheduler_worker_pool.h",
- "task/task_scheduler/scheduler_worker_pool_impl.cc",
- "task/task_scheduler/scheduler_worker_pool_impl.h",
- "task/task_scheduler/scheduler_worker_pool_params.cc",
- "task/task_scheduler/scheduler_worker_pool_params.h",
- "task/task_scheduler/scheduler_worker_stack.cc",
- "task/task_scheduler/scheduler_worker_stack.h",
- "task/task_scheduler/sequence.cc",
- "task/task_scheduler/sequence.h",
- "task/task_scheduler/sequence_sort_key.cc",
- "task/task_scheduler/sequence_sort_key.h",
- "task/task_scheduler/service_thread.cc",
- "task/task_scheduler/service_thread.h",
- "task/task_scheduler/task.cc",
- "task/task_scheduler/task.h",
- "task/task_scheduler/task_scheduler.cc",
- "task/task_scheduler/task_scheduler.h",
- "task/task_scheduler/task_scheduler_impl.cc",
- "task/task_scheduler/task_scheduler_impl.h",
- "task/task_scheduler/task_source.cc",
- "task/task_scheduler/task_source.h",
- "task/task_scheduler/task_tracker.cc",
- "task/task_scheduler/task_tracker.h",
- "task/task_scheduler/tracked_ref.h",
"task/task_traits.cc",
"task/task_traits.h",
"task/task_traits_extension.h",
+ "task/thread_pool/can_schedule_sequence_observer.h",
+ "task/thread_pool/delayed_task_manager.cc",
+ "task/thread_pool/delayed_task_manager.h",
+ "task/thread_pool/environment_config.cc",
+ "task/thread_pool/environment_config.h",
+ "task/thread_pool/initialization_util.cc",
+ "task/thread_pool/initialization_util.h",
+ "task/thread_pool/platform_native_worker_pool.cc",
+ "task/thread_pool/platform_native_worker_pool.h",
+ "task/thread_pool/platform_native_worker_pool_mac.h",
+ "task/thread_pool/platform_native_worker_pool_mac.mm",
+ "task/thread_pool/platform_native_worker_pool_win.cc",
+ "task/thread_pool/platform_native_worker_pool_win.h",
+ "task/thread_pool/priority_queue.cc",
+ "task/thread_pool/priority_queue.h",
+ "task/thread_pool/scheduler_lock.h",
+ "task/thread_pool/scheduler_lock_impl.cc",
+ "task/thread_pool/scheduler_lock_impl.h",
+ "task/thread_pool/scheduler_parallel_task_runner.cc",
+ "task/thread_pool/scheduler_parallel_task_runner.h",
+ "task/thread_pool/scheduler_sequenced_task_runner.cc",
+ "task/thread_pool/scheduler_sequenced_task_runner.h",
+ "task/thread_pool/scheduler_single_thread_task_runner_manager.cc",
+ "task/thread_pool/scheduler_single_thread_task_runner_manager.h",
+ "task/thread_pool/scheduler_task_runner_delegate.cc",
+ "task/thread_pool/scheduler_task_runner_delegate.h",
+ "task/thread_pool/scheduler_worker.cc",
+ "task/thread_pool/scheduler_worker.h",
+ "task/thread_pool/scheduler_worker_observer.h",
+ "task/thread_pool/scheduler_worker_params.h",
+ "task/thread_pool/scheduler_worker_pool.cc",
+ "task/thread_pool/scheduler_worker_pool.h",
+ "task/thread_pool/scheduler_worker_pool_impl.cc",
+ "task/thread_pool/scheduler_worker_pool_impl.h",
+ "task/thread_pool/scheduler_worker_pool_params.cc",
+ "task/thread_pool/scheduler_worker_pool_params.h",
+ "task/thread_pool/scheduler_worker_stack.cc",
+ "task/thread_pool/scheduler_worker_stack.h",
+ "task/thread_pool/sequence.cc",
+ "task/thread_pool/sequence.h",
+ "task/thread_pool/sequence_sort_key.cc",
+ "task/thread_pool/sequence_sort_key.h",
+ "task/thread_pool/service_thread.cc",
+ "task/thread_pool/service_thread.h",
+ "task/thread_pool/task.cc",
+ "task/thread_pool/task.h",
+ "task/thread_pool/task_source.cc",
+ "task/thread_pool/task_source.h",
+ "task/thread_pool/task_tracker.cc",
+ "task/thread_pool/task_tracker.h",
+ "task/thread_pool/thread_pool.cc",
+ "task/thread_pool/thread_pool.h",
+ "task/thread_pool/thread_pool_impl.cc",
+ "task/thread_pool/thread_pool_impl.h",
+ "task/thread_pool/tracked_ref.h",
"task_runner.cc",
"task_runner.h",
"task_runner_util.h",
@@ -1158,8 +1158,8 @@
"synchronization/waitable_event_posix.cc",
"synchronization/waitable_event_watcher_posix.cc",
"system/sys_info_posix.cc",
- "task/task_scheduler/task_tracker_posix.cc",
- "task/task_scheduler/task_tracker_posix.h",
+ "task/thread_pool/task_tracker_posix.cc",
+ "task/thread_pool/task_tracker_posix.h",
"threading/platform_thread_internal_posix.cc",
"threading/platform_thread_internal_posix.h",
"threading/platform_thread_posix.cc",
@@ -1515,8 +1515,8 @@
"synchronization/waitable_event_watcher_posix.cc",
"system/sys_info_fuchsia.cc",
"system/sys_info_posix.cc",
- "task/task_scheduler/task_tracker_posix.cc",
- "task/task_scheduler/task_tracker_posix.h",
+ "task/thread_pool/task_tracker_posix.cc",
+ "task/thread_pool/task_tracker_posix.h",
"threading/platform_thread_fuchsia.cc",
"threading/platform_thread_posix.cc",
"threading/thread_local_storage_posix.cc",
@@ -1597,8 +1597,8 @@
"sync_socket_posix.cc",
"system/sys_info.cc",
"system/sys_info_posix.cc",
- "task/task_scheduler/initialization_util.cc",
- "task/task_scheduler/initialization_util.h",
+ "task/thread_pool/initialization_util.cc",
+ "task/thread_pool/initialization_util.h",
]
if (is_nacl_nonsfi) {
@@ -1618,8 +1618,8 @@
"process/launch.h",
"process/launch_posix.cc",
"rand_util_posix.cc",
- "task/task_scheduler/task_tracker_posix.cc",
- "task/task_scheduler/task_tracker_posix.h",
+ "task/thread_pool/task_tracker_posix.cc",
+ "task/thread_pool/task_tracker_posix.h",
]
}
} else {
@@ -1877,8 +1877,8 @@
"strings/sys_string_conversions_mac.mm",
"synchronization/waitable_event_mac.cc",
"system/sys_info_ios.mm",
- "task/task_scheduler/platform_native_worker_pool_mac.h",
- "task/task_scheduler/platform_native_worker_pool_mac.mm",
+ "task/thread_pool/platform_native_worker_pool_mac.h",
+ "task/thread_pool/platform_native_worker_pool_mac.mm",
"threading/platform_thread_mac.mm",
"time/time_conversion_posix.cc",
"time/time_mac.cc",
@@ -2156,7 +2156,7 @@
"observer_list_perftest.cc",
"strings/string_util_perftest.cc",
"task/sequence_manager/sequence_manager_perftest.cc",
- "task/task_scheduler/task_scheduler_perftest.cc",
+ "task/thread_pool/thread_pool_perftest.cc",
# "test/run_all_unittests.cc",
"json/json_perftest.cc",
@@ -2581,27 +2581,27 @@
"task/sequence_manager/work_deduplicator_unittest.cc",
"task/sequence_manager/work_queue_sets_unittest.cc",
"task/sequence_manager/work_queue_unittest.cc",
- "task/task_scheduler/delayed_task_manager_unittest.cc",
- "task/task_scheduler/priority_queue_unittest.cc",
- "task/task_scheduler/scheduler_lock_unittest.cc",
- "task/task_scheduler/scheduler_single_thread_task_runner_manager_unittest.cc",
- "task/task_scheduler/scheduler_worker_pool_impl_unittest.cc",
- "task/task_scheduler/scheduler_worker_pool_unittest.cc",
- "task/task_scheduler/scheduler_worker_stack_unittest.cc",
- "task/task_scheduler/scheduler_worker_unittest.cc",
- "task/task_scheduler/sequence_sort_key_unittest.cc",
- "task/task_scheduler/sequence_unittest.cc",
- "task/task_scheduler/service_thread_unittest.cc",
- "task/task_scheduler/task_scheduler_impl_unittest.cc",
- "task/task_scheduler/task_source_unittest.cc",
- "task/task_scheduler/task_tracker_unittest.cc",
- "task/task_scheduler/test_task_factory.cc",
- "task/task_scheduler/test_task_factory.h",
- "task/task_scheduler/test_utils.cc",
- "task/task_scheduler/test_utils.h",
- "task/task_scheduler/tracked_ref_unittest.cc",
"task/task_traits_extension_unittest.cc",
"task/task_traits_unittest.cc",
+ "task/thread_pool/delayed_task_manager_unittest.cc",
+ "task/thread_pool/priority_queue_unittest.cc",
+ "task/thread_pool/scheduler_lock_unittest.cc",
+ "task/thread_pool/scheduler_single_thread_task_runner_manager_unittest.cc",
+ "task/thread_pool/scheduler_worker_pool_impl_unittest.cc",
+ "task/thread_pool/scheduler_worker_pool_unittest.cc",
+ "task/thread_pool/scheduler_worker_stack_unittest.cc",
+ "task/thread_pool/scheduler_worker_unittest.cc",
+ "task/thread_pool/sequence_sort_key_unittest.cc",
+ "task/thread_pool/sequence_unittest.cc",
+ "task/thread_pool/service_thread_unittest.cc",
+ "task/thread_pool/task_source_unittest.cc",
+ "task/thread_pool/task_tracker_unittest.cc",
+ "task/thread_pool/test_task_factory.cc",
+ "task/thread_pool/test_task_factory.h",
+ "task/thread_pool/test_utils.cc",
+ "task/thread_pool/test_utils.h",
+ "task/thread_pool/thread_pool_impl_unittest.cc",
+ "task/thread_pool/tracked_ref_unittest.cc",
"task_runner_util_unittest.cc",
"template_util_unittest.cc",
"test/launcher/test_results_tracker_unittest.cc",
@@ -2751,7 +2751,7 @@
"message_loop/message_loop_io_posix_unittest.cc",
"posix/file_descriptor_shuffle_unittest.cc",
"posix/unix_domain_socket_unittest.cc",
- "task/task_scheduler/task_tracker_posix_unittest.cc",
+ "task/thread_pool/task_tracker_posix_unittest.cc",
]
}
@@ -2875,7 +2875,7 @@
"fuchsia/service_provider_impl_unittest.cc",
"message_loop/message_loop_io_posix_unittest.cc",
"posix/file_descriptor_shuffle_unittest.cc",
- "task/task_scheduler/task_tracker_posix_unittest.cc",
+ "task/thread_pool/task_tracker_posix_unittest.cc",
]
# TODO(crbug.com/851641): FilePatchWatcherImpl is not implemented.
@@ -3266,7 +3266,7 @@
"test/android/javatests/src/org/chromium/base/test/params/ParameterProvider.java",
"test/android/javatests/src/org/chromium/base/test/params/ParameterSet.java",
"test/android/javatests/src/org/chromium/base/test/task/SchedulerTestHelpers.java",
- "test/android/javatests/src/org/chromium/base/test/task/TaskSchedulerTestHelpers.java",
+ "test/android/javatests/src/org/chromium/base/test/task/ThreadPoolTestHelpers.java",
"test/android/javatests/src/org/chromium/base/test/util/AdvancedMockContext.java",
"test/android/javatests/src/org/chromium/base/test/util/AnnotationRule.java",
"test/android/javatests/src/org/chromium/base/test/util/CallbackHelper.java",
diff --git a/base/android/java/src/org/chromium/base/task/DefaultTaskExecutor.java b/base/android/java/src/org/chromium/base/task/DefaultTaskExecutor.java
index 87db587b..0613e38 100644
--- a/base/android/java/src/org/chromium/base/task/DefaultTaskExecutor.java
+++ b/base/android/java/src/org/chromium/base/task/DefaultTaskExecutor.java
@@ -8,7 +8,7 @@
import java.util.Map;
/**
- * The default {@link TaskExecutor} which maps directly to base::TaskScheduler.
+ * The default {@link TaskExecutor} which maps directly to base::ThreadPool.
*/
class DefaultTaskExecutor implements TaskExecutor {
Map<TaskTraits, TaskRunner> mTraitsToRunnerMap = new HashMap<>();
diff --git a/base/android/java/src/org/chromium/base/task/PostTask.java b/base/android/java/src/org/chromium/base/task/PostTask.java
index 0e4e9cf..c66d228b 100644
--- a/base/android/java/src/org/chromium/base/task/PostTask.java
+++ b/base/android/java/src/org/chromium/base/task/PostTask.java
@@ -237,7 +237,7 @@
}
@CalledByNative
- private static void onNativeTaskSchedulerReady() {
+ private static void onNativeSchedulerReady() {
synchronized (sLock) {
for (TaskRunner taskRunner : sPreNativeTaskRunners) {
taskRunner.initNativeTaskRunner();
@@ -248,7 +248,7 @@
// This is here to make C++ tests work.
@CalledByNative
- private static void onNativeTaskSchedulerShutdown() {
+ private static void onNativeSchedulerShutdown() {
synchronized (sLock) {
sPreNativeTaskRunners =
Collections.newSetFromMap(new WeakHashMap<TaskRunner, Boolean>());
diff --git a/base/android/javatests/src/org/chromium/base/task/PostTaskTest.java b/base/android/javatests/src/org/chromium/base/task/PostTaskTest.java
index f414726..022013b 100644
--- a/base/android/javatests/src/org/chromium/base/task/PostTaskTest.java
+++ b/base/android/javatests/src/org/chromium/base/task/PostTaskTest.java
@@ -26,7 +26,7 @@
* Note due to layering concerns we can't test post native functionality in a
* base javatest. Instead see:
* content/public/android/javatests/src/org/chromium/content/browser/scheduler/
- * TaskSchedulerTest.java
+ * NativePostTaskTest.java
*/
@RunWith(BaseJUnit4ClassRunner.class)
public class PostTaskTest {
diff --git a/base/android/javatests/src/org/chromium/base/task/SequencedTaskRunnerImplTest.java b/base/android/javatests/src/org/chromium/base/task/SequencedTaskRunnerImplTest.java
index 2efd36d..51dc883a 100644
--- a/base/android/javatests/src/org/chromium/base/task/SequencedTaskRunnerImplTest.java
+++ b/base/android/javatests/src/org/chromium/base/task/SequencedTaskRunnerImplTest.java
@@ -24,7 +24,7 @@
* Note due to layering concerns we can't test post native functionality in a
* base javatest. Instead see:
* content/public/android/javatests/src/org/chromium/content/browser/scheduler/
- * TaskSchedulerTest.java
+ * NativePostTaskTest.java
*/
@RunWith(BaseJUnit4ClassRunner.class)
public class SequencedTaskRunnerImplTest {
diff --git a/base/android/javatests/src/org/chromium/base/task/SingleThreadTaskRunnerImplTest.java b/base/android/javatests/src/org/chromium/base/task/SingleThreadTaskRunnerImplTest.java
index 41754a1..8e68b11 100644
--- a/base/android/javatests/src/org/chromium/base/task/SingleThreadTaskRunnerImplTest.java
+++ b/base/android/javatests/src/org/chromium/base/task/SingleThreadTaskRunnerImplTest.java
@@ -30,7 +30,7 @@
* Note due to layering concerns we can't test post native functionality in a
* base javatest. Instead see:
* content/public/android/javatests/src/org/chromium/content/browser/scheduler/
- * TaskSchedulerTest.java
+ * NativePostTaskTest.java
*/
@RunWith(BaseJUnit4ClassRunner.class)
public class SingleThreadTaskRunnerImplTest {
diff --git a/base/android/javatests/src/org/chromium/base/task/TaskRunnerImplTest.java b/base/android/javatests/src/org/chromium/base/task/TaskRunnerImplTest.java
index c8c0de7..f4da7e8 100644
--- a/base/android/javatests/src/org/chromium/base/task/TaskRunnerImplTest.java
+++ b/base/android/javatests/src/org/chromium/base/task/TaskRunnerImplTest.java
@@ -18,7 +18,7 @@
* Note due to layering concerns we can't test post native functionality in a
* base javatest. Instead see:
* content/public/android/javatests/src/org/chromium/content/browser/scheduler/
- * TaskSchedulerTest.java
+ * NativePostTaskTest.java
*/
@RunWith(BaseJUnit4ClassRunner.class)
public class TaskRunnerImplTest {
diff --git a/base/android/task_scheduler/post_task_android.cc b/base/android/task_scheduler/post_task_android.cc
index 98319c5c..e1069c7 100644
--- a/base/android/task_scheduler/post_task_android.cc
+++ b/base/android/task_scheduler/post_task_android.cc
@@ -7,7 +7,7 @@
#include "base/no_destructor.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "jni/PostTask_jni.h"
#include "jni/Runnable_jni.h"
@@ -15,14 +15,12 @@
// static
void PostTaskAndroid::SignalNativeSchedulerReady() {
- Java_PostTask_onNativeTaskSchedulerReady(
- base::android::AttachCurrentThread());
+ Java_PostTask_onNativeSchedulerReady(base::android::AttachCurrentThread());
}
// static
void PostTaskAndroid::SignalNativeSchedulerShutdown() {
- Java_PostTask_onNativeTaskSchedulerShutdown(
- base::android::AttachCurrentThread());
+ Java_PostTask_onNativeSchedulerShutdown(base::android::AttachCurrentThread());
}
namespace {
diff --git a/base/android/task_scheduler/post_task_android.h b/base/android/task_scheduler/post_task_android.h
index 753210f..1d60711 100644
--- a/base/android/task_scheduler/post_task_android.h
+++ b/base/android/task_scheduler/post_task_android.h
@@ -14,12 +14,12 @@
// C++ interface for PostTask.java
class BASE_EXPORT PostTaskAndroid {
public:
- // Routes Java tasks posted via TaskScheduler APIs through the C++
- // TaskScheduler.
+ // Routes tasks posted via the Java PostTask APIs through the C++ PostTask
+ // APIs. Invoked once the C++ PostTask APIs are fully initialized.
static void SignalNativeSchedulerReady();
- // Signals that the C++ scheduler has shutdown. Needed to make unit tests that
- // repeatedly create and destroy the scheduler work.
+ // Signals that the C++ PostTask APIs have shutdown. Needed to make unit tests
+ // that repeatedly create and destroy the scheduler work.
static void SignalNativeSchedulerShutdown();
static TaskTraits CreateTaskTraits(
diff --git a/base/files/file_descriptor_watcher_posix.h b/base/files/file_descriptor_watcher_posix.h
index eccae13..3751cef 100644
--- a/base/files/file_descriptor_watcher_posix.h
+++ b/base/files/file_descriptor_watcher_posix.h
@@ -97,7 +97,7 @@
// returned Controller is deleted (deletion must happen on the current
// sequence). To call these methods, a FileDescriptorWatcher must have been
// instantiated on the current thread and SequencedTaskRunnerHandle::IsSet()
- // must return true (these conditions are met at least on all TaskScheduler
+ // must return true (these conditions are met at least on all ThreadPool
// threads as well as on threads backed by a MessageLoopForIO). |fd| must
// outlive the returned Controller.
static std::unique_ptr<Controller> WatchReadable(int fd,
diff --git a/base/i18n/streaming_utf8_validator_unittest.cc b/base/i18n/streaming_utf8_validator_unittest.cc
index 0742acc..9c9bd5b3 100644
--- a/base/i18n/streaming_utf8_validator_unittest.cc
+++ b/base/i18n/streaming_utf8_validator_unittest.cc
@@ -33,7 +33,7 @@
#include "base/strings/utf_string_conversion_utils.h"
#include "base/synchronization/lock.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "third_party/icu/source/common/unicode/utf8.h"
#endif // BASE_I18N_UTF8_VALIDATOR_THOROUGH_TEST
@@ -110,7 +110,7 @@
};
TEST_F(StreamingUtf8ValidatorThoroughTest, TestEverything) {
- base::TaskScheduler::CreateAndStartWithDefaultParams(
+ base::ThreadPool::CreateAndStartWithDefaultParams(
"StreamingUtf8ValidatorThoroughTest");
{
base::AutoLock al(lock_);
@@ -125,9 +125,9 @@
begin += kThoroughTestChunkSize;
} while (begin != 0);
}
- base::TaskScheduler::GetInstance()->Shutdown();
- base::TaskScheduler::GetInstance()->JoinForTesting();
- base::TaskScheduler::SetInstance(nullptr);
+ base::ThreadPool::GetInstance()->Shutdown();
+ base::ThreadPool::GetInstance()->JoinForTesting();
+ base::ThreadPool::SetInstance(nullptr);
}
#endif // BASE_I18N_UTF8_VALIDATOR_THOROUGH_TEST
diff --git a/base/message_loop/message_loop_unittest.cc b/base/message_loop/message_loop_unittest.cc
index 006d300..fe65fb7 100644
--- a/base/message_loop/message_loop_unittest.cc
+++ b/base/message_loop/message_loop_unittest.cc
@@ -21,7 +21,7 @@
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/bind_test_util.h"
#include "base/test/gtest_util.h"
#include "base/test/metrics/histogram_tester.h"
diff --git a/base/observer_list_threadsafe_unittest.cc b/base/observer_list_threadsafe_unittest.cc
index 87d1ebe..6d8f4a2 100644
--- a/base/observer_list_threadsafe_unittest.cc
+++ b/base/observer_list_threadsafe_unittest.cc
@@ -17,7 +17,7 @@
#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_task_environment.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_restrictions.h"
@@ -390,11 +390,11 @@
BindOnce(&ObserverListThreadSafe<Foo>::AddObserver,
observer_list, Unretained(&observer_2)));
- TaskScheduler::GetInstance()->FlushForTesting();
+ ThreadPool::GetInstance()->FlushForTesting();
observer_list->Notify(FROM_HERE, &Foo::Observe, 1);
- TaskScheduler::GetInstance()->FlushForTesting();
+ ThreadPool::GetInstance()->FlushForTesting();
EXPECT_TRUE(observer_1.called_on_valid_sequence());
EXPECT_TRUE(observer_2.called_on_valid_sequence());
@@ -460,14 +460,14 @@
WaitableEvent::InitialState::NOT_SIGNALED);
// This must be after the declaration of |barrier| so that tasks posted to
- // TaskScheduler can safely use |barrier|.
+ // ThreadPool can safely use |barrier|.
test::ScopedTaskEnvironment scoped_task_environment;
CreateSequencedTaskRunnerWithTraits({MayBlock()})
->PostTask(FROM_HERE,
base::BindOnce(&ObserverListThreadSafe<Foo>::AddObserver,
observer_list, Unretained(&observer)));
- TaskScheduler::GetInstance()->FlushForTesting();
+ ThreadPool::GetInstance()->FlushForTesting();
observer_list->Notify(FROM_HERE, &Foo::Observe, 1);
observer.WaitForNotificationRunning();
diff --git a/base/pending_task.h b/base/pending_task.h
index c3df29d..e7b7c80 100644
--- a/base/pending_task.h
+++ b/base/pending_task.h
@@ -47,8 +47,8 @@
base::TimeTicks delayed_run_time;
// The time at which the task was queued. For SequenceManager tasks and
- // TaskScheduler non-delayed tasks, this happens at post time. For
- // TaskScheduler delayed tasks, this happens some time after the task's delay
+ // ThreadPool non-delayed tasks, this happens at post time. For
+ // ThreadPool delayed tasks, this happens some time after the task's delay
// has expired. This is not set for SequenceManager tasks if
// SetAddQueueTimeToTasks(true) wasn't call. This defaults to a null TimeTicks
// if the task hasn't been inserted in a sequence yet.
diff --git a/base/task/OWNERS b/base/task/OWNERS
index 0f3ad5e..c32490a 100644
--- a/base/task/OWNERS
+++ b/base/task/OWNERS
@@ -3,4 +3,4 @@
robliao@chromium.org
# TEAM: scheduler-dev@chromium.org
-# COMPONENT: Internals>TaskScheduler
+# COMPONENT: Internals>ThreadPool
diff --git a/base/task/README.md b/base/task/README.md
index de4f0451..4d230ba9 100644
--- a/base/task/README.md
+++ b/base/task/README.md
@@ -1,9 +1,9 @@
This directory has the following layout:
- base/task/: public APIs for posting tasks and managing task queues.
-- base/task/task_scheduler/: implementation of the TaskScheduler.
+- base/task/thread_pool/: implementation of the ThreadPool.
- base/task/sequence_manager/: implementation of the SequenceManager.
-Apart from embedders explicitly managing a TaskScheduler and/or SequenceManager
+Apart from embedders explicitly managing a ThreadPool and/or SequenceManager
instance(s) for their process/threads, the vast majority of users should only
need APIs in base/task/.
diff --git a/base/task/common/task_annotator_unittest.cc b/base/task/common/task_annotator_unittest.cc
index 697d968..901ab54 100644
--- a/base/task/common/task_annotator_unittest.cc
+++ b/base/task/common/task_annotator_unittest.cc
@@ -188,8 +188,8 @@
TEST_F(TaskAnnotatorBacktraceIntegrationTest, MultipleThreads) {
test::ScopedTaskEnvironment scoped_task_environment;
- // Use diverse task runners (a task environment main thread, a TaskScheduler
- // based SequencedTaskRunner, and a TaskScheduler based
+ // Use diverse task runners (a task environment main thread, a ThreadPool
+ // based SequencedTaskRunner, and a ThreadPool based
// SingleThreadTaskRunner) to verify that TaskAnnotator can capture backtraces
// for PostTasks back-and-forth between these.
auto main_thread_a = ThreadTaskRunnerHandle::Get();
diff --git a/base/task/lazy_task_runner.h b/base/task/lazy_task_runner.h
index 5f11ab5..544d3473 100644
--- a/base/task/lazy_task_runner.h
+++ b/base/task/lazy_task_runner.h
@@ -14,8 +14,8 @@
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/task/single_thread_task_runner_thread_mode.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/scheduler_lock.h"
#include "base/thread_annotations.h"
#include "build/build_config.h"
diff --git a/base/task/lazy_task_runner_unittest.cc b/base/task/lazy_task_runner_unittest.cc
index c983187..8494908 100644
--- a/base/task/lazy_task_runner_unittest.cc
+++ b/base/task/lazy_task_runner_unittest.cc
@@ -80,9 +80,9 @@
#endif
}
-class TaskSchedulerLazyTaskRunnerEnvironmentTest : public testing::Test {
+class LazyTaskRunnerEnvironmentTest : public testing::Test {
protected:
- TaskSchedulerLazyTaskRunnerEnvironmentTest() = default;
+ LazyTaskRunnerEnvironmentTest() = default;
void TestTaskRunnerEnvironment(scoped_refptr<SequencedTaskRunner> task_runner,
bool expect_single_thread,
@@ -119,44 +119,38 @@
test::ScopedTaskEnvironment scoped_task_environment_;
private:
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerLazyTaskRunnerEnvironmentTest);
+ DISALLOW_COPY_AND_ASSIGN(LazyTaskRunnerEnvironmentTest);
};
} // namespace
-TEST_F(TaskSchedulerLazyTaskRunnerEnvironmentTest,
- LazySequencedTaskRunnerUserVisible) {
+TEST_F(LazyTaskRunnerEnvironmentTest, LazySequencedTaskRunnerUserVisible) {
TestTaskRunnerEnvironment(g_sequenced_task_runner_user_visible.Get(), false,
TaskPriority::USER_VISIBLE);
}
-TEST_F(TaskSchedulerLazyTaskRunnerEnvironmentTest,
- LazySequencedTaskRunnerUserBlocking) {
+TEST_F(LazyTaskRunnerEnvironmentTest, LazySequencedTaskRunnerUserBlocking) {
TestTaskRunnerEnvironment(g_sequenced_task_runner_user_blocking.Get(), false,
TaskPriority::USER_BLOCKING);
}
-TEST_F(TaskSchedulerLazyTaskRunnerEnvironmentTest,
- LazySingleThreadTaskRunnerUserVisible) {
+TEST_F(LazyTaskRunnerEnvironmentTest, LazySingleThreadTaskRunnerUserVisible) {
TestTaskRunnerEnvironment(g_single_thread_task_runner_user_visible.Get(),
true, TaskPriority::USER_VISIBLE);
}
-TEST_F(TaskSchedulerLazyTaskRunnerEnvironmentTest,
- LazySingleThreadTaskRunnerUserBlocking) {
+TEST_F(LazyTaskRunnerEnvironmentTest, LazySingleThreadTaskRunnerUserBlocking) {
TestTaskRunnerEnvironment(g_single_thread_task_runner_user_blocking.Get(),
true, TaskPriority::USER_BLOCKING);
}
#if defined(OS_WIN)
-TEST_F(TaskSchedulerLazyTaskRunnerEnvironmentTest,
- LazyCOMSTATaskRunnerUserVisible) {
+TEST_F(LazyTaskRunnerEnvironmentTest, LazyCOMSTATaskRunnerUserVisible) {
TestTaskRunnerEnvironment(g_com_sta_task_runner_user_visible.Get(), true,
TaskPriority::USER_VISIBLE, true);
}
-TEST_F(TaskSchedulerLazyTaskRunnerEnvironmentTest,
- LazyCOMSTATaskRunnerUserBlocking) {
+TEST_F(LazyTaskRunnerEnvironmentTest, LazyCOMSTATaskRunnerUserBlocking) {
TestTaskRunnerEnvironment(g_com_sta_task_runner_user_blocking.Get(), true,
TaskPriority::USER_BLOCKING, true);
}
@@ -167,7 +161,7 @@
test::ScopedTaskEnvironment scoped_task_environment;
// If the TaskRunner isn't released when the test::ScopedTaskEnvironment
// goes out of scope, the second invocation of the line below will access a
- // deleted TaskScheduler and crash.
+ // deleted ThreadPool and crash.
g_sequenced_task_runner_user_visible.Get()->PostTask(FROM_HERE,
DoNothing());
}
@@ -178,7 +172,7 @@
test::ScopedTaskEnvironment scoped_task_environment;
// If the TaskRunner isn't released when the test::ScopedTaskEnvironment
// goes out of scope, the second invocation of the line below will access a
- // deleted TaskScheduler and crash.
+ // deleted ThreadPool and crash.
g_single_thread_task_runner_user_visible.Get()->PostTask(FROM_HERE,
DoNothing());
}
@@ -190,7 +184,7 @@
test::ScopedTaskEnvironment scoped_task_environment;
// If the TaskRunner isn't released when the test::ScopedTaskEnvironment
// goes out of scope, the second invocation of the line below will access a
- // deleted TaskScheduler and crash.
+ // deleted ThreadPool and crash.
g_com_sta_task_runner_user_visible.Get()->PostTask(FROM_HERE, DoNothing());
}
}
diff --git a/base/task/post_task.cc b/base/task/post_task.cc
index 2f5721b5..af810c9a 100644
--- a/base/task/post_task.cc
+++ b/base/task/post_task.cc
@@ -9,7 +9,7 @@
#include "base/logging.h"
#include "base/task/scoped_set_task_priority_for_current_thread.h"
#include "base/task/task_executor.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/post_task_and_reply_impl.h"
namespace base {
@@ -41,12 +41,12 @@
}
TaskExecutor* GetTaskExecutorForTraits(const TaskTraits& traits) {
- DCHECK(TaskScheduler::GetInstance())
+ DCHECK(ThreadPool::GetInstance())
<< "Ref. Prerequisite section of post_task.h.\n\n"
"Hint: if this is in a unit test, you're likely merely missing a "
"base::test::ScopedTaskEnvironment member in your fixture.\n";
TaskExecutor* executor = GetRegisteredTaskExecutorForTraits(traits);
- return executor ? executor : TaskScheduler::GetInstance();
+ return executor ? executor : ThreadPool::GetInstance();
}
} // namespace
diff --git a/base/task/post_task.h b/base/task/post_task.h
index 63a4cc6..0aff1ba1 100644
--- a/base/task/post_task.h
+++ b/base/task/post_task.h
@@ -58,7 +58,7 @@
// requirements are not sufficient.
//
// Tasks posted with only traits defined in base/task/task_traits.h run on
-// threads owned by the registered TaskScheduler (i.e. not on the main thread).
+// threads owned by the registered ThreadPool (i.e. not on the main thread).
// An embedder (e.g. Chrome) can define additional traits to make tasks run on
// threads of their choosing. TODO(https://crbug.com/863341): Make this a
// reality.
@@ -69,8 +69,8 @@
// for tasks posted in a given order (being scheduled first doesn't mean it will
// run first -- could run in parallel or have its physical thread preempted).
//
-// Prerequisite: A TaskScheduler must have been registered for the current
-// process via TaskScheduler::SetInstance() before the functions below are
+// Prerequisite: A ThreadPool must have been registered for the current
+// process via ThreadPool::SetInstance() before the functions below are
// valid. This is typically done during the initialization phase in each
// process. If your code is not running in that phase, you most likely don't
// have to worry about this. You will encounter DCHECKs or nullptr dereferences
diff --git a/base/task/post_task_unittest.cc b/base/task/post_task_unittest.cc
index e84567f..796b6848 100644
--- a/base/task/post_task_unittest.cc
+++ b/base/task/post_task_unittest.cc
@@ -97,7 +97,7 @@
test::ScopedTaskEnvironment scoped_task_environment_;
};
-TEST_F(PostTaskTestWithExecutor, PostTaskToTaskScheduler) {
+TEST_F(PostTaskTestWithExecutor, PostTaskToThreadPool) {
// Tasks without extension should not go to the TestTaskExecutor.
EXPECT_TRUE(PostTask(FROM_HERE, DoNothing()));
EXPECT_FALSE(executor_.runner()->HasPendingTask());
diff --git a/base/task/scoped_set_task_priority_for_current_thread.h b/base/task/scoped_set_task_priority_for_current_thread.h
index fadc6bf..e5f098b 100644
--- a/base/task/scoped_set_task_priority_for_current_thread.h
+++ b/base/task/scoped_set_task_priority_for_current_thread.h
@@ -25,8 +25,8 @@
DISALLOW_COPY_AND_ASSIGN(ScopedSetTaskPriorityForCurrentThread);
};
-// Returns the priority of the TaskScheduler task running on the current thread,
-// or TaskPriority::USER_VISIBLE if no TaskScheduler task is running on the
+// Returns the priority of the ThreadPool task running on the current thread,
+// or TaskPriority::USER_VISIBLE if no ThreadPool task is running on the
// current thread.
BASE_EXPORT TaskPriority GetTaskPriorityForCurrentThread();
diff --git a/base/task/scoped_set_task_priority_for_current_thread_unittest.cc b/base/task/scoped_set_task_priority_for_current_thread_unittest.cc
index f88f858..838fad9 100644
--- a/base/task/scoped_set_task_priority_for_current_thread_unittest.cc
+++ b/base/task/scoped_set_task_priority_for_current_thread_unittest.cc
@@ -10,7 +10,7 @@
namespace base {
namespace internal {
-TEST(TaskSchedulerScopedSetTaskPriorityForCurrentThreadTest,
+TEST(ThreadPoolScopedSetTaskPriorityForCurrentThreadTest,
ScopedSetTaskPriorityForCurrentThread) {
EXPECT_EQ(TaskPriority::USER_VISIBLE, GetTaskPriorityForCurrentThread());
{
diff --git a/base/task/sequence_manager/sequence_manager_perftest.cc b/base/task/sequence_manager/sequence_manager_perftest.cc
index 1e90d37..34d0568 100644
--- a/base/task/sequence_manager/sequence_manager_perftest.cc
+++ b/base/task/sequence_manager/sequence_manager_perftest.cc
@@ -22,9 +22,9 @@
#include "base/task/sequence_manager/test/test_task_queue.h"
#include "base/task/sequence_manager/test/test_task_time_observer.h"
#include "base/task/sequence_manager/thread_controller_with_message_pump_impl.h"
-#include "base/task/task_scheduler/task_scheduler.h"
-#include "base/task/task_scheduler/task_scheduler_impl.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/thread_pool.h"
+#include "base/task/thread_pool/thread_pool_impl.h"
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/default_tick_clock.h"
@@ -239,14 +239,14 @@
class SingleThreadInWorkerPoolPerfTestDelegate : public PerfTestDelegate {
public:
SingleThreadInWorkerPoolPerfTestDelegate() : done_cond_(&done_lock_) {
- TaskScheduler::SetInstance(
- std::make_unique<::base::internal::TaskSchedulerImpl>("Test"));
- TaskScheduler::GetInstance()->StartWithDefaultParams();
+ ThreadPool::SetInstance(
+ std::make_unique<::base::internal::ThreadPoolImpl>("Test"));
+ ThreadPool::GetInstance()->StartWithDefaultParams();
}
~SingleThreadInWorkerPoolPerfTestDelegate() override {
- TaskScheduler::GetInstance()->JoinForTesting();
- TaskScheduler::SetInstance(nullptr);
+ ThreadPool::GetInstance()->JoinForTesting();
+ ThreadPool::SetInstance(nullptr);
}
const char* GetName() const override {
diff --git a/base/task/sequence_manager/task_queue.h b/base/task/sequence_manager/task_queue.h
index 96e7337..a742e58 100644
--- a/base/task/sequence_manager/task_queue.h
+++ b/base/task/sequence_manager/task_queue.h
@@ -15,7 +15,7 @@
#include "base/task/sequence_manager/lazy_now.h"
#include "base/task/sequence_manager/tasks.h"
#include "base/task/task_observer.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
+#include "base/task/thread_pool/scheduler_lock.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
diff --git a/base/task/sequence_manager/task_queue_impl.h b/base/task/sequence_manager/task_queue_impl.h
index 2a84e78..8c866b89 100644
--- a/base/task/sequence_manager/task_queue_impl.h
+++ b/base/task/sequence_manager/task_queue_impl.h
@@ -23,7 +23,7 @@
#include "base/task/sequence_manager/lazily_deallocated_deque.h"
#include "base/task/sequence_manager/sequenced_task_source.h"
#include "base/task/sequence_manager/task_queue.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
+#include "base/task/thread_pool/scheduler_lock.h"
#include "base/threading/thread_checker.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h"
diff --git a/base/task/sequence_manager/thread_controller_with_message_pump_impl.h b/base/task/sequence_manager/thread_controller_with_message_pump_impl.h
index b138c7f..8e2f13ea 100644
--- a/base/task/sequence_manager/thread_controller_with_message_pump_impl.h
+++ b/base/task/sequence_manager/thread_controller_with_message_pump_impl.h
@@ -16,7 +16,7 @@
#include "base/task/sequence_manager/sequenced_task_source.h"
#include "base/task/sequence_manager/thread_controller.h"
#include "base/task/sequence_manager/work_deduplicator.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
+#include "base/task/thread_pool/scheduler_lock.h"
#include "base/thread_annotations.h"
#include "base/threading/platform_thread.h"
#include "base/threading/sequence_local_storage_map.h"
diff --git a/base/task/task_features.h b/base/task/task_features.h
index 6f70af7..21d8719 100644
--- a/base/task/task_features.h
+++ b/base/task/task_features.h
@@ -25,7 +25,7 @@
extern const BASE_EXPORT Feature kMayBlockWithoutDelay;
#if defined(OS_WIN) || defined(OS_MACOSX)
-// Under this feature, TaskScheduler will use a SchedulerWorkerPool backed by a
+// Under this feature, ThreadPool will use a SchedulerWorkerPool backed by a
// native thread pool implementation. The Windows Thread Pool API and
// libdispatch are used on Windows and macOS/iOS respectively.
extern const BASE_EXPORT Feature kUseNativeThreadPool;
diff --git a/base/task/task_scheduler/OWNERS b/base/task/task_scheduler/OWNERS
index 0f3ad5e..d37bf7ea 100644
--- a/base/task/task_scheduler/OWNERS
+++ b/base/task/task_scheduler/OWNERS
@@ -1,6 +1,8 @@
+# TODO: Remove this (had to keep it during move because of buggy presubmit)
+
fdoray@chromium.org
gab@chromium.org
robliao@chromium.org
# TEAM: scheduler-dev@chromium.org
-# COMPONENT: Internals>TaskScheduler
+# COMPONENT: Internals>ThreadPool
diff --git a/base/task/task_scheduler/scheduler_worker_observer.h b/base/task/task_scheduler/scheduler_worker_observer.h
deleted file mode 100644
index 21f3d098..0000000
--- a/base/task/task_scheduler/scheduler_worker_observer.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_OBSERVER_H_
-#define BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_OBSERVER_H_
-
-namespace base {
-
-// Interface to observe entry and exit of the main function of a TaskScheduler
-// worker.
-class SchedulerWorkerObserver {
- public:
- virtual ~SchedulerWorkerObserver() = default;
-
- // Invoked at the beginning of the main function of a TaskScheduler worker,
- // before any task runs.
- virtual void OnSchedulerWorkerMainEntry() = 0;
-
- // Invoked at the end of the main function of a TaskScheduler worker, when it
- // can no longer run tasks.
- virtual void OnSchedulerWorkerMainExit() = 0;
-};
-
-} // namespace base
-
-#endif // BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_OBSERVER_H_
diff --git a/base/task/task_scheduler/single_thread_task_runner_thread_mode.h b/base/task/task_scheduler/single_thread_task_runner_thread_mode.h
deleted file mode 100644
index 3406b39..0000000
--- a/base/task/task_scheduler/single_thread_task_runner_thread_mode.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_TASK_TASK_SCHEDULER_SINGLE_THREAD_TASK_RUNNER_THREAD_MODE_H_
-#define BASE_TASK_TASK_SCHEDULER_SINGLE_THREAD_TASK_RUNNER_THREAD_MODE_H_
-
-namespace base {
-
-enum class SingleThreadTaskRunnerThreadMode {
- // Allow the SingleThreadTaskRunner's thread to be shared with others,
- // allowing for efficient use of thread resources when this
- // SingleThreadTaskRunner is idle. This is the default mode and is
- // recommended for most code.
- SHARED,
- // Dedicate a single thread for this SingleThreadTaskRunner. No other tasks
- // from any other source will run on the thread backing the
- // SingleThreadTaskRunner. Use sparingly as this reserves an entire thread for
- // this SingleThreadTaskRunner.
- DEDICATED,
-};
-
-} // namespace base
-
-#endif // BASE_TASK_TASK_SCHEDULER_SINGLE_THREAD_TASK_RUNNER_THREAD_MODE_H_
diff --git a/base/task/task_scheduler/task_scheduler.cc b/base/task/task_scheduler/task_scheduler.cc
deleted file mode 100644
index 02c9297..0000000
--- a/base/task/task_scheduler/task_scheduler.cc
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/task/task_scheduler/task_scheduler.h"
-
-#include <algorithm>
-
-#include "base/logging.h"
-#include "base/memory/ptr_util.h"
-#include "base/system/sys_info.h"
-#include "base/task/task_scheduler/scheduler_worker_pool_params.h"
-#include "base/task/task_scheduler/task_scheduler_impl.h"
-#include "base/threading/platform_thread.h"
-#include "base/time/time.h"
-
-namespace base {
-
-namespace {
-
-// |g_task_scheduler| is intentionally leaked on shutdown.
-TaskScheduler* g_task_scheduler = nullptr;
-
-} // namespace
-
-TaskScheduler::InitParams::InitParams(
- const SchedulerWorkerPoolParams& background_worker_pool_params_in,
- const SchedulerWorkerPoolParams& foreground_worker_pool_params_in,
- SharedWorkerPoolEnvironment shared_worker_pool_environment_in)
- : background_worker_pool_params(background_worker_pool_params_in),
- foreground_worker_pool_params(foreground_worker_pool_params_in),
- shared_worker_pool_environment(shared_worker_pool_environment_in) {}
-
-TaskScheduler::InitParams::~InitParams() = default;
-
-TaskScheduler::ScopedExecutionFence::ScopedExecutionFence() {
- DCHECK(g_task_scheduler);
- g_task_scheduler->SetExecutionFenceEnabled(true);
-}
-
-TaskScheduler::ScopedExecutionFence::~ScopedExecutionFence() {
- DCHECK(g_task_scheduler);
- g_task_scheduler->SetExecutionFenceEnabled(false);
-}
-
-#if !defined(OS_NACL)
-// static
-void TaskScheduler::CreateAndStartWithDefaultParams(StringPiece name) {
- Create(name);
- GetInstance()->StartWithDefaultParams();
-}
-
-void TaskScheduler::StartWithDefaultParams() {
- // Values were chosen so that:
- // * There are few background threads.
- // * Background threads never outnumber foreground threads.
- // * The system is utilized maximally by foreground threads.
- // * The main thread is assumed to be busy, cap foreground workers at
- // |num_cores - 1|.
- const int num_cores = SysInfo::NumberOfProcessors();
-
- // TODO(etiennep): Change this to 2.
- constexpr int kBackgroundMaxThreads = 3;
- const int kForegroundMaxThreads = std::max(3, num_cores - 1);
-
- constexpr TimeDelta kSuggestedReclaimTime = TimeDelta::FromSeconds(30);
-
- Start({{kBackgroundMaxThreads, kSuggestedReclaimTime},
- {kForegroundMaxThreads, kSuggestedReclaimTime}});
-}
-#endif // !defined(OS_NACL)
-
-void TaskScheduler::Create(StringPiece name) {
- SetInstance(std::make_unique<internal::TaskSchedulerImpl>(name));
-}
-
-// static
-void TaskScheduler::SetInstance(std::unique_ptr<TaskScheduler> task_scheduler) {
- delete g_task_scheduler;
- g_task_scheduler = task_scheduler.release();
-}
-
-// static
-TaskScheduler* TaskScheduler::GetInstance() {
- return g_task_scheduler;
-}
-
-} // namespace base
diff --git a/base/task/task_traits.h b/base/task/task_traits.h
index c98bed9..b3e0bafa 100644
--- a/base/task/task_traits.h
+++ b/base/task/task_traits.h
@@ -22,10 +22,10 @@
class PostTaskAndroid;
-// Valid priorities supported by the task scheduler. Note: internal algorithms
-// depend on priorities being expressed as a continuous zero-based list from
-// lowest to highest priority. Users of this API shouldn't otherwise care about
-// nor use the underlying values.
+// Valid priorities supported by the task scheduling infrastructure.
+// Note: internal algorithms depend on priorities being expressed as a
+// continuous zero-based list from lowest to highest priority. Users of this API
+// shouldn't otherwise care about nor use the underlying values.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.base.task
enum class TaskPriority {
// This will always be equal to the lowest priority available.
@@ -48,7 +48,7 @@
HIGHEST = USER_BLOCKING,
};
-// Valid shutdown behaviors supported by the task scheduler.
+// Valid shutdown behaviors supported by the thread pool.
enum class TaskShutdownBehavior {
// Tasks posted with this mode which have not started executing before
// shutdown is initiated will never run. Tasks with this mode running at
@@ -72,9 +72,9 @@
// executing when shutdown is invoked will be allowed to continue and
// will block shutdown until completion.
//
- // Note: Because TaskScheduler::Shutdown() may block while these tasks are
+ // Note: Because ThreadPool::Shutdown() may block while these tasks are
// executing, care must be taken to ensure that they do not block on the
- // thread that called TaskScheduler::Shutdown(), as this may lead to deadlock.
+ // thread that called ThreadPool::Shutdown(), as this may lead to deadlock.
SKIP_ON_SHUTDOWN,
// Tasks posted with this mode before shutdown is complete will block shutdown
@@ -139,7 +139,7 @@
// (1) don't block (ref. MayBlock() and WithBaseSyncPrimitives()),
// (2) prefer inheriting the current priority to specifying their own, and
// (3) can either block shutdown or be skipped on shutdown
- // (TaskScheduler implementation is free to choose a fitting default).
+ // (ThreadPool implementation is free to choose a fitting default).
//
// To get TaskTraits for tasks that require stricter guarantees and/or know
// the specific TaskPriority appropriate for them, provide arguments of type
diff --git a/base/task/thread_pool/OWNERS b/base/task/thread_pool/OWNERS
new file mode 100644
index 0000000..b956a61
--- /dev/null
+++ b/base/task/thread_pool/OWNERS
@@ -0,0 +1,7 @@
+fdoray@chromium.org
+gab@chromium.org
+robliao@chromium.org
+
+# TEAM: scheduler-dev@chromium.org
+# COMPONENT: Internals>ThreadPool
+# TODO(gab): Rename component to ThreadPool
diff --git a/base/task/task_scheduler/can_schedule_sequence_observer.h b/base/task/thread_pool/can_schedule_sequence_observer.h
similarity index 71%
rename from base/task/task_scheduler/can_schedule_sequence_observer.h
rename to base/task/thread_pool/can_schedule_sequence_observer.h
index 50284a1..91db9d6a 100644
--- a/base/task/task_scheduler/can_schedule_sequence_observer.h
+++ b/base/task/thread_pool/can_schedule_sequence_observer.h
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_CAN_SCHEDULE_SEQUENCE_OBSERVER_H_
-#define BASE_TASK_TASK_SCHEDULER_CAN_SCHEDULE_SEQUENCE_OBSERVER_H_
+#ifndef BASE_TASK_THREAD_POOL_CAN_SCHEDULE_SEQUENCE_OBSERVER_H_
+#define BASE_TASK_THREAD_POOL_CAN_SCHEDULE_SEQUENCE_OBSERVER_H_
-#include "base/task/task_scheduler/sequence.h"
+#include "base/task/thread_pool/sequence.h"
namespace base {
namespace internal {
@@ -24,4 +24,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_CAN_SCHEDULE_SEQUENCE_OBSERVER_H_
+#endif // BASE_TASK_THREAD_POOL_CAN_SCHEDULE_SEQUENCE_OBSERVER_H_
diff --git a/base/task/task_scheduler/delayed_task_manager.cc b/base/task/thread_pool/delayed_task_manager.cc
similarity index 97%
rename from base/task/task_scheduler/delayed_task_manager.cc
rename to base/task/thread_pool/delayed_task_manager.cc
index b5cb77c..a805bec 100644
--- a/base/task/task_scheduler/delayed_task_manager.cc
+++ b/base/task/thread_pool/delayed_task_manager.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/delayed_task_manager.h"
+#include "base/task/thread_pool/delayed_task_manager.h"
#include <algorithm>
#include "base/bind.h"
#include "base/logging.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task.h"
+#include "base/task/thread_pool/task.h"
#include "base/task_runner.h"
namespace base {
diff --git a/base/task/task_scheduler/delayed_task_manager.h b/base/task/thread_pool/delayed_task_manager.h
similarity index 91%
rename from base/task/task_scheduler/delayed_task_manager.h
rename to base/task/thread_pool/delayed_task_manager.h
index 4485f8ea..f83901719 100644
--- a/base/task/task_scheduler/delayed_task_manager.h
+++ b/base/task/thread_pool/delayed_task_manager.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_DELAYED_TASK_MANAGER_H_
-#define BASE_TASK_TASK_SCHEDULER_DELAYED_TASK_MANAGER_H_
+#ifndef BASE_TASK_THREAD_POOL_DELAYED_TASK_MANAGER_H_
+#define BASE_TASK_THREAD_POOL_DELAYED_TASK_MANAGER_H_
#include <memory>
#include <utility>
@@ -15,8 +15,8 @@
#include "base/memory/ref_counted.h"
#include "base/synchronization/atomic_flag.h"
#include "base/task/common/intrusive_heap.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
-#include "base/task/task_scheduler/task.h"
+#include "base/task/thread_pool/scheduler_lock.h"
+#include "base/task/thread_pool/task.h"
#include "base/time/default_tick_clock.h"
#include "base/time/tick_clock.h"
@@ -41,7 +41,7 @@
// Starts the delayed task manager, allowing past and future tasks to be
// forwarded to their callbacks as they become ripe for execution.
- // |service_thread_task_runner| posts tasks to the TaskScheduler service
+ // |service_thread_task_runner| posts tasks to the ThreadPool service
// thread.
void Start(scoped_refptr<TaskRunner> service_thread_task_runner);
@@ -124,4 +124,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_DELAYED_TASK_MANAGER_H_
+#endif // BASE_TASK_THREAD_POOL_DELAYED_TASK_MANAGER_H_
diff --git a/base/task/task_scheduler/delayed_task_manager_unittest.cc b/base/task/thread_pool/delayed_task_manager_unittest.cc
similarity index 90%
rename from base/task/task_scheduler/delayed_task_manager_unittest.cc
rename to base/task/thread_pool/delayed_task_manager_unittest.cc
index 003b349..e2f10f0 100644
--- a/base/task/task_scheduler/delayed_task_manager_unittest.cc
+++ b/base/task/thread_pool/delayed_task_manager_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/delayed_task_manager.h"
+#include "base/task/thread_pool/delayed_task_manager.h"
#include <memory>
#include <utility>
@@ -11,7 +11,7 @@
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/task.h"
+#include "base/task/thread_pool/task.h"
#include "base/test/bind_test_util.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/threading/thread.h"
@@ -45,16 +45,16 @@
return task;
}
-class TaskSchedulerDelayedTaskManagerTest : public testing::Test {
+class ThreadPoolDelayedTaskManagerTest : public testing::Test {
protected:
- TaskSchedulerDelayedTaskManagerTest()
+ ThreadPoolDelayedTaskManagerTest()
: delayed_task_manager_(
service_thread_task_runner_->DeprecatedGetMockTickClock()),
task_(ConstructMockedTask(
mock_task_,
service_thread_task_runner_->GetMockTickClock()->NowTicks(),
kLongDelay)) {}
- ~TaskSchedulerDelayedTaskManagerTest() override = default;
+ ~ThreadPoolDelayedTaskManagerTest() override = default;
const scoped_refptr<TestMockTimeTaskRunner> service_thread_task_runner_ =
MakeRefCounted<TestMockTimeTaskRunner>();
@@ -63,13 +63,13 @@
Task task_;
private:
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerDelayedTaskManagerTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolDelayedTaskManagerTest);
};
} // namespace
// Verify that a delayed task isn't forwarded before Start().
-TEST_F(TaskSchedulerDelayedTaskManagerTest, DelayedTaskDoesNotRunBeforeStart) {
+TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTaskDoesNotRunBeforeStart) {
// Send |task| to the DelayedTaskManager.
delayed_task_manager_.AddDelayedTask(std::move(task_), BindOnce(&RunTask),
nullptr);
@@ -82,7 +82,7 @@
// Verify that a delayed task added before Start() and whose delay expires after
// Start() is forwarded when its delay expires.
-TEST_F(TaskSchedulerDelayedTaskManagerTest,
+TEST_F(ThreadPoolDelayedTaskManagerTest,
DelayedTaskPostedBeforeStartExpiresAfterStartRunsOnExpire) {
// Send |task| to the DelayedTaskManager.
delayed_task_manager_.AddDelayedTask(std::move(task_), BindOnce(&RunTask),
@@ -102,7 +102,7 @@
// Verify that a delayed task added before Start() and whose delay expires
// before Start() is forwarded when Start() is called.
-TEST_F(TaskSchedulerDelayedTaskManagerTest,
+TEST_F(ThreadPoolDelayedTaskManagerTest,
DelayedTaskPostedBeforeStartExpiresBeforeStartRunsOnStart) {
// Send |task| to the DelayedTaskManager.
delayed_task_manager_.AddDelayedTask(std::move(task_), BindOnce(&RunTask),
@@ -124,7 +124,7 @@
// Verify that a delayed task added after Start() isn't forwarded before it is
// ripe for execution.
-TEST_F(TaskSchedulerDelayedTaskManagerTest, DelayedTaskDoesNotRunTooEarly) {
+TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTaskDoesNotRunTooEarly) {
delayed_task_manager_.Start(service_thread_task_runner_);
// Send |task| to the DelayedTaskManager.
@@ -138,7 +138,7 @@
// Verify that a delayed task added after Start() is forwarded when it is ripe
// for execution.
-TEST_F(TaskSchedulerDelayedTaskManagerTest, DelayedTaskRunsAfterDelay) {
+TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTaskRunsAfterDelay) {
delayed_task_manager_.Start(service_thread_task_runner_);
// Send |task| to the DelayedTaskManager.
@@ -152,7 +152,7 @@
// Verify that multiple delayed tasks added after Start() are forwarded when
// they are ripe for execution.
-TEST_F(TaskSchedulerDelayedTaskManagerTest, DelayedTasksRunAfterDelay) {
+TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTasksRunAfterDelay) {
delayed_task_manager_.Start(service_thread_task_runner_);
testing::StrictMock<MockTask> mock_task_a;
@@ -196,7 +196,7 @@
testing::Mock::VerifyAndClear(&mock_task_b);
}
-TEST_F(TaskSchedulerDelayedTaskManagerTest, PostTaskDuringStart) {
+TEST_F(ThreadPoolDelayedTaskManagerTest, PostTaskDuringStart) {
Thread other_thread("Test");
other_thread.StartAndWaitForTesting();
diff --git a/base/task/task_scheduler/environment_config.cc b/base/task/thread_pool/environment_config.cc
similarity index 95%
rename from base/task/task_scheduler/environment_config.cc
rename to base/task/thread_pool/environment_config.cc
index 0bb59ab..eeb4df9 100644
--- a/base/task/task_scheduler/environment_config.cc
+++ b/base/task/thread_pool/environment_config.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/environment_config.h"
+#include "base/task/thread_pool/environment_config.h"
#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
@@ -29,7 +29,7 @@
#if !defined(OS_ANDROID)
// When thread priority can't be increased to NORMAL, run all threads with a
- // NORMAL priority to avoid priority inversions on shutdown (TaskScheduler
+ // NORMAL priority to avoid priority inversions on shutdown (ThreadPool
// increases BACKGROUND threads priority to NORMAL on shutdown while resolving
// remaining shutdown blocking tasks).
//
diff --git a/base/task/task_scheduler/environment_config.h b/base/task/thread_pool/environment_config.h
similarity index 86%
rename from base/task/task_scheduler/environment_config.h
rename to base/task/thread_pool/environment_config.h
index 5280cd7a..23432ead 100644
--- a/base/task/task_scheduler/environment_config.h
+++ b/base/task/thread_pool/environment_config.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_ENVIRONMENT_CONFIG_H_
-#define BASE_TASK_TASK_SCHEDULER_ENVIRONMENT_CONFIG_H_
+#ifndef BASE_TASK_THREAD_POOL_ENVIRONMENT_CONFIG_H_
+#define BASE_TASK_THREAD_POOL_ENVIRONMENT_CONFIG_H_
#include <stddef.h>
@@ -27,7 +27,7 @@
// Order must match the EnvironmentType enum.
struct EnvironmentParams {
// The threads and histograms of this environment will be labeled with
- // the task scheduler name concatenated to this.
+ // the thread pool name concatenated to this.
const char* name_suffix;
// Preferred priority for threads in this environment; the actual thread
@@ -51,4 +51,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_ENVIRONMENT_CONFIG_H_
+#endif // BASE_TASK_THREAD_POOL_ENVIRONMENT_CONFIG_H_
diff --git a/base/task/task_scheduler/initialization_util.cc b/base/task/thread_pool/initialization_util.cc
similarity index 91%
rename from base/task/task_scheduler/initialization_util.cc
rename to base/task/thread_pool/initialization_util.cc
index f1a6d7ef..7534eb37 100644
--- a/base/task/task_scheduler/initialization_util.cc
+++ b/base/task/thread_pool/initialization_util.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/initialization_util.h"
+#include "base/task/thread_pool/initialization_util.h"
#include <algorithm>
diff --git a/base/task/task_scheduler/initialization_util.h b/base/task/thread_pool/initialization_util.h
similarity index 69%
rename from base/task/task_scheduler/initialization_util.h
rename to base/task/thread_pool/initialization_util.h
index 586318c..c81438e 100644
--- a/base/task/task_scheduler/initialization_util.h
+++ b/base/task/thread_pool/initialization_util.h
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_INITIALIZATION_UTIL_H_
-#define BASE_TASK_TASK_SCHEDULER_INITIALIZATION_UTIL_H_
+#ifndef BASE_TASK_THREAD_POOL_INITIALIZATION_UTIL_H_
+#define BASE_TASK_THREAD_POOL_INITIALIZATION_UTIL_H_
#include "base/base_export.h"
namespace base {
// Computes a value that may be used as the maximum number of threads in a
-// TaskScheduler pool. Developers may use other methods to choose this maximum.
+// ThreadPool pool. Developers may use other methods to choose this maximum.
BASE_EXPORT int RecommendedMaxNumberOfThreadsInPool(int min,
int max,
double cores_multiplier,
@@ -18,4 +18,4 @@
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_INITIALIZATION_UTIL_H_
+#endif // BASE_TASK_THREAD_POOL_INITIALIZATION_UTIL_H_
diff --git a/base/task/task_scheduler/platform_native_worker_pool.cc b/base/task/thread_pool/platform_native_worker_pool.cc
similarity index 96%
rename from base/task/task_scheduler/platform_native_worker_pool.cc
rename to base/task/thread_pool/platform_native_worker_pool.cc
index d32f278b..4c6f8f8 100644
--- a/base/task/task_scheduler/platform_native_worker_pool.cc
+++ b/base/task/thread_pool/platform_native_worker_pool.cc
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/platform_native_worker_pool.h"
+#include "base/task/thread_pool/platform_native_worker_pool.h"
#include <algorithm>
#include <utility>
#include "base/system/sys_info.h"
-#include "base/task/task_scheduler/task_tracker.h"
+#include "base/task/thread_pool/task_tracker.h"
namespace base {
namespace internal {
@@ -139,7 +139,7 @@
// Native thread pools give us no control over the number of workers that are
// active at one time. Consequently, we cannot report a true value here.
// Instead, the values were chosen to match
- // TaskScheduler::StartWithDefaultParams.
+ // ThreadPool::StartWithDefaultParams.
const int num_cores = SysInfo::NumberOfProcessors();
return std::max(3, num_cores - 1);
}
diff --git a/base/task/task_scheduler/platform_native_worker_pool.h b/base/task/thread_pool/platform_native_worker_pool.h
similarity index 90%
rename from base/task/task_scheduler/platform_native_worker_pool.h
rename to base/task/thread_pool/platform_native_worker_pool.h
index 79e680a4..38444702 100644
--- a/base/task/task_scheduler/platform_native_worker_pool.h
+++ b/base/task/thread_pool/platform_native_worker_pool.h
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_PLATFORM_NATIVE_WORKER_POOL_H_
-#define BASE_TASK_TASK_SCHEDULER_PLATFORM_NATIVE_WORKER_POOL_H_
+#ifndef BASE_TASK_THREAD_POOL_PLATFORM_NATIVE_WORKER_POOL_H_
+#define BASE_TASK_THREAD_POOL_PLATFORM_NATIVE_WORKER_POOL_H_
#include "base/base_export.h"
#include "base/synchronization/atomic_flag.h"
-#include "base/task/task_scheduler/scheduler_worker_pool.h"
+#include "base/task/thread_pool/scheduler_worker_pool.h"
namespace base {
namespace internal {
@@ -75,4 +75,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_PLATFORM_NATIVE_WORKER_POOL_H_
+#endif // BASE_TASK_THREAD_POOL_PLATFORM_NATIVE_WORKER_POOL_H_
diff --git a/base/task/task_scheduler/platform_native_worker_pool_mac.h b/base/task/thread_pool/platform_native_worker_pool_mac.h
similarity index 84%
rename from base/task/task_scheduler/platform_native_worker_pool_mac.h
rename to base/task/thread_pool/platform_native_worker_pool_mac.h
index a091808..39d9959 100644
--- a/base/task/task_scheduler/platform_native_worker_pool_mac.h
+++ b/base/task/thread_pool/platform_native_worker_pool_mac.h
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_PLATFORM_NATIVE_WORKER_POOL_MAC_H_
-#define BASE_TASK_TASK_SCHEDULER_PLATFORM_NATIVE_WORKER_POOL_MAC_H_
+#ifndef BASE_TASK_THREAD_POOL_PLATFORM_NATIVE_WORKER_POOL_MAC_H_
+#define BASE_TASK_THREAD_POOL_PLATFORM_NATIVE_WORKER_POOL_MAC_H_
#include <dispatch/dispatch.h>
#include "base/base_export.h"
#include "base/mac/scoped_dispatch_object.h"
-#include "base/task/task_scheduler/platform_native_worker_pool.h"
+#include "base/task/thread_pool/platform_native_worker_pool.h"
namespace base {
namespace internal {
@@ -50,4 +50,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_PLATFORM_NATIVE_WORKER_POOL_MAC_H_
+#endif // BASE_TASK_THREAD_POOL_PLATFORM_NATIVE_WORKER_POOL_MAC_H_
diff --git a/base/task/task_scheduler/platform_native_worker_pool_mac.mm b/base/task/thread_pool/platform_native_worker_pool_mac.mm
similarity index 80%
rename from base/task/task_scheduler/platform_native_worker_pool_mac.mm
rename to base/task/thread_pool/platform_native_worker_pool_mac.mm
index fbccf5d..3c08aa5 100644
--- a/base/task/task_scheduler/platform_native_worker_pool_mac.mm
+++ b/base/task/thread_pool/platform_native_worker_pool_mac.mm
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/platform_native_worker_pool_mac.h"
+#include "base/task/thread_pool/platform_native_worker_pool_mac.h"
-#include "base/task/task_scheduler/task_tracker.h"
+#include "base/task/thread_pool/task_tracker.h"
namespace base {
namespace internal {
@@ -20,8 +20,8 @@
PlatformNativeWorkerPoolMac::~PlatformNativeWorkerPoolMac() {}
void PlatformNativeWorkerPoolMac::StartImpl() {
- queue_.reset(dispatch_queue_create(
- "org.chromium.base.TaskScheduler.WorkerPool", DISPATCH_QUEUE_CONCURRENT));
+ queue_.reset(dispatch_queue_create("org.chromium.base.ThreadPool.WorkerPool",
+ DISPATCH_QUEUE_CONCURRENT));
group_.reset(dispatch_group_create());
}
diff --git a/base/task/task_scheduler/platform_native_worker_pool_win.cc b/base/task/thread_pool/platform_native_worker_pool_win.cc
similarity index 95%
rename from base/task/task_scheduler/platform_native_worker_pool_win.cc
rename to base/task/thread_pool/platform_native_worker_pool_win.cc
index 1a85e06..30a50ac 100644
--- a/base/task/task_scheduler/platform_native_worker_pool_win.cc
+++ b/base/task/thread_pool/platform_native_worker_pool_win.cc
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/platform_native_worker_pool_win.h"
+#include "base/task/thread_pool/platform_native_worker_pool_win.h"
#include "base/no_destructor.h"
-#include "base/task/task_scheduler/task_tracker.h"
+#include "base/task/thread_pool/task_tracker.h"
#include "base/threading/thread_local.h"
#include "base/win/scoped_com_initializer.h"
diff --git a/base/task/task_scheduler/platform_native_worker_pool_win.h b/base/task/thread_pool/platform_native_worker_pool_win.h
similarity index 88%
rename from base/task/task_scheduler/platform_native_worker_pool_win.h
rename to base/task/thread_pool/platform_native_worker_pool_win.h
index db94bf0..cb7fe7a 100644
--- a/base/task/task_scheduler/platform_native_worker_pool_win.h
+++ b/base/task/thread_pool/platform_native_worker_pool_win.h
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_PLATFORM_NATIVE_WORKER_POOL_WIN_H_
-#define BASE_TASK_TASK_SCHEDULER_PLATFORM_NATIVE_WORKER_POOL_WIN_H_
+#ifndef BASE_TASK_THREAD_POOL_PLATFORM_NATIVE_WORKER_POOL_WIN_H_
+#define BASE_TASK_THREAD_POOL_PLATFORM_NATIVE_WORKER_POOL_WIN_H_
#include <windows.h>
#include "base/base_export.h"
-#include "base/task/task_scheduler/platform_native_worker_pool.h"
+#include "base/task/thread_pool/platform_native_worker_pool.h"
namespace base {
namespace internal {
@@ -62,4 +62,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_PLATFORM_NATIVE_WORKER_POOL_WIN_H_
+#endif // BASE_TASK_THREAD_POOL_PLATFORM_NATIVE_WORKER_POOL_WIN_H_
diff --git a/base/task/task_scheduler/priority_queue.cc b/base/task/thread_pool/priority_queue.cc
similarity index 98%
rename from base/task/task_scheduler/priority_queue.cc
rename to base/task/thread_pool/priority_queue.cc
index 00a6954..f187a63 100644
--- a/base/task/task_scheduler/priority_queue.cc
+++ b/base/task/thread_pool/priority_queue.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/priority_queue.h"
+#include "base/task/thread_pool/priority_queue.h"
#include <utility>
diff --git a/base/task/task_scheduler/priority_queue.h b/base/task/thread_pool/priority_queue.h
similarity index 91%
rename from base/task/task_scheduler/priority_queue.h
rename to base/task/thread_pool/priority_queue.h
index 3bb7d3db..0020045 100644
--- a/base/task/task_scheduler/priority_queue.h
+++ b/base/task/thread_pool/priority_queue.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_PRIORITY_QUEUE_H_
-#define BASE_TASK_TASK_SCHEDULER_PRIORITY_QUEUE_H_
+#ifndef BASE_TASK_THREAD_POOL_PRIORITY_QUEUE_H_
+#define BASE_TASK_THREAD_POOL_PRIORITY_QUEUE_H_
#include <memory>
@@ -11,9 +11,9 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/task/common/intrusive_heap.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
-#include "base/task/task_scheduler/sequence.h"
-#include "base/task/task_scheduler/sequence_sort_key.h"
+#include "base/task/thread_pool/scheduler_lock.h"
+#include "base/task/thread_pool/sequence.h"
+#include "base/task/thread_pool/sequence_sort_key.h"
namespace base {
namespace internal {
@@ -94,4 +94,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_PRIORITY_QUEUE_H_
+#endif // BASE_TASK_THREAD_POOL_PRIORITY_QUEUE_H_
diff --git a/base/task/task_scheduler/priority_queue_unittest.cc b/base/task/thread_pool/priority_queue_unittest.cc
similarity index 95%
rename from base/task/task_scheduler/priority_queue_unittest.cc
rename to base/task/thread_pool/priority_queue_unittest.cc
index 8e8be1b..f4de124 100644
--- a/base/task/task_scheduler/priority_queue_unittest.cc
+++ b/base/task/thread_pool/priority_queue_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/priority_queue.h"
+#include "base/task/thread_pool/priority_queue.h"
#include <memory>
#include <utility>
@@ -11,9 +11,9 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
-#include "base/task/task_scheduler/sequence.h"
-#include "base/task/task_scheduler/task.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/sequence.h"
+#include "base/task/thread_pool/task.h"
#include "base/test/gtest_util.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -32,7 +32,7 @@
return sequence;
}
-class TaskSchedulerPriorityQueueWithSequencesTest : public testing::Test {
+class ThreadPoolPriorityQueueWithSequencesTest : public testing::Test {
protected:
void ExpectNumSequences(size_t num_best_effort,
size_t num_user_visible,
@@ -66,7 +66,7 @@
} // namespace
-TEST_F(TaskSchedulerPriorityQueueWithSequencesTest, PushPopPeek) {
+TEST_F(ThreadPoolPriorityQueueWithSequencesTest, PushPopPeek) {
EXPECT_TRUE(pq.IsEmpty());
ExpectNumSequences(0U, 0U, 0U);
@@ -118,7 +118,7 @@
ExpectNumSequences(0U, 0U, 0U);
}
-TEST_F(TaskSchedulerPriorityQueueWithSequencesTest, RemoveSequence) {
+TEST_F(ThreadPoolPriorityQueueWithSequencesTest, RemoveSequence) {
EXPECT_TRUE(pq.IsEmpty());
// Push all test Sequences into the PriorityQueue. |sequence_b|
@@ -163,7 +163,7 @@
ExpectNumSequences(0U, 0U, 0U);
}
-TEST_F(TaskSchedulerPriorityQueueWithSequencesTest, UpdateSortKey) {
+TEST_F(ThreadPoolPriorityQueueWithSequencesTest, UpdateSortKey) {
EXPECT_TRUE(pq.IsEmpty());
// Push all test Sequences into the PriorityQueue. |sequence_b| becomes the
diff --git a/base/task/task_scheduler/scheduler_lock.h b/base/task/thread_pool/scheduler_lock.h
similarity index 95%
rename from base/task/task_scheduler/scheduler_lock.h
rename to base/task/thread_pool/scheduler_lock.h
index 9b4a346..f39b206 100644
--- a/base/task/task_scheduler/scheduler_lock.h
+++ b/base/task/thread_pool/scheduler_lock.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SCHEDULER_LOCK_H_
-#define BASE_TASK_TASK_SCHEDULER_SCHEDULER_LOCK_H_
+#ifndef BASE_TASK_THREAD_POOL_SCHEDULER_LOCK_H_
+#define BASE_TASK_THREAD_POOL_SCHEDULER_LOCK_H_
#include <memory>
@@ -11,7 +11,7 @@
#include "base/macros.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
-#include "base/task/task_scheduler/scheduler_lock_impl.h"
+#include "base/task/thread_pool/scheduler_lock_impl.h"
#include "base/thread_annotations.h"
namespace base {
@@ -128,4 +128,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SCHEDULER_LOCK_H_
+#endif // BASE_TASK_THREAD_POOL_SCHEDULER_LOCK_H_
diff --git a/base/task/task_scheduler/scheduler_lock_impl.cc b/base/task/thread_pool/scheduler_lock_impl.cc
similarity index 97%
rename from base/task/task_scheduler/scheduler_lock_impl.cc
rename to base/task/thread_pool/scheduler_lock_impl.cc
index 31e3d84..b6f62e3 100644
--- a/base/task/task_scheduler/scheduler_lock_impl.cc
+++ b/base/task/thread_pool/scheduler_lock_impl.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_lock_impl.h"
+#include "base/task/thread_pool/scheduler_lock_impl.h"
#include <algorithm>
#include <unordered_map>
@@ -11,7 +11,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/synchronization/condition_variable.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
+#include "base/task/thread_pool/scheduler_lock.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_local.h"
diff --git a/base/task/task_scheduler/scheduler_lock_impl.h b/base/task/thread_pool/scheduler_lock_impl.h
similarity index 87%
rename from base/task/task_scheduler/scheduler_lock_impl.h
rename to base/task/thread_pool/scheduler_lock_impl.h
index c67c3b5..0b827bf 100644
--- a/base/task/task_scheduler/scheduler_lock_impl.h
+++ b/base/task/thread_pool/scheduler_lock_impl.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SCHEDULER_LOCK_IMPL_H_
-#define BASE_TASK_TASK_SCHEDULER_SCHEDULER_LOCK_IMPL_H_
+#ifndef BASE_TASK_THREAD_POOL_SCHEDULER_LOCK_IMPL_H_
+#define BASE_TASK_THREAD_POOL_SCHEDULER_LOCK_IMPL_H_
#include <memory>
@@ -51,4 +51,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SCHEDULER_LOCK_IMPL_H_
+#endif // BASE_TASK_THREAD_POOL_SCHEDULER_LOCK_IMPL_H_
diff --git a/base/task/task_scheduler/scheduler_lock_unittest.cc b/base/task/thread_pool/scheduler_lock_unittest.cc
similarity index 88%
rename from base/task/task_scheduler/scheduler_lock_unittest.cc
rename to base/task/thread_pool/scheduler_lock_unittest.cc
index ef8cca5..f572774 100644
--- a/base/task/task_scheduler/scheduler_lock_unittest.cc
+++ b/base/task/thread_pool/scheduler_lock_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_lock.h"
+#include "base/task/thread_pool/scheduler_lock.h"
#include <stdlib.h>
@@ -81,7 +81,7 @@
} // namespace
-TEST(TaskSchedulerLock, Basic) {
+TEST(ThreadPoolLock, Basic) {
SchedulerLock lock;
BasicLockTestThread thread(&lock);
@@ -112,7 +112,7 @@
EXPECT_EQ(thread.acquired(), 20);
}
-TEST(TaskSchedulerLock, AcquirePredecessor) {
+TEST(ThreadPoolLock, AcquirePredecessor) {
SchedulerLock predecessor;
SchedulerLock lock(&predecessor);
predecessor.Acquire();
@@ -121,7 +121,7 @@
predecessor.Release();
}
-TEST(TaskSchedulerLock, AcquirePredecessorWrongOrder) {
+TEST(ThreadPoolLock, AcquirePredecessorWrongOrder) {
SchedulerLock predecessor;
SchedulerLock lock(&predecessor);
EXPECT_DCHECK_DEATH({
@@ -130,7 +130,7 @@
});
}
-TEST(TaskSchedulerLock, AcquireNonPredecessor) {
+TEST(ThreadPoolLock, AcquireNonPredecessor) {
SchedulerLock lock1;
SchedulerLock lock2;
EXPECT_DCHECK_DEATH({
@@ -139,7 +139,7 @@
});
}
-TEST(TaskSchedulerLock, AcquireMultipleLocksInOrder) {
+TEST(ThreadPoolLock, AcquireMultipleLocksInOrder) {
SchedulerLock lock1;
SchedulerLock lock2(&lock1);
SchedulerLock lock3(&lock2);
@@ -151,7 +151,7 @@
lock1.Release();
}
-TEST(TaskSchedulerLock, AcquireMultipleLocksInTheMiddleOfAChain) {
+TEST(ThreadPoolLock, AcquireMultipleLocksInTheMiddleOfAChain) {
SchedulerLock lock1;
SchedulerLock lock2(&lock1);
SchedulerLock lock3(&lock2);
@@ -161,7 +161,7 @@
lock2.Release();
}
-TEST(TaskSchedulerLock, AcquireMultipleLocksNoTransitivity) {
+TEST(ThreadPoolLock, AcquireMultipleLocksNoTransitivity) {
SchedulerLock lock1;
SchedulerLock lock2(&lock1);
SchedulerLock lock3(&lock2);
@@ -171,7 +171,7 @@
});
}
-TEST(TaskSchedulerLock, AcquireLocksDifferentThreadsSafely) {
+TEST(ThreadPoolLock, AcquireLocksDifferentThreadsSafely) {
SchedulerLock lock1;
SchedulerLock lock2;
BasicLockAcquireAndWaitThread thread(&lock1);
@@ -184,7 +184,7 @@
lock2.Release();
}
-TEST(TaskSchedulerLock,
+TEST(ThreadPoolLock,
AcquireLocksWithPredecessorDifferentThreadsSafelyPredecessorFirst) {
// A lock and its predecessor may be safely acquired on different threads.
// This Thread Other Thread
@@ -203,7 +203,7 @@
thread.Join();
}
-TEST(TaskSchedulerLock,
+TEST(ThreadPoolLock,
AcquireLocksWithPredecessorDifferentThreadsSafelyPredecessorLast) {
// A lock and its predecessor may be safely acquired on different threads.
// This Thread Other Thread
@@ -222,7 +222,7 @@
thread.Join();
}
-TEST(TaskSchedulerLock,
+TEST(ThreadPoolLock,
AcquireLocksWithPredecessorDifferentThreadsSafelyNoInterference) {
// Acquisition of an unrelated lock on another thread should not affect a
// legal lock acquisition with a predecessor on this thread.
@@ -247,7 +247,7 @@
predecessor.Release();
}
-TEST(TaskSchedulerLock, SelfReferentialLock) {
+TEST(ThreadPoolLock, SelfReferentialLock) {
struct SelfReferentialLock {
SelfReferentialLock() : lock(&lock) {}
@@ -257,7 +257,7 @@
EXPECT_DCHECK_DEATH({ SelfReferentialLock lock; });
}
-TEST(TaskSchedulerLock, PredecessorCycle) {
+TEST(ThreadPoolLock, PredecessorCycle) {
struct LockCycle {
LockCycle() : lock1(&lock2), lock2(&lock1) {}
@@ -268,7 +268,7 @@
EXPECT_DCHECK_DEATH({ LockCycle cycle; });
}
-TEST(TaskSchedulerLock, PredecessorLongerCycle) {
+TEST(ThreadPoolLock, PredecessorLongerCycle) {
struct LockCycle {
LockCycle()
: lock1(&lock5),
@@ -287,7 +287,7 @@
EXPECT_DCHECK_DEATH({ LockCycle cycle; });
}
-TEST(TaskSchedulerLock, AcquireLockAfterUniversalPredecessor) {
+TEST(ThreadPoolLock, AcquireLockAfterUniversalPredecessor) {
// Acquisition of a universal-predecessor lock should not prevent acquisition
// of a SchedulerLock after it.
SchedulerLock universal_predecessor((UniversalPredecessor()));
@@ -299,7 +299,7 @@
universal_predecessor.Release();
}
-TEST(TaskSchedulerLock, AcquireMultipleLocksAfterUniversalPredecessor) {
+TEST(ThreadPoolLock, AcquireMultipleLocksAfterUniversalPredecessor) {
// Acquisition of a universal-predecessor lock does not affect acquisition
// rules for locks beyond the one acquired directly after it.
SchedulerLock universal_predecessor((UniversalPredecessor()));
@@ -321,7 +321,7 @@
});
}
-TEST(TaskSchedulerLock, AcquireUniversalPredecessorAfterLock) {
+TEST(ThreadPoolLock, AcquireUniversalPredecessorAfterLock) {
// A universal-predecessor lock may not be acquired after any other lock.
SchedulerLock universal_predecessor((UniversalPredecessor()));
SchedulerLock lock;
@@ -332,7 +332,7 @@
});
}
-TEST(TaskSchedulerLock, AcquireUniversalPredecessorAfterUniversalPredecessor) {
+TEST(ThreadPoolLock, AcquireUniversalPredecessorAfterUniversalPredecessor) {
// A universal-predecessor lock may not be acquired after any other lock, not
// even another universal predecessor.
SchedulerLock universal_predecessor((UniversalPredecessor()));
@@ -344,7 +344,7 @@
});
}
-TEST(TaskSchedulerLock, AssertNoLockHeldOnCurrentThread) {
+TEST(ThreadPoolLock, AssertNoLockHeldOnCurrentThread) {
// AssertNoLockHeldOnCurrentThread() shouldn't fail when no lock is acquired.
SchedulerLock::AssertNoLockHeldOnCurrentThread();
@@ -366,7 +366,7 @@
} // namespace
-TEST(TaskSchedulerLock, AnnotateAcquiredLockAlias) {
+TEST(ThreadPoolLock, AnnotateAcquiredLockAlias) {
MemberGuardedByLock member_guarded_by_lock;
SchedulerLock* acquired = &member_guarded_by_lock.lock_;
AutoSchedulerLock auto_lock(*acquired);
diff --git a/base/task/task_scheduler/scheduler_parallel_task_runner.cc b/base/task/thread_pool/scheduler_parallel_task_runner.cc
similarity index 89%
rename from base/task/task_scheduler/scheduler_parallel_task_runner.cc
rename to base/task/thread_pool/scheduler_parallel_task_runner.cc
index ac424b70..35c41541 100644
--- a/base/task/task_scheduler/scheduler_parallel_task_runner.cc
+++ b/base/task/thread_pool/scheduler_parallel_task_runner.cc
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_parallel_task_runner.h"
-#include "base/task/task_scheduler/scheduler_task_runner_delegate.h"
+#include "base/task/thread_pool/scheduler_parallel_task_runner.h"
+#include "base/task/thread_pool/scheduler_task_runner_delegate.h"
-#include "base/task/task_scheduler/sequence.h"
+#include "base/task/thread_pool/sequence.h"
namespace base {
namespace internal {
diff --git a/base/task/task_scheduler/scheduler_parallel_task_runner.h b/base/task/thread_pool/scheduler_parallel_task_runner.h
similarity index 86%
rename from base/task/task_scheduler/scheduler_parallel_task_runner.h
rename to base/task/thread_pool/scheduler_parallel_task_runner.h
index 84552e2..40ca662 100644
--- a/base/task/task_scheduler/scheduler_parallel_task_runner.h
+++ b/base/task/thread_pool/scheduler_parallel_task_runner.h
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SCHEDULER_PARALLEL_TASK_RUNNER_H_
-#define BASE_TASK_TASK_SCHEDULER_SCHEDULER_PARALLEL_TASK_RUNNER_H_
+#ifndef BASE_TASK_THREAD_POOL_SCHEDULER_PARALLEL_TASK_RUNNER_H_
+#define BASE_TASK_THREAD_POOL_SCHEDULER_PARALLEL_TASK_RUNNER_H_
#include "base/base_export.h"
#include "base/callback_forward.h"
#include "base/containers/flat_set.h"
#include "base/location.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/scheduler_lock.h"
#include "base/task_runner.h"
#include "base/thread_annotations.h"
#include "base/time/time.h"
@@ -58,4 +58,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SCHEDULER_PARALLEL_TASK_RUNNER_H_
+#endif // BASE_TASK_THREAD_POOL_SCHEDULER_PARALLEL_TASK_RUNNER_H_
diff --git a/base/task/task_scheduler/scheduler_sequenced_task_runner.cc b/base/task/thread_pool/scheduler_sequenced_task_runner.cc
similarity index 93%
rename from base/task/task_scheduler/scheduler_sequenced_task_runner.cc
rename to base/task/thread_pool/scheduler_sequenced_task_runner.cc
index 0fc3ab9..b85312b 100644
--- a/base/task/task_scheduler/scheduler_sequenced_task_runner.cc
+++ b/base/task/thread_pool/scheduler_sequenced_task_runner.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_sequenced_task_runner.h"
+#include "base/task/thread_pool/scheduler_sequenced_task_runner.h"
#include "base/sequence_token.h"
@@ -37,7 +37,7 @@
const Location& from_here,
OnceClosure closure,
TimeDelta delay) {
- // Tasks are never nested within the task scheduler.
+ // Tasks are never nested within the thread pool.
return PostDelayedTask(from_here, std::move(closure), delay);
}
diff --git a/base/task/task_scheduler/scheduler_sequenced_task_runner.h b/base/task/thread_pool/scheduler_sequenced_task_runner.h
similarity index 83%
rename from base/task/task_scheduler/scheduler_sequenced_task_runner.h
rename to base/task/thread_pool/scheduler_sequenced_task_runner.h
index 491cf76..749b7f2 100644
--- a/base/task/task_scheduler/scheduler_sequenced_task_runner.h
+++ b/base/task/thread_pool/scheduler_sequenced_task_runner.h
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SCHEDULER_SEQUENCED_TASK_RUNNER_H_
-#define BASE_TASK_TASK_SCHEDULER_SCHEDULER_SEQUENCED_TASK_RUNNER_H_
+#ifndef BASE_TASK_THREAD_POOL_SCHEDULER_SEQUENCED_TASK_RUNNER_H_
+#define BASE_TASK_THREAD_POOL_SCHEDULER_SEQUENCED_TASK_RUNNER_H_
#include "base/base_export.h"
#include "base/callback_forward.h"
#include "base/location.h"
-#include "base/task/task_scheduler/scheduler_task_runner_delegate.h"
-#include "base/task/task_scheduler/sequence.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/scheduler_task_runner_delegate.h"
+#include "base/task/thread_pool/sequence.h"
#include "base/time/time.h"
#include "base/updateable_sequenced_task_runner.h"
@@ -53,4 +53,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SCHEDULER_SEQUENCED_TASK_RUNNER_H_
+#endif // BASE_TASK_THREAD_POOL_SCHEDULER_SEQUENCED_TASK_RUNNER_H_
diff --git a/base/task/task_scheduler/scheduler_single_thread_task_runner_manager.cc b/base/task/thread_pool/scheduler_single_thread_task_runner_manager.cc
similarity index 96%
rename from base/task/task_scheduler/scheduler_single_thread_task_runner_manager.cc
rename to base/task/thread_pool/scheduler_single_thread_task_runner_manager.cc
index c5cb647..222f4bc 100644
--- a/base/task/task_scheduler/scheduler_single_thread_task_runner_manager.cc
+++ b/base/task/thread_pool/scheduler_single_thread_task_runner_manager.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_single_thread_task_runner_manager.h"
+#include "base/task/thread_pool/scheduler_single_thread_task_runner_manager.h"
#include <algorithm>
#include <memory>
@@ -16,13 +16,13 @@
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/atomic_flag.h"
-#include "base/task/task_scheduler/delayed_task_manager.h"
-#include "base/task/task_scheduler/priority_queue.h"
-#include "base/task/task_scheduler/scheduler_worker.h"
-#include "base/task/task_scheduler/sequence.h"
-#include "base/task/task_scheduler/task.h"
-#include "base/task/task_scheduler/task_tracker.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/delayed_task_manager.h"
+#include "base/task/thread_pool/priority_queue.h"
+#include "base/task/thread_pool/scheduler_worker.h"
+#include "base/task/thread_pool/sequence.h"
+#include "base/task/thread_pool/task.h"
+#include "base/task/thread_pool/task_tracker.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
@@ -48,9 +48,9 @@
// unit tests so that SchedulerSingleThreadTaskRunnerManager bound TaskRunners
// can return false on PostTask, letting such callers know they should complete
// necessary work synchronously. Note: |!g_manager_is_alive| is generally
-// equivalent to |!TaskScheduler::GetInstance()| but has the advantage of being
-// valid in task_scheduler unit tests that don't instantiate a full
-// TaskScheduler.
+// equivalent to |!ThreadPool::GetInstance()| but has the advantage of being
+// valid in thread_pool unit tests that don't instantiate a full
+// ThreadPool.
bool g_manager_is_alive = false;
// Allows for checking the PlatformThread::CurrentRef() against a set
@@ -309,7 +309,7 @@
bool PostNonNestableDelayedTask(const Location& from_here,
OnceClosure closure,
TimeDelta delay) override {
- // Tasks are never nested within the task scheduler.
+ // Tasks are never nested within the thread pool.
return PostDelayedTask(from_here, std::move(closure), delay);
}
@@ -332,7 +332,7 @@
// entire destruction (which happens-after the manager's destruction). Yes,
// there's a theoretical use case where the last ref to this
// SchedulerSingleThreadTaskRunner is handed to a thread not controlled by
- // task_scheduler and that this ends up causing
+ // thread_pool and that this ends up causing
// ~SchedulerSingleThreadTaskRunner() to race with
// ~SchedulerSingleThreadTaskRunnerManager() but this is intentionally not
// supported (and it doesn't matter in production where we leak the task
@@ -532,7 +532,7 @@
int id,
SingleThreadTaskRunnerThreadMode thread_mode) {
return std::make_unique<SchedulerWorkerDelegate>(
- StringPrintf("TaskSchedulerSingleThread%s%d", name.c_str(), id),
+ StringPrintf("ThreadPoolSingleThread%s%d", name.c_str(), id),
thread_mode == SingleThreadTaskRunnerThreadMode::DEDICATED
? SchedulerWorker::ThreadLabel::DEDICATED
: SchedulerWorker::ThreadLabel::SHARED);
@@ -546,7 +546,7 @@
int id,
SingleThreadTaskRunnerThreadMode thread_mode) {
return std::make_unique<SchedulerWorkerCOMDelegate>(
- StringPrintf("TaskSchedulerSingleThreadCOMSTA%s%d", name.c_str(), id),
+ StringPrintf("ThreadPoolSingleThreadCOMSTA%s%d", name.c_str(), id),
thread_mode == SingleThreadTaskRunnerThreadMode::DEDICATED
? SchedulerWorker::ThreadLabel::DEDICATED_COM
: SchedulerWorker::ThreadLabel::SHARED_COM,
diff --git a/base/task/task_scheduler/scheduler_single_thread_task_runner_manager.h b/base/task/thread_pool/scheduler_single_thread_task_runner_manager.h
similarity index 90%
rename from base/task/task_scheduler/scheduler_single_thread_task_runner_manager.h
rename to base/task/thread_pool/scheduler_single_thread_task_runner_manager.h
index 220dde2..ea57bec 100644
--- a/base/task/task_scheduler/scheduler_single_thread_task_runner_manager.h
+++ b/base/task/thread_pool/scheduler_single_thread_task_runner_manager.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SCHEDULER_SINGLE_THREAD_TASK_RUNNER_MANAGER_H_
-#define BASE_TASK_TASK_SCHEDULER_SCHEDULER_SINGLE_THREAD_TASK_RUNNER_MANAGER_H_
+#ifndef BASE_TASK_THREAD_POOL_SCHEDULER_SINGLE_THREAD_TASK_RUNNER_MANAGER_H_
+#define BASE_TASK_THREAD_POOL_SCHEDULER_SINGLE_THREAD_TASK_RUNNER_MANAGER_H_
#include <memory>
#include <string>
@@ -13,9 +13,9 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/task/single_thread_task_runner_thread_mode.h"
-#include "base/task/task_scheduler/environment_config.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
-#include "base/task/task_scheduler/tracked_ref.h"
+#include "base/task/thread_pool/environment_config.h"
+#include "base/task/thread_pool/scheduler_lock.h"
+#include "base/task/thread_pool/tracked_ref.h"
#include "base/thread_annotations.h"
#include "base/threading/platform_thread.h"
#include "build/build_config.h"
@@ -64,7 +64,7 @@
void Start(SchedulerWorkerObserver* scheduler_worker_observer = nullptr);
// Creates a SingleThreadTaskRunner which runs tasks with |traits| on a thread
- // named "TaskSchedulerSingleThread[Shared]" +
+ // named "ThreadPoolSingleThread[Shared]" +
// kEnvironmentParams[GetEnvironmentIndexForTraits(traits)].name_suffix +
// index.
scoped_refptr<SingleThreadTaskRunner> CreateSingleThreadTaskRunnerWithTraits(
@@ -73,7 +73,7 @@
#if defined(OS_WIN)
// Creates a SingleThreadTaskRunner which runs tasks with |traits| on a COM
- // STA thread named "TaskSchedulerSingleThreadCOMSTA[Shared]" +
+ // STA thread named "ThreadPoolSingleThreadCOMSTA[Shared]" +
// kEnvironmentParams[GetEnvironmentIndexForTraits(traits)].name_suffix +
// index.
scoped_refptr<SingleThreadTaskRunner> CreateCOMSTATaskRunnerWithTraits(
@@ -151,4 +151,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SCHEDULER_SINGLE_THREAD_TASK_RUNNER_MANAGER_H_
+#endif // BASE_TASK_THREAD_POOL_SCHEDULER_SINGLE_THREAD_TASK_RUNNER_MANAGER_H_
diff --git a/base/task/task_scheduler/scheduler_single_thread_task_runner_manager_unittest.cc b/base/task/thread_pool/scheduler_single_thread_task_runner_manager_unittest.cc
similarity index 86%
rename from base/task/task_scheduler/scheduler_single_thread_task_runner_manager_unittest.cc
rename to base/task/thread_pool/scheduler_single_thread_task_runner_manager_unittest.cc
index f33be2fb..3b38954 100644
--- a/base/task/task_scheduler/scheduler_single_thread_task_runner_manager_unittest.cc
+++ b/base/task/thread_pool/scheduler_single_thread_task_runner_manager_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_single_thread_task_runner_manager.h"
+#include "base/task/thread_pool/scheduler_single_thread_task_runner_manager.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -11,11 +11,11 @@
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/delayed_task_manager.h"
-#include "base/task/task_scheduler/environment_config.h"
-#include "base/task/task_scheduler/scheduler_worker_pool_params.h"
-#include "base/task/task_scheduler/task_tracker.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/delayed_task_manager.h"
+#include "base/task/thread_pool/environment_config.h"
+#include "base/task/thread_pool/scheduler_worker_pool_params.h"
+#include "base/task/thread_pool/task_tracker.h"
#include "base/test/gtest_util.h"
#include "base/test/test_timeouts.h"
#include "base/threading/platform_thread.h"
@@ -37,10 +37,10 @@
namespace {
-class TaskSchedulerSingleThreadTaskRunnerManagerTest : public testing::Test {
+class ThreadPoolSingleThreadTaskRunnerManagerTest : public testing::Test {
public:
- TaskSchedulerSingleThreadTaskRunnerManagerTest()
- : service_thread_("TaskSchedulerServiceThread") {}
+ ThreadPoolSingleThreadTaskRunnerManagerTest()
+ : service_thread_("ThreadPoolServiceThread") {}
void SetUp() override {
service_thread_.Start();
@@ -74,7 +74,7 @@
single_thread_task_runner_manager_;
private:
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerSingleThreadTaskRunnerManagerTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolSingleThreadTaskRunnerManagerTest);
};
void CaptureThreadRef(PlatformThreadRef* thread_ref) {
@@ -97,7 +97,7 @@
} // namespace
-TEST_F(TaskSchedulerSingleThreadTaskRunnerManagerTest, DifferentThreadsUsed) {
+TEST_F(ThreadPoolSingleThreadTaskRunnerManagerTest, DifferentThreadsUsed) {
scoped_refptr<SingleThreadTaskRunner> task_runner_1 =
single_thread_task_runner_manager_
->CreateSingleThreadTaskRunnerWithTraits(
@@ -123,7 +123,7 @@
EXPECT_NE(thread_ref_1, thread_ref_2);
}
-TEST_F(TaskSchedulerSingleThreadTaskRunnerManagerTest, SameThreadUsed) {
+TEST_F(ThreadPoolSingleThreadTaskRunnerManagerTest, SameThreadUsed) {
scoped_refptr<SingleThreadTaskRunner> task_runner_1 =
single_thread_task_runner_manager_
->CreateSingleThreadTaskRunnerWithTraits(
@@ -149,7 +149,7 @@
EXPECT_EQ(thread_ref_1, thread_ref_2);
}
-TEST_F(TaskSchedulerSingleThreadTaskRunnerManagerTest,
+TEST_F(ThreadPoolSingleThreadTaskRunnerManagerTest,
RunsTasksInCurrentSequence) {
scoped_refptr<SingleThreadTaskRunner> task_runner_1 =
single_thread_task_runner_manager_
@@ -188,7 +188,7 @@
task_tracker_.Shutdown();
}
-TEST_F(TaskSchedulerSingleThreadTaskRunnerManagerTest,
+TEST_F(ThreadPoolSingleThreadTaskRunnerManagerTest,
SharedWithBaseSyncPrimitivesDCHECKs) {
testing::GTEST_FLAG(death_test_style) = "threadsafe";
EXPECT_DCHECK_DEATH({
@@ -198,7 +198,7 @@
}
// Regression test for https://crbug.com/829786
-TEST_F(TaskSchedulerSingleThreadTaskRunnerManagerTest,
+TEST_F(ThreadPoolSingleThreadTaskRunnerManagerTest,
ContinueOnShutdownDoesNotBlockBlockShutdown) {
WaitableEvent task_has_started;
WaitableEvent task_can_continue;
@@ -242,20 +242,19 @@
namespace {
-class TaskSchedulerSingleThreadTaskRunnerManagerCommonTest
- : public TaskSchedulerSingleThreadTaskRunnerManagerTest,
+class ThreadPoolSingleThreadTaskRunnerManagerCommonTest
+ : public ThreadPoolSingleThreadTaskRunnerManagerTest,
public ::testing::WithParamInterface<SingleThreadTaskRunnerThreadMode> {
public:
- TaskSchedulerSingleThreadTaskRunnerManagerCommonTest() = default;
+ ThreadPoolSingleThreadTaskRunnerManagerCommonTest() = default;
private:
- DISALLOW_COPY_AND_ASSIGN(
- TaskSchedulerSingleThreadTaskRunnerManagerCommonTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolSingleThreadTaskRunnerManagerCommonTest);
};
} // namespace
-TEST_P(TaskSchedulerSingleThreadTaskRunnerManagerCommonTest,
+TEST_P(ThreadPoolSingleThreadTaskRunnerManagerCommonTest,
PrioritySetCorrectly) {
// Why are events used here instead of the task tracker?
// Shutting down can cause priorities to get raised. This means we have to use
@@ -295,7 +294,7 @@
EXPECT_EQ(ThreadPriority::NORMAL, thread_priority_normal);
}
-TEST_P(TaskSchedulerSingleThreadTaskRunnerManagerCommonTest, ThreadNamesSet) {
+TEST_P(ThreadPoolSingleThreadTaskRunnerManagerCommonTest, ThreadNamesSet) {
constexpr TaskTraits foo_traits = {TaskPriority::BEST_EFFORT,
TaskShutdownBehavior::BLOCK_SHUTDOWN};
scoped_refptr<SingleThreadTaskRunner> foo_task_runner =
@@ -338,7 +337,7 @@
}
}
-TEST_P(TaskSchedulerSingleThreadTaskRunnerManagerCommonTest,
+TEST_P(ThreadPoolSingleThreadTaskRunnerManagerCommonTest,
PostTaskAfterShutdown) {
auto task_runner =
single_thread_task_runner_manager_
@@ -348,7 +347,7 @@
}
// Verify that a Task runs shortly after its delay expires.
-TEST_P(TaskSchedulerSingleThreadTaskRunnerManagerCommonTest, PostDelayedTask) {
+TEST_P(ThreadPoolSingleThreadTaskRunnerManagerCommonTest, PostDelayedTask) {
TimeTicks start_time = TimeTicks::Now();
WaitableEvent task_ran(WaitableEvent::ResetPolicy::AUTOMATIC,
@@ -382,7 +381,7 @@
// Verify that posting tasks after the single-thread manager is destroyed fails
// but doesn't crash.
-TEST_P(TaskSchedulerSingleThreadTaskRunnerManagerCommonTest,
+TEST_P(ThreadPoolSingleThreadTaskRunnerManagerCommonTest,
PostTaskAfterDestroy) {
auto task_runner =
single_thread_task_runner_manager_
@@ -395,7 +394,7 @@
INSTANTIATE_TEST_SUITE_P(
AllModes,
- TaskSchedulerSingleThreadTaskRunnerManagerCommonTest,
+ ThreadPoolSingleThreadTaskRunnerManagerCommonTest,
::testing::Values(SingleThreadTaskRunnerThreadMode::SHARED,
SingleThreadTaskRunnerThreadMode::DEDICATED));
@@ -424,11 +423,11 @@
DISALLOW_COPY_AND_ASSIGN(CallJoinFromDifferentThread);
};
-class TaskSchedulerSingleThreadTaskRunnerManagerJoinTest
- : public TaskSchedulerSingleThreadTaskRunnerManagerTest {
+class ThreadPoolSingleThreadTaskRunnerManagerJoinTest
+ : public ThreadPoolSingleThreadTaskRunnerManagerTest {
public:
- TaskSchedulerSingleThreadTaskRunnerManagerJoinTest() = default;
- ~TaskSchedulerSingleThreadTaskRunnerManagerJoinTest() override = default;
+ ThreadPoolSingleThreadTaskRunnerManagerJoinTest() = default;
+ ~ThreadPoolSingleThreadTaskRunnerManagerJoinTest() override = default;
protected:
void TearDownSingleThreadTaskRunnerManager() override {
@@ -437,12 +436,12 @@
}
private:
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerSingleThreadTaskRunnerManagerJoinTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolSingleThreadTaskRunnerManagerJoinTest);
};
} // namespace
-TEST_F(TaskSchedulerSingleThreadTaskRunnerManagerJoinTest, ConcurrentJoin) {
+TEST_F(ThreadPoolSingleThreadTaskRunnerManagerJoinTest, ConcurrentJoin) {
// Exercises the codepath where the workers are unavailable for unregistration
// because of a Join call.
WaitableEvent task_running;
@@ -469,7 +468,7 @@
join_from_different_thread.Join();
}
-TEST_F(TaskSchedulerSingleThreadTaskRunnerManagerJoinTest,
+TEST_F(ThreadPoolSingleThreadTaskRunnerManagerJoinTest,
ConcurrentJoinExtraSkippedTask) {
// Tests to make sure that tasks are properly cleaned up at Join, allowing
// SingleThreadTaskRunners to unregister themselves.
@@ -500,8 +499,7 @@
#if defined(OS_WIN)
-TEST_P(TaskSchedulerSingleThreadTaskRunnerManagerCommonTest,
- COMSTAInitialized) {
+TEST_P(ThreadPoolSingleThreadTaskRunnerManagerCommonTest, COMSTAInitialized) {
scoped_refptr<SingleThreadTaskRunner> com_task_runner =
single_thread_task_runner_manager_->CreateCOMSTATaskRunnerWithTraits(
{TaskShutdownBehavior::BLOCK_SHUTDOWN}, GetParam());
@@ -512,7 +510,7 @@
task_tracker_.Shutdown();
}
-TEST_F(TaskSchedulerSingleThreadTaskRunnerManagerTest, COMSTASameThreadUsed) {
+TEST_F(ThreadPoolSingleThreadTaskRunnerManagerTest, COMSTASameThreadUsed) {
scoped_refptr<SingleThreadTaskRunner> task_runner_1 =
single_thread_task_runner_manager_->CreateCOMSTATaskRunnerWithTraits(
{TaskShutdownBehavior::BLOCK_SHUTDOWN},
@@ -539,15 +537,15 @@
namespace {
const wchar_t* const kTestWindowClassName =
- L"TaskSchedulerSingleThreadTaskRunnerManagerTestWinMessageWindow";
+ L"ThreadPoolSingleThreadTaskRunnerManagerTestWinMessageWindow";
-class TaskSchedulerSingleThreadTaskRunnerManagerTestWin
- : public TaskSchedulerSingleThreadTaskRunnerManagerTest {
+class ThreadPoolSingleThreadTaskRunnerManagerTestWin
+ : public ThreadPoolSingleThreadTaskRunnerManagerTest {
public:
- TaskSchedulerSingleThreadTaskRunnerManagerTestWin() = default;
+ ThreadPoolSingleThreadTaskRunnerManagerTestWin() = default;
void SetUp() override {
- TaskSchedulerSingleThreadTaskRunnerManagerTest::SetUp();
+ ThreadPoolSingleThreadTaskRunnerManagerTest::SetUp();
register_class_succeeded_ = RegisterTestWindowClass();
ASSERT_TRUE(register_class_succeeded_);
}
@@ -556,7 +554,7 @@
if (register_class_succeeded_)
::UnregisterClass(kTestWindowClassName, CURRENT_MODULE());
- TaskSchedulerSingleThreadTaskRunnerManagerTest::TearDown();
+ ThreadPoolSingleThreadTaskRunnerManagerTest::TearDown();
}
HWND CreateTestWindow() {
@@ -576,12 +574,12 @@
bool register_class_succeeded_ = false;
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerSingleThreadTaskRunnerManagerTestWin);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolSingleThreadTaskRunnerManagerTestWin);
};
} // namespace
-TEST_F(TaskSchedulerSingleThreadTaskRunnerManagerTestWin, PumpsMessages) {
+TEST_F(ThreadPoolSingleThreadTaskRunnerManagerTestWin, PumpsMessages) {
scoped_refptr<SingleThreadTaskRunner> com_task_runner =
single_thread_task_runner_manager_->CreateCOMSTATaskRunnerWithTraits(
{TaskShutdownBehavior::BLOCK_SHUTDOWN},
@@ -592,10 +590,9 @@
// COM callback.
com_task_runner->PostTask(
FROM_HERE,
- BindOnce(
- [](TaskSchedulerSingleThreadTaskRunnerManagerTestWin* test_harness,
- HWND* hwnd) { *hwnd = test_harness->CreateTestWindow(); },
- Unretained(this), &hwnd));
+ BindOnce([](ThreadPoolSingleThreadTaskRunnerManagerTestWin* test_harness,
+ HWND* hwnd) { *hwnd = test_harness->CreateTestWindow(); },
+ Unretained(this), &hwnd));
task_tracker_.FlushForTesting();
@@ -614,24 +611,23 @@
namespace {
-class TaskSchedulerSingleThreadTaskRunnerManagerStartTest
- : public TaskSchedulerSingleThreadTaskRunnerManagerTest {
+class ThreadPoolSingleThreadTaskRunnerManagerStartTest
+ : public ThreadPoolSingleThreadTaskRunnerManagerTest {
public:
- TaskSchedulerSingleThreadTaskRunnerManagerStartTest() = default;
+ ThreadPoolSingleThreadTaskRunnerManagerStartTest() = default;
private:
void StartSingleThreadTaskRunnerManagerFromSetUp() override {
// Start() is called in the test body rather than in SetUp().
}
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerSingleThreadTaskRunnerManagerStartTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolSingleThreadTaskRunnerManagerStartTest);
};
} // namespace
// Verify that a task posted before Start() doesn't run until Start() is called.
-TEST_F(TaskSchedulerSingleThreadTaskRunnerManagerStartTest,
- PostTaskBeforeStart) {
+TEST_F(ThreadPoolSingleThreadTaskRunnerManagerStartTest, PostTaskBeforeStart) {
AtomicFlag manager_started;
WaitableEvent task_finished;
single_thread_task_runner_manager_
diff --git a/base/task/task_scheduler/scheduler_task_runner_delegate.cc b/base/task/thread_pool/scheduler_task_runner_delegate.cc
similarity index 94%
rename from base/task/task_scheduler/scheduler_task_runner_delegate.cc
rename to base/task/thread_pool/scheduler_task_runner_delegate.cc
index b41629b..f7aedcf 100644
--- a/base/task/task_scheduler/scheduler_task_runner_delegate.cc
+++ b/base/task/thread_pool/scheduler_task_runner_delegate.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_task_runner_delegate.h"
+#include "base/task/thread_pool/scheduler_task_runner_delegate.h"
namespace base {
namespace internal {
diff --git a/base/task/task_scheduler/scheduler_task_runner_delegate.h b/base/task/thread_pool/scheduler_task_runner_delegate.h
similarity index 83%
rename from base/task/task_scheduler/scheduler_task_runner_delegate.h
rename to base/task/thread_pool/scheduler_task_runner_delegate.h
index 90def4e..e563fb31 100644
--- a/base/task/task_scheduler/scheduler_task_runner_delegate.h
+++ b/base/task/thread_pool/scheduler_task_runner_delegate.h
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SCHEDULER_TASK_RUNNER_DELEGATE_H_
-#define BASE_TASK_TASK_SCHEDULER_SCHEDULER_TASK_RUNNER_DELEGATE_H_
+#ifndef BASE_TASK_THREAD_POOL_SCHEDULER_TASK_RUNNER_DELEGATE_H_
+#define BASE_TASK_THREAD_POOL_SCHEDULER_TASK_RUNNER_DELEGATE_H_
#include "base/base_export.h"
-#include "base/task/task_scheduler/sequence.h"
-#include "base/task/task_scheduler/task.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/sequence.h"
+#include "base/task/thread_pool/task.h"
namespace base {
namespace internal {
@@ -22,7 +22,7 @@
// Returns true if a SchedulerTaskRunnerDelegate instance exists in the
// process. This is needed in case of unit tests wherein a TaskRunner
- // outlives the TaskScheduler that created it.
+ // outlives the ThreadPool that created it.
static bool Exists();
// Invoked when a |task| is posted to the SchedulerParallelTaskRunner or
@@ -49,4 +49,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SCHEDULER_TASK_RUNNER_DELEGATE_H_
+#endif // BASE_TASK_THREAD_POOL_SCHEDULER_TASK_RUNNER_DELEGATE_H_
diff --git a/base/task/task_scheduler/scheduler_worker.cc b/base/task/thread_pool/scheduler_worker.cc
similarity index 92%
rename from base/task/task_scheduler/scheduler_worker.cc
rename to base/task/thread_pool/scheduler_worker.cc
index c8d951c..c4f81c8 100644
--- a/base/task/task_scheduler/scheduler_worker.cc
+++ b/base/task/thread_pool/scheduler_worker.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_worker.h"
+#include "base/task/thread_pool/scheduler_worker.h"
#include <stddef.h>
@@ -11,9 +11,9 @@
#include "base/compiler_specific.h"
#include "base/debug/alias.h"
#include "base/logging.h"
-#include "base/task/task_scheduler/environment_config.h"
-#include "base/task/task_scheduler/scheduler_worker_observer.h"
-#include "base/task/task_scheduler/task_tracker.h"
+#include "base/task/thread_pool/environment_config.h"
+#include "base/task/thread_pool/scheduler_worker_observer.h"
+#include "base/task/thread_pool/task_tracker.h"
#include "base/trace_event/trace_event.h"
#if defined(OS_MACOSX)
@@ -292,9 +292,9 @@
void SchedulerWorker::RunWorker() {
DCHECK_EQ(self_, this);
- TRACE_EVENT_INSTANT0("task_scheduler", "SchedulerWorkerThread born",
+ TRACE_EVENT_INSTANT0("thread_pool", "SchedulerWorkerThread born",
TRACE_EVENT_SCOPE_THREAD);
- TRACE_EVENT_BEGIN0("task_scheduler", "SchedulerWorkerThread active");
+ TRACE_EVENT_BEGIN0("thread_pool", "SchedulerWorkerThread active");
if (scheduler_worker_observer_)
scheduler_worker_observer_->OnSchedulerWorkerMainEntry();
@@ -303,9 +303,9 @@
// A SchedulerWorker starts out waiting for work.
{
- TRACE_EVENT_END0("task_scheduler", "SchedulerWorkerThread active");
+ TRACE_EVENT_END0("thread_pool", "SchedulerWorkerThread active");
delegate_->WaitForWork(&wake_up_event_);
- TRACE_EVENT_BEGIN0("task_scheduler", "SchedulerWorkerThread active");
+ TRACE_EVENT_BEGIN0("thread_pool", "SchedulerWorkerThread active");
}
// When defined(COM_INIT_CHECK_HOOK_ENABLED), ignore
@@ -331,9 +331,9 @@
if (ShouldExit())
break;
- TRACE_EVENT_END0("task_scheduler", "SchedulerWorkerThread active");
+ TRACE_EVENT_END0("thread_pool", "SchedulerWorkerThread active");
delegate_->WaitForWork(&wake_up_event_);
- TRACE_EVENT_BEGIN0("task_scheduler", "SchedulerWorkerThread active");
+ TRACE_EVENT_BEGIN0("thread_pool", "SchedulerWorkerThread active");
continue;
}
@@ -362,8 +362,8 @@
// and as such no more member accesses should be made after this point.
self_ = nullptr;
- TRACE_EVENT_END0("task_scheduler", "SchedulerWorkerThread active");
- TRACE_EVENT_INSTANT0("task_scheduler", "SchedulerWorkerThread dead",
+ TRACE_EVENT_END0("thread_pool", "SchedulerWorkerThread active");
+ TRACE_EVENT_INSTANT0("thread_pool", "SchedulerWorkerThread dead",
TRACE_EVENT_SCOPE_THREAD);
}
diff --git a/base/task/task_scheduler/scheduler_worker.h b/base/task/thread_pool/scheduler_worker.h
similarity index 95%
rename from base/task/task_scheduler/scheduler_worker.h
rename to base/task/thread_pool/scheduler_worker.h
index 88d1608..2f028d93 100644
--- a/base/task/task_scheduler/scheduler_worker.h
+++ b/base/task/thread_pool/scheduler_worker.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_H_
-#define BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_H_
+#ifndef BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_H_
+#define BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_H_
#include <memory>
@@ -12,11 +12,11 @@
#include "base/memory/ref_counted.h"
#include "base/synchronization/atomic_flag.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/can_schedule_sequence_observer.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
-#include "base/task/task_scheduler/scheduler_worker_params.h"
-#include "base/task/task_scheduler/sequence.h"
-#include "base/task/task_scheduler/tracked_ref.h"
+#include "base/task/thread_pool/can_schedule_sequence_observer.h"
+#include "base/task/thread_pool/scheduler_lock.h"
+#include "base/task/thread_pool/scheduler_worker_params.h"
+#include "base/task/thread_pool/sequence.h"
+#include "base/task/thread_pool/tracked_ref.h"
#include "base/thread_annotations.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
@@ -254,4 +254,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_H_
+#endif // BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_H_
diff --git a/base/task/thread_pool/scheduler_worker_observer.h b/base/task/thread_pool/scheduler_worker_observer.h
new file mode 100644
index 0000000..bd04bf4
--- /dev/null
+++ b/base/task/thread_pool/scheduler_worker_observer.h
@@ -0,0 +1,27 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_OBSERVER_H_
+#define BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_OBSERVER_H_
+
+namespace base {
+
+// Interface to observe entry and exit of the main function of a ThreadPool
+// worker.
+class SchedulerWorkerObserver {
+ public:
+ virtual ~SchedulerWorkerObserver() = default;
+
+ // Invoked at the beginning of the main function of a ThreadPool worker,
+ // before any task runs.
+ virtual void OnSchedulerWorkerMainEntry() = 0;
+
+ // Invoked at the end of the main function of a ThreadPool worker, when it
+ // can no longer run tasks.
+ virtual void OnSchedulerWorkerMainExit() = 0;
+};
+
+} // namespace base
+
+#endif // BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_OBSERVER_H_
diff --git a/base/task/task_scheduler/scheduler_worker_params.h b/base/task/thread_pool/scheduler_worker_params.h
similarity index 76%
rename from base/task/task_scheduler/scheduler_worker_params.h
rename to base/task/thread_pool/scheduler_worker_params.h
index 82123b2..4929e8f 100644
--- a/base/task/task_scheduler/scheduler_worker_params.h
+++ b/base/task/thread_pool/scheduler_worker_params.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_PARAMS_H_
-#define BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_PARAMS_H_
+#ifndef BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_PARAMS_H_
+#define BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_PARAMS_H_
namespace base {
@@ -21,4 +21,4 @@
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_PARAMS_H_
+#endif // BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_PARAMS_H_
diff --git a/base/task/task_scheduler/scheduler_worker_pool.cc b/base/task/thread_pool/scheduler_worker_pool.cc
similarity index 97%
rename from base/task/task_scheduler/scheduler_worker_pool.cc
rename to base/task/thread_pool/scheduler_worker_pool.cc
index 14e5e36..341678d 100644
--- a/base/task/task_scheduler/scheduler_worker_pool.cc
+++ b/base/task/thread_pool/scheduler_worker_pool.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_worker_pool.h"
+#include "base/task/thread_pool/scheduler_worker_pool.h"
#include <utility>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/lazy_instance.h"
-#include "base/task/task_scheduler/task_tracker.h"
+#include "base/task/thread_pool/task_tracker.h"
#include "base/threading/thread_local.h"
namespace base {
diff --git a/base/task/task_scheduler/scheduler_worker_pool.h b/base/task/thread_pool/scheduler_worker_pool.h
similarity index 93%
rename from base/task/task_scheduler/scheduler_worker_pool.h
rename to base/task/thread_pool/scheduler_worker_pool.h
index 9c14fe3..99b3af47 100644
--- a/base/task/task_scheduler/scheduler_worker_pool.h
+++ b/base/task/thread_pool/scheduler_worker_pool.h
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_H_
-#define BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_H_
+#ifndef BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_POOL_H_
+#define BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_POOL_H_
#include "base/base_export.h"
#include "base/memory/ref_counted.h"
-#include "base/task/task_scheduler/can_schedule_sequence_observer.h"
-#include "base/task/task_scheduler/priority_queue.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
-#include "base/task/task_scheduler/sequence.h"
-#include "base/task/task_scheduler/task.h"
-#include "base/task/task_scheduler/tracked_ref.h"
+#include "base/task/thread_pool/can_schedule_sequence_observer.h"
+#include "base/task/thread_pool/priority_queue.h"
+#include "base/task/thread_pool/scheduler_lock.h"
+#include "base/task/thread_pool/sequence.h"
+#include "base/task/thread_pool/task.h"
+#include "base/task/thread_pool/tracked_ref.h"
#include "build/build_config.h"
namespace base {
@@ -197,4 +197,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_H_
+#endif // BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_POOL_H_
diff --git a/base/task/task_scheduler/scheduler_worker_pool_impl.cc b/base/task/thread_pool/scheduler_worker_pool_impl.cc
similarity index 96%
rename from base/task/task_scheduler/scheduler_worker_pool_impl.cc
rename to base/task/thread_pool/scheduler_worker_pool_impl.cc
index 1effafe..72717b9 100644
--- a/base/task/task_scheduler/scheduler_worker_pool_impl.cc
+++ b/base/task/thread_pool/scheduler_worker_pool_impl.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_worker_pool_impl.h"
+#include "base/task/thread_pool/scheduler_worker_pool_impl.h"
#include <stddef.h>
@@ -24,9 +24,9 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/task_features.h"
-#include "base/task/task_scheduler/scheduler_worker_pool_params.h"
-#include "base/task/task_scheduler/task_tracker.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/scheduler_worker_pool_params.h"
+#include "base/task/thread_pool/task_tracker.h"
#include "base/threading/platform_thread.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/thread_checker.h"
@@ -45,16 +45,14 @@
namespace {
-constexpr char kPoolNameSuffix[] = "Pool";
-constexpr char kDetachDurationHistogramPrefix[] =
- "TaskScheduler.DetachDuration.";
+constexpr char kDetachDurationHistogramPrefix[] = "ThreadPool.DetachDuration.";
constexpr char kNumTasksBeforeDetachHistogramPrefix[] =
- "TaskScheduler.NumTasksBeforeDetach.";
+ "ThreadPool.NumTasksBeforeDetach.";
constexpr char kNumTasksBetweenWaitsHistogramPrefix[] =
- "TaskScheduler.NumTasksBetweenWaits.";
-constexpr char kNumWorkersHistogramPrefix[] = "TaskScheduler.NumWorkers.";
+ "ThreadPool.NumTasksBetweenWaits.";
+constexpr char kNumWorkersHistogramPrefix[] = "ThreadPool.NumWorkers.";
constexpr char kNumActiveWorkersHistogramPrefix[] =
- "TaskScheduler.NumActiveWorkers.";
+ "ThreadPool.NumActiveWorkers.";
constexpr size_t kMaxNumberOfWorkers = 256;
// In a background pool:
@@ -267,11 +265,11 @@
// Accessed only from the worker thread.
struct WorkerOnly {
// Number of tasks executed since the last time the
- // TaskScheduler.NumTasksBetweenWaits histogram was recorded.
+ // ThreadPool.NumTasksBetweenWaits histogram was recorded.
size_t num_tasks_since_last_wait = 0;
// Number of tasks executed since the last time the
- // TaskScheduler.NumTasksBeforeDetach histogram was recorded.
+ // ThreadPool.NumTasksBeforeDetach histogram was recorded.
size_t num_tasks_since_last_detach = 0;
// Whether the worker is currently running a task (i.e. GetWork() has
@@ -338,9 +336,7 @@
idle_workers_stack_cv_for_testing_(lock_.CreateConditionVariable()),
// Mimics the UMA_HISTOGRAM_LONG_TIMES macro.
detach_duration_histogram_(Histogram::FactoryTimeGet(
- JoinString({kDetachDurationHistogramPrefix, histogram_label,
- kPoolNameSuffix},
- ""),
+ JoinString({kDetachDurationHistogramPrefix, histogram_label}, ""),
TimeDelta::FromMilliseconds(1),
TimeDelta::FromHours(1),
50,
@@ -349,8 +345,7 @@
// than 1000 tasks before detaching, there is no need to know the exact
// number of tasks that ran.
num_tasks_before_detach_histogram_(Histogram::FactoryGet(
- JoinString({kNumTasksBeforeDetachHistogramPrefix, histogram_label,
- kPoolNameSuffix},
+ JoinString({kNumTasksBeforeDetachHistogramPrefix, histogram_label},
""),
1,
1000,
@@ -361,8 +356,7 @@
// When it runs more than 100 tasks, there is no need to know the exact
// number of tasks that ran.
num_tasks_between_waits_histogram_(Histogram::FactoryGet(
- JoinString({kNumTasksBetweenWaitsHistogramPrefix, histogram_label,
- kPoolNameSuffix},
+ JoinString({kNumTasksBetweenWaitsHistogramPrefix, histogram_label},
""),
1,
100,
@@ -373,21 +367,17 @@
// When it runs more than 100 worker, there is no need to know the exact
// number of workers that ran.
num_workers_histogram_(Histogram::FactoryGet(
- JoinString(
- {kNumWorkersHistogramPrefix, histogram_label, kPoolNameSuffix},
- ""),
+ JoinString({kNumWorkersHistogramPrefix, histogram_label}, ""),
1,
100,
50,
HistogramBase::kUmaTargetedHistogramFlag)),
- num_active_workers_histogram_(
- Histogram::FactoryGet(JoinString({kNumActiveWorkersHistogramPrefix,
- histogram_label, kPoolNameSuffix},
- ""),
- 1,
- 100,
- 50,
- HistogramBase::kUmaTargetedHistogramFlag)),
+ num_active_workers_histogram_(Histogram::FactoryGet(
+ JoinString({kNumActiveWorkersHistogramPrefix, histogram_label}, ""),
+ 1,
+ 100,
+ 50,
+ HistogramBase::kUmaTargetedHistogramFlag)),
tracked_ref_factory_(this) {
DCHECK(!histogram_label.empty());
DCHECK(!pool_label_.empty());
@@ -602,7 +592,7 @@
DCHECK_EQ(worker_only().num_tasks_since_last_wait, 0U);
PlatformThread::SetName(
- StringPrintf("TaskScheduler%sWorker", outer_->pool_label_.c_str()));
+ StringPrintf("ThreadPool%sWorker", outer_->pool_label_.c_str()));
outer_->BindToCurrentThread();
SetBlockingObserverForCurrentThread(this);
@@ -787,7 +777,7 @@
OnWorkerBecomesIdleLockRequired(SchedulerWorker* worker) {
DCHECK_CALLED_ON_VALID_THREAD(worker_thread_checker_);
- // Record the TaskScheduler.NumTasksBetweenWaits histogram. After GetWork()
+ // Record the ThreadPool.NumTasksBetweenWaits histogram. After GetWork()
// returns nullptr, the SchedulerWorker will perform a wait on its
// WaitableEvent, so we record how many tasks were ran since the last wait
// here.
diff --git a/base/task/task_scheduler/scheduler_worker_pool_impl.h b/base/task/thread_pool/scheduler_worker_pool_impl.h
similarity index 92%
rename from base/task/task_scheduler/scheduler_worker_pool_impl.h
rename to base/task/thread_pool/scheduler_worker_pool_impl.h
index 6949e51..3c8788e1 100644
--- a/base/task/task_scheduler/scheduler_worker_pool_impl.h
+++ b/base/task/thread_pool/scheduler_worker_pool_impl.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_
-#define BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_
+#ifndef BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_POOL_IMPL_H_
+#define BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_POOL_IMPL_H_
#include <stddef.h>
@@ -23,12 +23,12 @@
#include "base/synchronization/atomic_flag.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/scheduler_worker.h"
-#include "base/task/task_scheduler/scheduler_worker_pool.h"
-#include "base/task/task_scheduler/scheduler_worker_stack.h"
-#include "base/task/task_scheduler/sequence.h"
-#include "base/task/task_scheduler/task.h"
-#include "base/task/task_scheduler/tracked_ref.h"
+#include "base/task/thread_pool/scheduler_worker.h"
+#include "base/task/thread_pool/scheduler_worker_pool.h"
+#include "base/task/thread_pool/scheduler_worker_stack.h"
+#include "base/task/thread_pool/sequence.h"
+#include "base/task/thread_pool/task.h"
+#include "base/task/thread_pool/tracked_ref.h"
#include "base/task_runner.h"
#include "base/time/time.h"
@@ -52,7 +52,7 @@
public:
// Constructs a pool without workers.
//
- // |histogram_label| is used to label the pool's histograms ("TaskScheduler."
+ // |histogram_label| is used to label the pool's histograms ("ThreadPool."
// + histogram_name + "." + |histogram_label| + extra suffixes), it must not
// be empty. |pool_label| is used to label the pool's threads, it must not be
// empty. |priority_hint| is the preferred thread priority; the actual thread
@@ -138,9 +138,9 @@
// Friend tests so that they can access |blocked_workers_poll_period| and
// may_block_threshold().
- friend class TaskSchedulerWorkerPoolBlockingTest;
- friend class TaskSchedulerWorkerPoolMayBlockTest;
- FRIEND_TEST_ALL_PREFIXES(TaskSchedulerWorkerPoolBlockingTest,
+ friend class ThreadPoolWorkerPoolBlockingTest;
+ friend class ThreadPoolWorkerPoolMayBlockTest;
+ FRIEND_TEST_ALL_PREFIXES(ThreadPoolWorkerPoolBlockingTest,
ThreadBlockUnblockPremature);
// SchedulerWorkerPool:
@@ -325,23 +325,23 @@
AtomicFlag join_for_testing_started_;
#endif
- // TaskScheduler.DetachDuration.[worker pool name] histogram. Intentionally
+ // ThreadPool.DetachDuration.[worker pool name] histogram. Intentionally
// leaked.
HistogramBase* const detach_duration_histogram_;
- // TaskScheduler.NumTasksBeforeDetach.[worker pool name] histogram.
+ // ThreadPool.NumTasksBeforeDetach.[worker pool name] histogram.
// Intentionally leaked.
HistogramBase* const num_tasks_before_detach_histogram_;
- // TaskScheduler.NumTasksBetweenWaits.[worker pool name] histogram.
+ // ThreadPool.NumTasksBetweenWaits.[worker pool name] histogram.
// Intentionally leaked.
HistogramBase* const num_tasks_between_waits_histogram_;
- // TaskScheduler.NumWorkers.[worker pool name] histogram.
+ // ThreadPool.NumWorkers.[worker pool name] histogram.
// Intentionally leaked.
HistogramBase* const num_workers_histogram_;
- // TaskScheduler.NumActiveWorkers.[worker pool name] histogram.
+ // ThreadPool.NumActiveWorkers.[worker pool name] histogram.
// Intentionally leaked.
HistogramBase* const num_active_workers_histogram_;
@@ -360,4 +360,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_
+#endif // BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_POOL_IMPL_H_
diff --git a/base/task/task_scheduler/scheduler_worker_pool_impl_unittest.cc b/base/task/thread_pool/scheduler_worker_pool_impl_unittest.cc
similarity index 87%
rename from base/task/task_scheduler/scheduler_worker_pool_impl_unittest.cc
rename to base/task/thread_pool/scheduler_worker_pool_impl_unittest.cc
index d3afa74..870d028 100644
--- a/base/task/task_scheduler/scheduler_worker_pool_impl_unittest.cc
+++ b/base/task/thread_pool/scheduler_worker_pool_impl_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_worker_pool_impl.h"
+#include "base/task/thread_pool/scheduler_worker_pool_impl.h"
#include <stddef.h>
@@ -28,15 +28,15 @@
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/task_features.h"
-#include "base/task/task_scheduler/delayed_task_manager.h"
-#include "base/task/task_scheduler/scheduler_task_runner_delegate.h"
-#include "base/task/task_scheduler/scheduler_worker_observer.h"
-#include "base/task/task_scheduler/scheduler_worker_pool_params.h"
-#include "base/task/task_scheduler/sequence.h"
-#include "base/task/task_scheduler/sequence_sort_key.h"
-#include "base/task/task_scheduler/task_tracker.h"
-#include "base/task/task_scheduler/test_task_factory.h"
-#include "base/task/task_scheduler/test_utils.h"
+#include "base/task/thread_pool/delayed_task_manager.h"
+#include "base/task/thread_pool/scheduler_task_runner_delegate.h"
+#include "base/task/thread_pool/scheduler_worker_observer.h"
+#include "base/task/thread_pool/scheduler_worker_pool_params.h"
+#include "base/task/thread_pool/sequence.h"
+#include "base/task/thread_pool/sequence_sort_key.h"
+#include "base/task/thread_pool/task_tracker.h"
+#include "base/task/thread_pool/test_task_factory.h"
+#include "base/task/thread_pool/test_utils.h"
#include "base/task_runner.h"
#include "base/test/bind_test_util.h"
#include "base/test/gtest_util.h"
@@ -69,11 +69,10 @@
TimeDelta::FromMilliseconds(500);
constexpr size_t kLargeNumber = 512;
-class TaskSchedulerWorkerPoolImplTestBase
- : public SchedulerWorkerPool::Delegate {
+class ThreadPoolWorkerPoolImplTestBase : public SchedulerWorkerPool::Delegate {
protected:
- TaskSchedulerWorkerPoolImplTestBase()
- : service_thread_("TaskSchedulerServiceThread"),
+ ThreadPoolWorkerPoolImplTestBase()
+ : service_thread_("ThreadPoolServiceThread"),
tracked_ref_factory_(this) {}
void CommonTearDown() {
@@ -135,39 +134,38 @@
return worker_pool_.get();
}
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerWorkerPoolImplTestBase);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolWorkerPoolImplTestBase);
};
-class TaskSchedulerWorkerPoolImplTest
- : public TaskSchedulerWorkerPoolImplTestBase,
- public testing::Test {
+class ThreadPoolWorkerPoolImplTest : public ThreadPoolWorkerPoolImplTestBase,
+ public testing::Test {
protected:
- TaskSchedulerWorkerPoolImplTest() = default;
+ ThreadPoolWorkerPoolImplTest() = default;
void SetUp() override { CreateAndStartWorkerPool(); }
void TearDown() override {
- TaskSchedulerWorkerPoolImplTestBase::CommonTearDown();
+ ThreadPoolWorkerPoolImplTestBase::CommonTearDown();
}
private:
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerWorkerPoolImplTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolWorkerPoolImplTest);
};
-class TaskSchedulerWorkerPoolImplTestParam
- : public TaskSchedulerWorkerPoolImplTestBase,
+class ThreadPoolWorkerPoolImplTestParam
+ : public ThreadPoolWorkerPoolImplTestBase,
public testing::TestWithParam<test::ExecutionMode> {
protected:
- TaskSchedulerWorkerPoolImplTestParam() = default;
+ ThreadPoolWorkerPoolImplTestParam() = default;
void SetUp() override { CreateAndStartWorkerPool(); }
void TearDown() override {
- TaskSchedulerWorkerPoolImplTestBase::CommonTearDown();
+ ThreadPoolWorkerPoolImplTestBase::CommonTearDown();
}
private:
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerWorkerPoolImplTestParam);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolWorkerPoolImplTestParam);
};
using PostNestedTask = test::TestTaskFactory::PostNestedTask;
@@ -211,7 +209,7 @@
} // namespace
-TEST_P(TaskSchedulerWorkerPoolImplTestParam, PostTasksWaitAllWorkersIdle) {
+TEST_P(ThreadPoolWorkerPoolImplTestParam, PostTasksWaitAllWorkersIdle) {
// Create threads to post tasks. To verify that workers can sleep and be woken
// up when new tasks are posted, wait for all workers to become idle before
// posting a new task.
@@ -236,7 +234,7 @@
worker_pool_->WaitForAllWorkersIdleForTesting();
}
-TEST_P(TaskSchedulerWorkerPoolImplTestParam, PostTasksWithOneAvailableWorker) {
+TEST_P(ThreadPoolWorkerPoolImplTestParam, PostTasksWithOneAvailableWorker) {
// Post blocking tasks to keep all workers busy except one until |event| is
// signaled. Use different factories so that tasks are added to different
// sequences and can run simultaneously when the execution mode is SEQUENCED.
@@ -271,7 +269,7 @@
worker_pool_->WaitForAllWorkersIdleForTesting();
}
-TEST_P(TaskSchedulerWorkerPoolImplTestParam, Saturate) {
+TEST_P(ThreadPoolWorkerPoolImplTestParam, Saturate) {
// Verify that it is possible to have |kMaxTasks| tasks/sequences running
// simultaneously. Use different factories so that the blocking tasks are
// added to different sequences and can run simultaneously when the execution
@@ -298,16 +296,16 @@
}
INSTANTIATE_TEST_SUITE_P(Parallel,
- TaskSchedulerWorkerPoolImplTestParam,
+ ThreadPoolWorkerPoolImplTestParam,
::testing::Values(test::ExecutionMode::PARALLEL));
INSTANTIATE_TEST_SUITE_P(Sequenced,
- TaskSchedulerWorkerPoolImplTestParam,
+ ThreadPoolWorkerPoolImplTestParam,
::testing::Values(test::ExecutionMode::SEQUENCED));
namespace {
-class TaskSchedulerWorkerPoolImplStartInBodyTest
- : public TaskSchedulerWorkerPoolImplTest {
+class ThreadPoolWorkerPoolImplStartInBodyTest
+ : public ThreadPoolWorkerPoolImplTest {
public:
void SetUp() override {
CreateWorkerPool();
@@ -327,7 +325,7 @@
// Verify that 2 tasks posted before Start() to a SchedulerWorkerPoolImpl with
// more than 2 workers run on different workers when Start() is called.
-TEST_F(TaskSchedulerWorkerPoolImplStartInBodyTest, PostTasksBeforeStart) {
+TEST_F(ThreadPoolWorkerPoolImplStartInBodyTest, PostTasksBeforeStart) {
PlatformThreadRef task_1_thread_ref;
PlatformThreadRef task_2_thread_ref;
WaitableEvent task_1_running;
@@ -373,7 +371,7 @@
// Verify that posting many tasks before Start will cause the number of workers
// to grow to |max_tasks_| after Start.
-TEST_F(TaskSchedulerWorkerPoolImplStartInBodyTest, PostManyTasks) {
+TEST_F(ThreadPoolWorkerPoolImplStartInBodyTest, PostManyTasks) {
scoped_refptr<TaskRunner> task_runner = test::CreateTaskRunnerWithTraits(
{WithBaseSyncPrimitives()}, &mock_scheduler_task_runner_delegate_);
constexpr size_t kNumTasksPosted = 2 * kMaxTasks;
@@ -414,8 +412,7 @@
constexpr size_t kMagicTlsValue = 42;
-class TaskSchedulerWorkerPoolCheckTlsReuse
- : public TaskSchedulerWorkerPoolImplTest {
+class ThreadPoolWorkerPoolCheckTlsReuse : public ThreadPoolWorkerPoolImplTest {
public:
void SetTlsValueAndWait() {
slot_.Set(reinterpret_cast<void*>(kMagicTlsValue));
@@ -431,7 +428,7 @@
}
protected:
- TaskSchedulerWorkerPoolCheckTlsReuse() = default;
+ ThreadPoolWorkerPoolCheckTlsReuse() = default;
void SetUp() override {
CreateAndStartWorkerPool(kReclaimTimeForCleanupTests, kMaxTasks);
@@ -444,13 +441,13 @@
private:
ThreadLocalStorage::Slot slot_;
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerWorkerPoolCheckTlsReuse);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolWorkerPoolCheckTlsReuse);
};
} // namespace
// Checks that at least one worker has been cleaned up by checking the TLS.
-TEST_F(TaskSchedulerWorkerPoolCheckTlsReuse, CheckCleanupWorkers) {
+TEST_F(ThreadPoolWorkerPoolCheckTlsReuse, CheckCleanupWorkers) {
// Saturate the workers and mark each worker's thread with a magic TLS value.
std::vector<std::unique_ptr<test::TestTaskFactory>> factories;
for (size_t i = 0; i < kMaxTasks; ++i) {
@@ -460,7 +457,7 @@
test::ExecutionMode::PARALLEL));
ASSERT_TRUE(factories.back()->PostTask(
PostNestedTask::NO,
- Bind(&TaskSchedulerWorkerPoolCheckTlsReuse::SetTlsValueAndWait,
+ Bind(&ThreadPoolWorkerPoolCheckTlsReuse::SetTlsValueAndWait,
Unretained(this))));
factories.back()->WaitForAllTasksToRun();
}
@@ -482,7 +479,7 @@
count_waiters.push_back(std::make_unique<WaitableEvent>());
ASSERT_TRUE(factory->PostTask(
PostNestedTask::NO,
- Bind(&TaskSchedulerWorkerPoolCheckTlsReuse::CountZeroTlsValuesAndWait,
+ Bind(&ThreadPoolWorkerPoolCheckTlsReuse::CountZeroTlsValuesAndWait,
Unretained(this), count_waiters.back().get())));
factory->WaitForAllTasksToRun();
}
@@ -499,10 +496,9 @@
namespace {
-class TaskSchedulerWorkerPoolHistogramTest
- : public TaskSchedulerWorkerPoolImplTest {
+class ThreadPoolWorkerPoolHistogramTest : public ThreadPoolWorkerPoolImplTest {
public:
- TaskSchedulerWorkerPoolHistogramTest() = default;
+ ThreadPoolWorkerPoolHistogramTest() = default;
protected:
// Override SetUp() to allow every test case to initialize a worker pool with
@@ -513,7 +509,7 @@
// |continue_event| is signaled. Every worker in the pool is blocked on
// |continue_event| when this method returns. Note: this helper can easily be
// generalized to be useful in other tests, but it's here for now because it's
- // only used in a TaskSchedulerWorkerPoolHistogramTest at the moment.
+ // only used in a ThreadPoolWorkerPoolHistogramTest at the moment.
void FloodPool(WaitableEvent* continue_event) {
ASSERT_FALSE(continue_event->IsSignaled());
@@ -543,12 +539,12 @@
std::unique_ptr<StatisticsRecorder> statistics_recorder_ =
StatisticsRecorder::CreateTemporaryForTesting();
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerWorkerPoolHistogramTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolWorkerPoolHistogramTest);
};
} // namespace
-TEST_F(TaskSchedulerWorkerPoolHistogramTest, NumTasksBetweenWaits) {
+TEST_F(ThreadPoolWorkerPoolHistogramTest, NumTasksBetweenWaits) {
WaitableEvent event;
CreateAndStartWorkerPool(TimeDelta::Max(), kMaxTasks);
auto task_runner = test::CreateSequencedTaskRunnerWithTraits(
@@ -570,7 +566,7 @@
// Wake up the SchedulerWorker that just became idle by posting a task and
// wait until it becomes idle again. The SchedulerWorker should record the
- // TaskScheduler.NumTasksBetweenWaits.* histogram on wake up.
+ // ThreadPool.NumTasksBetweenWaits.* histogram on wake up.
task_runner->PostTask(FROM_HERE, DoNothing());
worker_pool_->WaitForAllWorkersIdleForTesting();
@@ -583,7 +579,7 @@
// Verifies that NumTasksBetweenWaits histogram is logged as expected across
// idle and cleanup periods.
-TEST_F(TaskSchedulerWorkerPoolHistogramTest,
+TEST_F(ThreadPoolWorkerPoolHistogramTest,
NumTasksBetweenWaitsWithIdlePeriodAndCleanup) {
WaitableEvent tasks_can_exit_event;
CreateAndStartWorkerPool(kReclaimTimeForCleanupTests, kMaxTasks);
@@ -633,7 +629,7 @@
worker_pool_->WaitForAllWorkersIdleForTesting();
}
-TEST_F(TaskSchedulerWorkerPoolHistogramTest, NumTasksBeforeCleanup) {
+TEST_F(ThreadPoolWorkerPoolHistogramTest, NumTasksBeforeCleanup) {
CreateWorkerPool();
auto histogrammed_thread_task_runner =
test::CreateSequencedTaskRunnerWithTraits(
@@ -705,20 +701,20 @@
auto task_runner_for_top_idle = test::CreateSequencedTaskRunnerWithTraits(
{WithBaseSyncPrimitives()}, &mock_scheduler_task_runner_delegate_);
task_runner_for_top_idle->PostTask(
- FROM_HERE, BindOnce(
- [](PlatformThreadRef thread_ref,
- WaitableEvent* top_idle_thread_running,
- WaitableEvent* top_idle_thread_continue) {
- ASSERT_FALSE(thread_ref.is_null());
- EXPECT_NE(thread_ref, PlatformThread::CurrentRef())
- << "Worker reused. Worker will not cleanup and the "
- "histogram value will be wrong.";
- top_idle_thread_running->Signal();
- test::WaitWithoutBlockingObserver(
- top_idle_thread_continue);
- },
- thread_ref, Unretained(&top_idle_thread_running),
- Unretained(&top_idle_thread_continue)));
+ FROM_HERE,
+ BindOnce(
+ [](PlatformThreadRef thread_ref,
+ WaitableEvent* top_idle_thread_running,
+ WaitableEvent* top_idle_thread_continue) {
+ ASSERT_FALSE(thread_ref.is_null());
+ EXPECT_NE(thread_ref, PlatformThread::CurrentRef())
+ << "Worker reused. Worker will not cleanup and the "
+ "histogram value will be wrong.";
+ top_idle_thread_running->Signal();
+ test::WaitWithoutBlockingObserver(top_idle_thread_continue);
+ },
+ thread_ref, Unretained(&top_idle_thread_running),
+ Unretained(&top_idle_thread_continue)));
top_idle_thread_running.Wait();
EXPECT_EQ(0U, worker_pool_->NumberOfIdleWorkersForTesting());
cleanup_thread_continue.Signal();
@@ -743,33 +739,33 @@
namespace {
-class TaskSchedulerWorkerPoolStandbyPolicyTest
- : public TaskSchedulerWorkerPoolImplTestBase,
+class ThreadPoolWorkerPoolStandbyPolicyTest
+ : public ThreadPoolWorkerPoolImplTestBase,
public testing::Test {
public:
- TaskSchedulerWorkerPoolStandbyPolicyTest() = default;
+ ThreadPoolWorkerPoolStandbyPolicyTest() = default;
void SetUp() override {
CreateAndStartWorkerPool(kReclaimTimeForCleanupTests);
}
void TearDown() override {
- TaskSchedulerWorkerPoolImplTestBase::CommonTearDown();
+ ThreadPoolWorkerPoolImplTestBase::CommonTearDown();
}
private:
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerWorkerPoolStandbyPolicyTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolWorkerPoolStandbyPolicyTest);
};
} // namespace
-TEST_F(TaskSchedulerWorkerPoolStandbyPolicyTest, InitOne) {
+TEST_F(ThreadPoolWorkerPoolStandbyPolicyTest, InitOne) {
EXPECT_EQ(1U, worker_pool_->NumberOfWorkersForTesting());
}
// Verify that the SchedulerWorkerPoolImpl keeps at least one idle standby
// thread, capacity permitting.
-TEST_F(TaskSchedulerWorkerPoolStandbyPolicyTest, VerifyStandbyThread) {
+TEST_F(ThreadPoolWorkerPoolStandbyPolicyTest, VerifyStandbyThread) {
auto task_runner = test::CreateTaskRunnerWithTraits(
{WithBaseSyncPrimitives()}, &mock_scheduler_task_runner_delegate_);
@@ -804,8 +800,7 @@
// Verify that being "the" idle thread counts as being active (i.e. won't be
// reclaimed even if not on top of the idle stack when reclaim timeout expires).
// Regression test for https://crbug.com/847501.
-TEST_F(TaskSchedulerWorkerPoolStandbyPolicyTest,
- InAndOutStandbyThreadIsActive) {
+TEST_F(ThreadPoolWorkerPoolStandbyPolicyTest, InAndOutStandbyThreadIsActive) {
auto sequenced_task_runner = test::CreateSequencedTaskRunnerWithTraits(
{}, &mock_scheduler_task_runner_delegate_);
@@ -841,12 +836,12 @@
// Verify that being "the" idle thread counts as being active but isn't sticky.
// Regression test for https://crbug.com/847501.
-TEST_F(TaskSchedulerWorkerPoolStandbyPolicyTest, OnlyKeepActiveStandbyThreads) {
+TEST_F(ThreadPoolWorkerPoolStandbyPolicyTest, OnlyKeepActiveStandbyThreads) {
auto sequenced_task_runner = test::CreateSequencedTaskRunnerWithTraits(
{}, &mock_scheduler_task_runner_delegate_);
// Start this test like
- // TaskSchedulerWorkerPoolStandbyPolicyTest.InAndOutStandbyThreadIsActive and
+ // ThreadPoolWorkerPoolStandbyPolicyTest.InAndOutStandbyThreadIsActive and
// give it some time to stabilize.
RepeatingTimer recurring_task;
sequenced_task_runner->PostTask(
@@ -942,11 +937,11 @@
} // namespace
-class TaskSchedulerWorkerPoolBlockingTest
- : public TaskSchedulerWorkerPoolImplTestBase,
+class ThreadPoolWorkerPoolBlockingTest
+ : public ThreadPoolWorkerPoolImplTestBase,
public testing::TestWithParam<NestedBlockingType> {
public:
- TaskSchedulerWorkerPoolBlockingTest() = default;
+ ThreadPoolWorkerPoolBlockingTest() = default;
static std::string ParamInfoToString(
::testing::TestParamInfo<NestedBlockingType> param_info) {
@@ -961,7 +956,7 @@
}
void TearDown() override {
- TaskSchedulerWorkerPoolImplTestBase::CommonTearDown();
+ ThreadPoolWorkerPoolImplTestBase::CommonTearDown();
}
protected:
@@ -1041,13 +1036,13 @@
WaitableEvent blocking_threads_continue_;
WaitableEvent busy_threads_continue_;
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerWorkerPoolBlockingTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolWorkerPoolBlockingTest);
};
// Verify that BlockingScopeEntered() causes max tasks to increase and creates a
// worker if needed. Also verify that BlockingScopeExited() decreases max tasks
// after an increase.
-TEST_P(TaskSchedulerWorkerPoolBlockingTest, ThreadBlockedUnblocked) {
+TEST_P(ThreadPoolWorkerPoolBlockingTest, ThreadBlockedUnblocked) {
CreateAndStartWorkerPool();
ASSERT_EQ(worker_pool_->GetMaxTasksForTesting(), kMaxTasks);
@@ -1068,7 +1063,7 @@
// Verify that tasks posted in a saturated pool before a ScopedBlockingCall will
// execute after ScopedBlockingCall is instantiated.
-TEST_P(TaskSchedulerWorkerPoolBlockingTest, PostBeforeBlocking) {
+TEST_P(ThreadPoolWorkerPoolBlockingTest, PostBeforeBlocking) {
CreateAndStartWorkerPool();
WaitableEvent thread_running(WaitableEvent::ResetPolicy::AUTOMATIC);
@@ -1106,15 +1101,15 @@
BindOnce(&WaitableEvent::Signal, Unretained(&extra_threads_running)));
for (size_t i = 0; i < kMaxTasks; ++i) {
task_runner_->PostTask(
- FROM_HERE, BindOnce(
- [](Closure* extra_threads_running_barrier,
- WaitableEvent* extra_threads_continue) {
- extra_threads_running_barrier->Run();
- test::WaitWithoutBlockingObserver(
- extra_threads_continue);
- },
- Unretained(&extra_threads_running_barrier),
- Unretained(&extra_threads_continue)));
+ FROM_HERE,
+ BindOnce(
+ [](Closure* extra_threads_running_barrier,
+ WaitableEvent* extra_threads_continue) {
+ extra_threads_running_barrier->Run();
+ test::WaitWithoutBlockingObserver(extra_threads_continue);
+ },
+ Unretained(&extra_threads_running_barrier),
+ Unretained(&extra_threads_continue)));
}
// Allow tasks to enter ScopedBlockingCall. Workers should be created for the
@@ -1132,7 +1127,7 @@
// Verify that workers become idle when the pool is over-capacity and that
// those workers do no work.
-TEST_P(TaskSchedulerWorkerPoolBlockingTest, WorkersIdleWhenOverCapacity) {
+TEST_P(ThreadPoolWorkerPoolBlockingTest, WorkersIdleWhenOverCapacity) {
CreateAndStartWorkerPool();
ASSERT_EQ(worker_pool_->GetMaxTasksForTesting(), kMaxTasks);
@@ -1185,7 +1180,7 @@
INSTANTIATE_TEST_SUITE_P(
,
- TaskSchedulerWorkerPoolBlockingTest,
+ ThreadPoolWorkerPoolBlockingTest,
::testing::Values(NestedBlockingType(BlockingType::MAY_BLOCK,
OptionalBlockingType::NO_BLOCK,
BlockingType::MAY_BLOCK),
@@ -1198,12 +1193,12 @@
NestedBlockingType(BlockingType::WILL_BLOCK,
OptionalBlockingType::MAY_BLOCK,
BlockingType::WILL_BLOCK)),
- TaskSchedulerWorkerPoolBlockingTest::ParamInfoToString);
+ ThreadPoolWorkerPoolBlockingTest::ParamInfoToString);
// Verify that if a thread enters the scope of a MAY_BLOCK ScopedBlockingCall,
// but exits the scope before the MayBlock threshold is reached, that the max
// tasks does not increase.
-TEST_F(TaskSchedulerWorkerPoolBlockingTest, ThreadBlockUnblockPremature) {
+TEST_F(ThreadPoolWorkerPoolBlockingTest, ThreadBlockUnblockPremature) {
// Create a pool with an infinite MayBlock threshold so that a MAY_BLOCK
// ScopedBlockingCall never increases the max tasks.
CreateAndStartWorkerPool(TimeDelta::Max(), // |suggested_reclaim_time|
@@ -1230,7 +1225,7 @@
// Verify that if max tasks is incremented because of a MAY_BLOCK
// ScopedBlockingCall, it isn't incremented again when there is a nested
// WILL_BLOCK ScopedBlockingCall.
-TEST_F(TaskSchedulerWorkerPoolBlockingTest,
+TEST_F(ThreadPoolWorkerPoolBlockingTest,
MayBlockIncreaseCapacityNestedWillBlock) {
CreateAndStartWorkerPool();
@@ -1283,11 +1278,11 @@
EXPECT_EQ(worker_pool_->GetMaxTasksForTesting(), kMaxTasks);
}
-class TaskSchedulerWorkerPoolOverCapacityTest
- : public TaskSchedulerWorkerPoolImplTestBase,
+class ThreadPoolWorkerPoolOverCapacityTest
+ : public ThreadPoolWorkerPoolImplTestBase,
public testing::Test {
public:
- TaskSchedulerWorkerPoolOverCapacityTest() = default;
+ ThreadPoolWorkerPoolOverCapacityTest() = default;
void SetUp() override {
CreateAndStartWorkerPool(kReclaimTimeForCleanupTests, kLocalMaxTasks);
@@ -1297,7 +1292,7 @@
}
void TearDown() override {
- TaskSchedulerWorkerPoolImplTestBase::CommonTearDown();
+ ThreadPoolWorkerPoolImplTestBase::CommonTearDown();
}
protected:
@@ -1314,12 +1309,12 @@
ASSERT_TRUE(worker_pool_);
}
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerWorkerPoolOverCapacityTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolWorkerPoolOverCapacityTest);
};
// Verify that workers that become idle due to the pool being over capacity will
// eventually cleanup.
-TEST_F(TaskSchedulerWorkerPoolOverCapacityTest, VerifyCleanup) {
+TEST_F(ThreadPoolWorkerPoolOverCapacityTest, VerifyCleanup) {
WaitableEvent threads_running;
WaitableEvent threads_continue;
RepeatingClosure threads_running_barrier = BarrierClosure(
@@ -1355,15 +1350,15 @@
// These tasks should run on the new threads from increasing max tasks.
for (size_t i = 0; i < kLocalMaxTasks; ++i) {
task_runner_->PostTask(
- FROM_HERE, BindOnce(
- [](Closure* extra_threads_running_barrier,
- WaitableEvent* extra_threads_continue) {
- extra_threads_running_barrier->Run();
- test::WaitWithoutBlockingObserver(
- extra_threads_continue);
- },
- Unretained(&extra_threads_running_barrier),
- Unretained(&extra_threads_continue)));
+ FROM_HERE,
+ BindOnce(
+ [](Closure* extra_threads_running_barrier,
+ WaitableEvent* extra_threads_continue) {
+ extra_threads_running_barrier->Run();
+ test::WaitWithoutBlockingObserver(extra_threads_continue);
+ },
+ Unretained(&extra_threads_running_barrier),
+ Unretained(&extra_threads_continue)));
}
extra_threads_running.Wait();
@@ -1390,7 +1385,7 @@
// Verify that the maximum number of workers is 256 and that hitting the max
// leaves the pool in a valid state with regards to max tasks.
-TEST_F(TaskSchedulerWorkerPoolBlockingTest, MaximumWorkersTest) {
+TEST_F(ThreadPoolWorkerPoolBlockingTest, MaximumWorkersTest) {
CreateAndStartWorkerPool();
constexpr size_t kMaxNumberOfWorkers = 256;
@@ -1411,24 +1406,23 @@
// Post ScopedBlockingCall tasks to hit the worker cap.
for (size_t i = 0; i < kMaxNumberOfWorkers; ++i) {
- task_runner_->PostTask(
- FROM_HERE,
- BindOnce(
- [](Closure* early_threads_barrier_closure,
- WaitableEvent* early_release_threads_continue,
- Closure* early_threads_finished) {
- {
- ScopedBlockingCall scoped_blocking_call(
- FROM_HERE, BlockingType::WILL_BLOCK);
- early_threads_barrier_closure->Run();
- test::WaitWithoutBlockingObserver(
- early_release_threads_continue);
- }
- early_threads_finished->Run();
- },
- Unretained(&early_threads_barrier_closure),
- Unretained(&early_release_threads_continue),
- Unretained(&early_threads_finished_barrier)));
+ task_runner_->PostTask(FROM_HERE,
+ BindOnce(
+ [](Closure* early_threads_barrier_closure,
+ WaitableEvent* early_release_threads_continue,
+ Closure* early_threads_finished) {
+ {
+ ScopedBlockingCall scoped_blocking_call(
+ FROM_HERE, BlockingType::WILL_BLOCK);
+ early_threads_barrier_closure->Run();
+ test::WaitWithoutBlockingObserver(
+ early_release_threads_continue);
+ }
+ early_threads_finished->Run();
+ },
+ Unretained(&early_threads_barrier_closure),
+ Unretained(&early_release_threads_continue),
+ Unretained(&early_threads_finished_barrier)));
}
early_blocking_threads_running.Wait();
@@ -1495,7 +1489,7 @@
// Verify that the maximum number of best-effort tasks that can run concurrently
// is honored.
-TEST_F(TaskSchedulerWorkerPoolImplStartInBodyTest, MaxBestEffortTasks) {
+TEST_F(ThreadPoolWorkerPoolImplStartInBodyTest, MaxBestEffortTasks) {
constexpr int kMaxBestEffortTasks = kMaxTasks / 2;
StartWorkerPool(TimeDelta::Max(), // |suggested_reclaim_time|
kMaxTasks, // |max_tasks|
@@ -1552,7 +1546,7 @@
// Verify that flooding the pool with BEST_EFFORT tasks doesn't cause the
// creation of more than |max_best_effort_tasks| + 1 workers.
-TEST_F(TaskSchedulerWorkerPoolImplStartInBodyTest,
+TEST_F(ThreadPoolWorkerPoolImplStartInBodyTest,
FloodBestEffortTasksDoesNotCreateTooManyWorkers) {
constexpr size_t kMaxBestEffortTasks = kMaxTasks / 2;
StartWorkerPool(TimeDelta::Max(), // |suggested_reclaim_time|
@@ -1616,7 +1610,7 @@
// 4. Task A enters a second WILL_BLOCK ScopedBlockingCall. This should no-op
// because there are already enough workers.
// 5. Unblock HoldWorkersObserver and wait for all tasks to complete.
-TEST_F(TaskSchedulerWorkerPoolImplStartInBodyTest,
+TEST_F(ThreadPoolWorkerPoolImplStartInBodyTest,
RepeatedWillBlockDoesNotCreateTooManyWorkers) {
constexpr size_t kNumWorkers = 2U;
HoldWorkersObserver worker_observer;
@@ -1628,19 +1622,20 @@
{MayBlock()}, &mock_scheduler_task_runner_delegate_);
WaitableEvent hold_will_block_task;
- runner->PostTask(
- FROM_HERE, BindLambdaForTesting([&]() {
- test::WaitWithoutBlockingObserver(&hold_will_block_task);
- for (size_t i = 0; i < kLargeNumber; ++i) {
- // Number of workers should not increase when there is enough capacity
- // to accommodate queued and running sequences.
- ScopedBlockingCall scoped_blocking_call(FROM_HERE,
- BlockingType::WILL_BLOCK);
- EXPECT_LE(kNumWorkers + 1, worker_pool_->NumberOfWorkersForTesting());
- }
+ runner->PostTask(FROM_HERE, BindLambdaForTesting([&]() {
+ test::WaitWithoutBlockingObserver(&hold_will_block_task);
+ for (size_t i = 0; i < kLargeNumber; ++i) {
+ // Number of workers should not increase when there is
+ // enough capacity to accommodate queued and running
+ // sequences.
+ ScopedBlockingCall scoped_blocking_call(
+ FROM_HERE, BlockingType::WILL_BLOCK);
+ EXPECT_LE(kNumWorkers + 1,
+ worker_pool_->NumberOfWorkersForTesting());
+ }
- worker_observer.UnblockWorkers();
- }));
+ worker_observer.UnblockWorkers();
+ }));
runner->PostTask(FROM_HERE, BindLambdaForTesting([&]() {
EXPECT_LE(worker_pool_->NumberOfWorkersForTesting(),
@@ -1656,13 +1651,13 @@
namespace {
-class TaskSchedulerWorkerPoolBlockingCallAndMaxBestEffortTasksTest
- : public TaskSchedulerWorkerPoolImplTestBase,
+class ThreadPoolWorkerPoolBlockingCallAndMaxBestEffortTasksTest
+ : public ThreadPoolWorkerPoolImplTestBase,
public testing::TestWithParam<BlockingType> {
public:
static constexpr int kMaxBestEffortTasks = kMaxTasks / 2;
- TaskSchedulerWorkerPoolBlockingCallAndMaxBestEffortTasksTest() = default;
+ ThreadPoolWorkerPoolBlockingCallAndMaxBestEffortTasksTest() = default;
void SetUp() override {
CreateWorkerPool();
@@ -1673,17 +1668,17 @@
}
void TearDown() override {
- TaskSchedulerWorkerPoolImplTestBase::CommonTearDown();
+ ThreadPoolWorkerPoolImplTestBase::CommonTearDown();
}
private:
DISALLOW_COPY_AND_ASSIGN(
- TaskSchedulerWorkerPoolBlockingCallAndMaxBestEffortTasksTest);
+ ThreadPoolWorkerPoolBlockingCallAndMaxBestEffortTasksTest);
};
} // namespace
-TEST_P(TaskSchedulerWorkerPoolBlockingCallAndMaxBestEffortTasksTest,
+TEST_P(ThreadPoolWorkerPoolBlockingCallAndMaxBestEffortTasksTest,
BlockingCallAndMaxBestEffortTasksTest) {
const scoped_refptr<TaskRunner> background_runner =
test::CreateTaskRunnerWithTraits({TaskPriority::BEST_EFFORT, MayBlock()},
@@ -1736,16 +1731,16 @@
INSTANTIATE_TEST_SUITE_P(
MayBlock,
- TaskSchedulerWorkerPoolBlockingCallAndMaxBestEffortTasksTest,
+ ThreadPoolWorkerPoolBlockingCallAndMaxBestEffortTasksTest,
::testing::Values(BlockingType::MAY_BLOCK));
INSTANTIATE_TEST_SUITE_P(
WillBlock,
- TaskSchedulerWorkerPoolBlockingCallAndMaxBestEffortTasksTest,
+ ThreadPoolWorkerPoolBlockingCallAndMaxBestEffortTasksTest,
::testing::Values(BlockingType::WILL_BLOCK));
// Verify that worker detachment doesn't race with worker cleanup, regression
// test for https://crbug.com/810464.
-TEST_F(TaskSchedulerWorkerPoolImplStartInBodyTest, RacyCleanup) {
+TEST_F(ThreadPoolWorkerPoolImplStartInBodyTest, RacyCleanup) {
#if defined(OS_FUCHSIA)
// Fuchsia + QEMU doesn't deal well with *many* threads being
// created/destroyed at once: https://crbug.com/816575.
@@ -1796,14 +1791,13 @@
worker_pool_.reset();
}
-TEST_P(TaskSchedulerWorkerPoolImplTestParam, ReportHeartbeatMetrics) {
+TEST_P(ThreadPoolWorkerPoolImplTestParam, ReportHeartbeatMetrics) {
HistogramTester tester;
worker_pool_->ReportHeartbeatMetrics();
EXPECT_FALSE(
- tester.GetAllSamples("TaskScheduler.NumWorkers.TestWorkerPoolPool")
- .empty());
+ tester.GetAllSamples("ThreadPool.NumWorkers.TestWorkerPool").empty());
EXPECT_FALSE(
- tester.GetAllSamples("TaskScheduler.NumActiveWorkers.TestWorkerPoolPool")
+ tester.GetAllSamples("ThreadPool.NumActiveWorkers.TestWorkerPool")
.empty());
}
diff --git a/base/task/task_scheduler/scheduler_worker_pool_params.cc b/base/task/thread_pool/scheduler_worker_pool_params.cc
similarity index 91%
rename from base/task/task_scheduler/scheduler_worker_pool_params.cc
rename to base/task/thread_pool/scheduler_worker_pool_params.cc
index e787c3e..fbe2b05 100644
--- a/base/task/task_scheduler/scheduler_worker_pool_params.cc
+++ b/base/task/thread_pool/scheduler_worker_pool_params.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_worker_pool_params.h"
+#include "base/task/thread_pool/scheduler_worker_pool_params.h"
namespace base {
diff --git a/base/task/task_scheduler/scheduler_worker_pool_params.h b/base/task/thread_pool/scheduler_worker_pool_params.h
similarity index 84%
rename from base/task/task_scheduler/scheduler_worker_pool_params.h
rename to base/task/thread_pool/scheduler_worker_pool_params.h
index 84e2e42..64d6f9e8 100644
--- a/base/task/task_scheduler/scheduler_worker_pool_params.h
+++ b/base/task/thread_pool/scheduler_worker_pool_params.h
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_
-#define BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_
+#ifndef BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_POOL_PARAMS_H_
+#define BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_POOL_PARAMS_H_
-#include "base/task/task_scheduler/scheduler_worker_params.h"
+#include "base/task/thread_pool/scheduler_worker_params.h"
#include "base/time/time.h"
namespace base {
@@ -41,4 +41,4 @@
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_
+#endif // BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_POOL_PARAMS_H_
diff --git a/base/task/task_scheduler/scheduler_worker_pool_unittest.cc b/base/task/thread_pool/scheduler_worker_pool_unittest.cc
similarity index 90%
rename from base/task/task_scheduler/scheduler_worker_pool_unittest.cc
rename to base/task/thread_pool/scheduler_worker_pool_unittest.cc
index c3b236c..22ad909 100644
--- a/base/task/task_scheduler/scheduler_worker_pool_unittest.cc
+++ b/base/task/thread_pool/scheduler_worker_pool_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_worker_pool.h"
+#include "base/task/thread_pool/scheduler_worker_pool.h"
#include <memory>
@@ -11,14 +11,14 @@
#include "base/bind_helpers.h"
#include "base/location.h"
#include "base/memory/ref_counted.h"
-#include "base/task/task_scheduler/delayed_task_manager.h"
-#include "base/task/task_scheduler/scheduler_sequenced_task_runner.h"
-#include "base/task/task_scheduler/scheduler_worker_pool_impl.h"
-#include "base/task/task_scheduler/scheduler_worker_pool_params.h"
-#include "base/task/task_scheduler/task_tracker.h"
-#include "base/task/task_scheduler/test_task_factory.h"
-#include "base/task/task_scheduler/test_utils.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/delayed_task_manager.h"
+#include "base/task/thread_pool/scheduler_sequenced_task_runner.h"
+#include "base/task/thread_pool/scheduler_worker_pool_impl.h"
+#include "base/task/thread_pool/scheduler_worker_pool_params.h"
+#include "base/task/thread_pool/task_tracker.h"
+#include "base/task/thread_pool/test_task_factory.h"
+#include "base/task/thread_pool/test_utils.h"
#include "base/task_runner.h"
#include "base/test/bind_test_util.h"
#include "base/test/test_timeouts.h"
@@ -31,10 +31,10 @@
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_WIN)
-#include "base/task/task_scheduler/platform_native_worker_pool_win.h"
+#include "base/task/thread_pool/platform_native_worker_pool_win.h"
#include "base/win/com_init_util.h"
#elif defined(OS_MACOSX)
-#include "base/task/task_scheduler/platform_native_worker_pool_mac.h"
+#include "base/task/thread_pool/platform_native_worker_pool_mac.h"
#endif
namespace base {
@@ -98,12 +98,12 @@
DISALLOW_COPY_AND_ASSIGN(ThreadPostingTasks);
};
-class TaskSchedulerWorkerPoolTest
+class ThreadPoolWorkerPoolTest
: public testing::TestWithParam<PoolExecutionType>,
public SchedulerWorkerPool::Delegate {
protected:
- TaskSchedulerWorkerPoolTest()
- : service_thread_("TaskSchedulerServiceThread"),
+ ThreadPoolWorkerPoolTest()
+ : service_thread_("ThreadPoolServiceThread"),
tracked_ref_factory_(this) {}
void SetUp() override {
@@ -183,7 +183,7 @@
TrackedRefFactory<SchedulerWorkerPool::Delegate> tracked_ref_factory_;
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerWorkerPoolTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolWorkerPoolTest);
};
void ShouldNotRun() {
@@ -192,7 +192,7 @@
} // namespace
-TEST_P(TaskSchedulerWorkerPoolTest, PostTasks) {
+TEST_P(ThreadPoolWorkerPoolTest, PostTasks) {
StartWorkerPool();
// Create threads to post tasks.
std::vector<std::unique_ptr<ThreadPostingTasks>> threads_posting_tasks;
@@ -214,7 +214,7 @@
task_tracker_.FlushForTesting();
}
-TEST_P(TaskSchedulerWorkerPoolTest, NestedPostTasks) {
+TEST_P(ThreadPoolWorkerPoolTest, NestedPostTasks) {
StartWorkerPool();
// Create threads to post tasks. Each task posted by these threads will post
// another task when it runs.
@@ -238,7 +238,7 @@
}
// Verify that a Task can't be posted after shutdown.
-TEST_P(TaskSchedulerWorkerPoolTest, PostTaskAfterShutdown) {
+TEST_P(ThreadPoolWorkerPoolTest, PostTaskAfterShutdown) {
StartWorkerPool();
auto task_runner = test::CreateTaskRunnerWithExecutionMode(
GetParam().execution_mode, &mock_scheduler_task_runner_delegate_);
@@ -248,7 +248,7 @@
// Verify that posting tasks after the pool was destroyed fails but doesn't
// crash.
-TEST_P(TaskSchedulerWorkerPoolTest, PostAfterDestroy) {
+TEST_P(ThreadPoolWorkerPoolTest, PostAfterDestroy) {
StartWorkerPool();
auto task_runner = test::CreateTaskRunnerWithExecutionMode(
GetParam().execution_mode, &mock_scheduler_task_runner_delegate_);
@@ -260,7 +260,7 @@
}
// Verify that a Task runs shortly after its delay expires.
-TEST_P(TaskSchedulerWorkerPoolTest, PostDelayedTask) {
+TEST_P(ThreadPoolWorkerPoolTest, PostDelayedTask) {
StartWorkerPool();
WaitableEvent task_ran(WaitableEvent::ResetPolicy::AUTOMATIC,
@@ -298,7 +298,7 @@
// Tests that use TestTaskFactory already verify that
// RunsTasksInCurrentSequence() returns true when appropriate so this method
// complements it to get full coverage of that method.
-TEST_P(TaskSchedulerWorkerPoolTest, SequencedRunsTasksInCurrentSequence) {
+TEST_P(ThreadPoolWorkerPoolTest, SequencedRunsTasksInCurrentSequence) {
StartWorkerPool();
auto task_runner = test::CreateTaskRunnerWithExecutionMode(
GetParam().execution_mode, &mock_scheduler_task_runner_delegate_);
@@ -319,7 +319,7 @@
}
// Verify that tasks posted before Start run after Start.
-TEST_P(TaskSchedulerWorkerPoolTest, PostBeforeStart) {
+TEST_P(ThreadPoolWorkerPoolTest, PostBeforeStart) {
WaitableEvent task_1_running;
WaitableEvent task_2_running;
@@ -349,7 +349,7 @@
// Verify that the maximum number of BEST_EFFORT tasks that can run concurrently
// in a pool does not affect Sequences with a priority that was increased from
// BEST_EFFORT to USER_BLOCKING.
-TEST_P(TaskSchedulerWorkerPoolTest, UpdatePriorityBestEffortToUserBlocking) {
+TEST_P(ThreadPoolWorkerPoolTest, UpdatePriorityBestEffortToUserBlocking) {
StartWorkerPool();
SchedulerLock num_tasks_running_lock;
@@ -408,7 +408,7 @@
}
#if defined(OS_WIN)
-TEST_P(TaskSchedulerWorkerPoolTest, COMMTAWorkerEnvironment) {
+TEST_P(ThreadPoolWorkerPoolTest, COMMTAWorkerEnvironment) {
StartWorkerPool(SchedulerWorkerPool::WorkerEnvironment::COM_MTA);
auto task_runner = test::CreateTaskRunnerWithExecutionMode(
GetParam().execution_mode, &mock_scheduler_task_runner_delegate_);
@@ -424,7 +424,7 @@
task_ran.Wait();
}
-TEST_P(TaskSchedulerWorkerPoolTest, NoWorkerEnvironment) {
+TEST_P(ThreadPoolWorkerPoolTest, NoWorkerEnvironment) {
StartWorkerPool(SchedulerWorkerPool::WorkerEnvironment::NONE);
auto task_runner = test::CreateTaskRunnerWithExecutionMode(
GetParam().execution_mode, &mock_scheduler_task_runner_delegate_);
@@ -442,24 +442,24 @@
#endif
INSTANTIATE_TEST_SUITE_P(GenericParallel,
- TaskSchedulerWorkerPoolTest,
+ ThreadPoolWorkerPoolTest,
::testing::Values(PoolExecutionType{
test::PoolType::GENERIC,
test::ExecutionMode::PARALLEL}));
INSTANTIATE_TEST_SUITE_P(GenericSequenced,
- TaskSchedulerWorkerPoolTest,
+ ThreadPoolWorkerPoolTest,
::testing::Values(PoolExecutionType{
test::PoolType::GENERIC,
test::ExecutionMode::SEQUENCED}));
#if defined(OS_WIN) || defined(OS_MACOSX)
INSTANTIATE_TEST_SUITE_P(NativeParallel,
- TaskSchedulerWorkerPoolTest,
+ ThreadPoolWorkerPoolTest,
::testing::Values(PoolExecutionType{
test::PoolType::NATIVE,
test::ExecutionMode::PARALLEL}));
INSTANTIATE_TEST_SUITE_P(NativeSequenced,
- TaskSchedulerWorkerPoolTest,
+ ThreadPoolWorkerPoolTest,
::testing::Values(PoolExecutionType{
test::PoolType::NATIVE,
test::ExecutionMode::SEQUENCED}));
diff --git a/base/task/task_scheduler/scheduler_worker_stack.cc b/base/task/thread_pool/scheduler_worker_stack.cc
similarity index 92%
rename from base/task/task_scheduler/scheduler_worker_stack.cc
rename to base/task/thread_pool/scheduler_worker_stack.cc
index 87efd8d46..00cec88 100644
--- a/base/task/task_scheduler/scheduler_worker_stack.cc
+++ b/base/task/thread_pool/scheduler_worker_stack.cc
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_worker_stack.h"
+#include "base/task/thread_pool/scheduler_worker_stack.h"
#include <algorithm>
#include "base/logging.h"
#include "base/stl_util.h"
-#include "base/task/task_scheduler/scheduler_worker.h"
+#include "base/task/thread_pool/scheduler_worker.h"
namespace base {
namespace internal {
diff --git a/base/task/task_scheduler/scheduler_worker_stack.h b/base/task/thread_pool/scheduler_worker_stack.h
similarity index 91%
rename from base/task/task_scheduler/scheduler_worker_stack.h
rename to base/task/thread_pool/scheduler_worker_stack.h
index 944071ce..e3ab767 100644
--- a/base/task/task_scheduler/scheduler_worker_stack.h
+++ b/base/task/thread_pool/scheduler_worker_stack.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_STACK_H_
-#define BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_STACK_H_
+#ifndef BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_STACK_H_
+#define BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_STACK_H_
#include <stddef.h>
@@ -64,4 +64,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SCHEDULER_WORKER_STACK_H_
+#endif // BASE_TASK_THREAD_POOL_SCHEDULER_WORKER_STACK_H_
diff --git a/base/task/task_scheduler/scheduler_worker_stack_unittest.cc b/base/task/thread_pool/scheduler_worker_stack_unittest.cc
similarity index 91%
rename from base/task/task_scheduler/scheduler_worker_stack_unittest.cc
rename to base/task/thread_pool/scheduler_worker_stack_unittest.cc
index f78243b..d3aab55 100644
--- a/base/task/task_scheduler/scheduler_worker_stack_unittest.cc
+++ b/base/task/thread_pool/scheduler_worker_stack_unittest.cc
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_worker_stack.h"
+#include "base/task/thread_pool/scheduler_worker_stack.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
-#include "base/task/task_scheduler/scheduler_worker.h"
-#include "base/task/task_scheduler/sequence.h"
-#include "base/task/task_scheduler/task_tracker.h"
+#include "base/task/thread_pool/scheduler_worker.h"
+#include "base/task/thread_pool/sequence.h"
+#include "base/task/thread_pool/task_tracker.h"
#include "base/test/gtest_util.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
@@ -37,7 +37,7 @@
TimeDelta GetSleepTimeout() override { return TimeDelta::Max(); }
};
-class TaskSchedulerWorkerStackTest : public testing::Test {
+class ThreadPoolWorkerStackTest : public testing::Test {
protected:
void SetUp() override {
worker_a_ = MakeRefCounted<SchedulerWorker>(
@@ -66,7 +66,7 @@
} // namespace
// Verify that Push() and Pop() add/remove values in FIFO order.
-TEST_F(TaskSchedulerWorkerStackTest, PushPop) {
+TEST_F(ThreadPoolWorkerStackTest, PushPop) {
SchedulerWorkerStack stack;
EXPECT_EQ(nullptr, stack.Pop());
@@ -109,7 +109,7 @@
}
// Verify that Peek() returns the correct values in FIFO order.
-TEST_F(TaskSchedulerWorkerStackTest, PeekPop) {
+TEST_F(ThreadPoolWorkerStackTest, PeekPop) {
SchedulerWorkerStack stack;
EXPECT_EQ(nullptr, stack.Peek());
@@ -149,7 +149,7 @@
}
// Verify that Contains() returns true for workers on the stack.
-TEST_F(TaskSchedulerWorkerStackTest, Contains) {
+TEST_F(ThreadPoolWorkerStackTest, Contains) {
SchedulerWorkerStack stack;
EXPECT_FALSE(stack.Contains(worker_a_.get()));
EXPECT_FALSE(stack.Contains(worker_b_.get()));
@@ -187,7 +187,7 @@
}
// Verify that a value can be removed by Remove().
-TEST_F(TaskSchedulerWorkerStackTest, Remove) {
+TEST_F(ThreadPoolWorkerStackTest, Remove) {
SchedulerWorkerStack stack;
EXPECT_TRUE(stack.IsEmpty());
EXPECT_EQ(0U, stack.Size());
@@ -218,7 +218,7 @@
}
// Verify that a value can be pushed again after it has been removed.
-TEST_F(TaskSchedulerWorkerStackTest, PushAfterRemove) {
+TEST_F(ThreadPoolWorkerStackTest, PushAfterRemove) {
SchedulerWorkerStack stack;
EXPECT_EQ(0U, stack.Size());
@@ -238,7 +238,7 @@
}
// Verify that Push() DCHECKs when a value is inserted twice.
-TEST_F(TaskSchedulerWorkerStackTest, PushTwice) {
+TEST_F(ThreadPoolWorkerStackTest, PushTwice) {
SchedulerWorkerStack stack;
stack.Push(worker_a_.get());
EXPECT_DCHECK_DEATH({ stack.Push(worker_a_.get()); });
diff --git a/base/task/task_scheduler/scheduler_worker_unittest.cc b/base/task/thread_pool/scheduler_worker_unittest.cc
similarity index 94%
rename from base/task/task_scheduler/scheduler_worker_unittest.cc
rename to base/task/thread_pool/scheduler_worker_unittest.cc
index 4e9bac7..ffc7173 100644
--- a/base/task/task_scheduler/scheduler_worker_unittest.cc
+++ b/base/task/thread_pool/scheduler_worker_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/scheduler_worker.h"
+#include "base/task/thread_pool/scheduler_worker.h"
#include <stddef.h>
@@ -16,13 +16,13 @@
#include "base/memory/ref_counted.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/environment_config.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
-#include "base/task/task_scheduler/scheduler_worker_observer.h"
-#include "base/task/task_scheduler/sequence.h"
-#include "base/task/task_scheduler/task.h"
-#include "base/task/task_scheduler/task_tracker.h"
-#include "base/task/task_scheduler/test_utils.h"
+#include "base/task/thread_pool/environment_config.h"
+#include "base/task/thread_pool/scheduler_lock.h"
+#include "base/task/thread_pool/scheduler_worker_observer.h"
+#include "base/task/thread_pool/sequence.h"
+#include "base/task/thread_pool/task.h"
+#include "base/task/thread_pool/task_tracker.h"
+#include "base/task/thread_pool/test_utils.h"
#include "base/test/test_timeouts.h"
#include "base/threading/platform_thread.h"
#include "base/threading/simple_thread.h"
@@ -73,10 +73,9 @@
};
// The test parameter is the number of Tasks per Sequence returned by GetWork().
-class TaskSchedulerWorkerTest : public testing::TestWithParam<int> {
+class ThreadPoolWorkerTest : public testing::TestWithParam<int> {
protected:
- TaskSchedulerWorkerTest()
- : num_get_work_cv_(lock_.CreateConditionVariable()) {}
+ ThreadPoolWorkerTest() : num_get_work_cv_(lock_.CreateConditionVariable()) {}
void SetUp() override {
worker_ = MakeRefCounted<SchedulerWorker>(
@@ -136,8 +135,7 @@
private:
class TestSchedulerWorkerDelegate : public SchedulerWorkerDefaultDelegate {
public:
- TestSchedulerWorkerDelegate(TaskSchedulerWorkerTest* outer)
- : outer_(outer) {}
+ TestSchedulerWorkerDelegate(ThreadPoolWorkerTest* outer) : outer_(outer) {}
~TestSchedulerWorkerDelegate() override {
EXPECT_FALSE(IsCallToDidRunTaskExpected());
@@ -182,7 +180,7 @@
Sequence::Transaction sequence_transaction(sequence->BeginTransaction());
for (int i = 0; i < outer_->TasksPerSequence(); ++i) {
Task task(FROM_HERE,
- BindOnce(&TaskSchedulerWorkerTest::RunTaskCallback,
+ BindOnce(&ThreadPoolWorkerTest::RunTaskCallback,
Unretained(outer_)),
TimeDelta());
EXPECT_TRUE(outer_->task_tracker_.WillPostTask(
@@ -250,7 +248,7 @@
return expect_did_run_task_;
}
- TaskSchedulerWorkerTest* outer_;
+ ThreadPoolWorkerTest* outer_;
// Synchronizes access to |expect_did_run_task_|.
mutable SchedulerLock expect_did_run_task_lock_;
@@ -300,14 +298,14 @@
// Signaled after |worker_| is set.
WaitableEvent worker_set_;
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerWorkerTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolWorkerTest);
};
} // namespace
// Verify that when GetWork() continuously returns Sequences, all Tasks in these
// Sequences run successfully. The test wakes up the SchedulerWorker once.
-TEST_P(TaskSchedulerWorkerTest, ContinuousWork) {
+TEST_P(ThreadPoolWorkerTest, ContinuousWork) {
// Set GetWork() to return |kNumSequencesPerTest| Sequences before starting to
// return nullptr.
SetNumSequencesToCreate(kNumSequencesPerTest);
@@ -337,7 +335,7 @@
// Verify that when GetWork() alternates between returning a Sequence and
// returning nullptr, all Tasks in the returned Sequences run successfully. The
// test wakes up the SchedulerWorker once for each Sequence.
-TEST_P(TaskSchedulerWorkerTest, IntermittentWork) {
+TEST_P(ThreadPoolWorkerTest, IntermittentWork) {
for (size_t i = 0; i < kNumSequencesPerTest; ++i) {
// Set GetWork() to return 1 Sequence before starting to return
// nullptr.
@@ -367,10 +365,10 @@
}
INSTANTIATE_TEST_SUITE_P(OneTaskPerSequence,
- TaskSchedulerWorkerTest,
+ ThreadPoolWorkerTest,
::testing::Values(1));
INSTANTIATE_TEST_SUITE_P(TwoTasksPerSequence,
- TaskSchedulerWorkerTest,
+ ThreadPoolWorkerTest,
::testing::Values(2));
namespace {
@@ -516,7 +514,7 @@
// Verify that calling SchedulerWorker::Cleanup() from GetWork() causes
// the SchedulerWorker's thread to exit.
-TEST(TaskSchedulerWorkerTest, WorkerCleanupFromGetWork) {
+TEST(ThreadPoolWorkerTest, WorkerCleanupFromGetWork) {
TaskTracker task_tracker("Test");
// Will be owned by SchedulerWorker.
MockedControllableCleanupDelegate* delegate =
@@ -535,7 +533,7 @@
controls->WaitForMainExit();
}
-TEST(TaskSchedulerWorkerTest, WorkerCleanupDuringWork) {
+TEST(ThreadPoolWorkerTest, WorkerCleanupDuringWork) {
TaskTracker task_tracker("Test");
// Will be owned by SchedulerWorker.
// No mock here as that's reasonably covered by other tests and the delegate
@@ -560,7 +558,7 @@
controls->WaitForDelegateDestroy();
}
-TEST(TaskSchedulerWorkerTest, WorkerCleanupDuringWait) {
+TEST(ThreadPoolWorkerTest, WorkerCleanupDuringWait) {
TaskTracker task_tracker("Test");
// Will be owned by SchedulerWorker.
// No mock here as that's reasonably covered by other tests and the delegate
@@ -582,7 +580,7 @@
controls->WaitForDelegateDestroy();
}
-TEST(TaskSchedulerWorkerTest, WorkerCleanupDuringShutdown) {
+TEST(ThreadPoolWorkerTest, WorkerCleanupDuringShutdown) {
TaskTracker task_tracker("Test");
// Will be owned by SchedulerWorker.
// No mock here as that's reasonably covered by other tests and the delegate
@@ -609,7 +607,7 @@
}
// Verify that Start() is a no-op after Cleanup().
-TEST(TaskSchedulerWorkerTest, CleanupBeforeStart) {
+TEST(ThreadPoolWorkerTest, CleanupBeforeStart) {
TaskTracker task_tracker("Test");
// Will be owned by SchedulerWorker.
// No mock here as that's reasonably covered by other tests and the delegate
@@ -655,7 +653,7 @@
} // namespace
-TEST(TaskSchedulerWorkerTest, WorkerCleanupDuringJoin) {
+TEST(ThreadPoolWorkerTest, WorkerCleanupDuringJoin) {
TaskTracker task_tracker("Test");
// Will be owned by SchedulerWorker.
// No mock here as that's reasonably covered by other tests and the
@@ -739,7 +737,7 @@
} // namespace
-TEST(TaskSchedulerWorkerTest, BumpPriorityOfAliveThreadDuringShutdown) {
+TEST(ThreadPoolWorkerTest, BumpPriorityOfAliveThreadDuringShutdown) {
if (!CanUseBackgroundPriorityForSchedulerWorker())
return;
@@ -801,7 +799,7 @@
// Verify that the SchedulerWorkerObserver is notified when the worker enters
// and exits its main function.
-TEST(TaskSchedulerWorkerTest, MAYBE_SchedulerWorkerObserver) {
+TEST(ThreadPoolWorkerTest, MAYBE_SchedulerWorkerObserver) {
StrictMock<test::MockSchedulerWorkerObserver> observer;
{
TaskTracker task_tracker("Test");
@@ -851,7 +849,7 @@
} // namespace
-TEST(TaskSchedulerWorkerTest, BackwardCompatibilityEnabled) {
+TEST(ThreadPoolWorkerTest, BackwardCompatibilityEnabled) {
TaskTracker task_tracker("Test");
auto delegate = std::make_unique<CoInitializeDelegate>();
CoInitializeDelegate* const delegate_raw = delegate.get();
@@ -878,7 +876,7 @@
worker->JoinForTesting();
}
-TEST(TaskSchedulerWorkerTest, BackwardCompatibilityDisabled) {
+TEST(ThreadPoolWorkerTest, BackwardCompatibilityDisabled) {
TaskTracker task_tracker("Test");
auto delegate = std::make_unique<CoInitializeDelegate>();
CoInitializeDelegate* const delegate_raw = delegate.get();
diff --git a/base/task/task_scheduler/sequence.cc b/base/task/thread_pool/sequence.cc
similarity index 98%
rename from base/task/task_scheduler/sequence.cc
rename to base/task/thread_pool/sequence.cc
index ab842605..7ff0fa8 100644
--- a/base/task/task_scheduler/sequence.cc
+++ b/base/task/thread_pool/sequence.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/sequence.h"
+#include "base/task/thread_pool/sequence.h"
#include <utility>
diff --git a/base/task/task_scheduler/sequence.h b/base/task/thread_pool/sequence.h
similarity index 92%
rename from base/task/task_scheduler/sequence.h
rename to base/task/thread_pool/sequence.h
index 9394de1..a4f8495 100644
--- a/base/task/task_scheduler/sequence.h
+++ b/base/task/thread_pool/sequence.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SEQUENCE_H_
-#define BASE_TASK_TASK_SCHEDULER_SEQUENCE_H_
+#ifndef BASE_TASK_THREAD_POOL_SEQUENCE_H_
+#define BASE_TASK_THREAD_POOL_SEQUENCE_H_
#include <stddef.h>
@@ -12,11 +12,11 @@
#include "base/macros.h"
#include "base/optional.h"
#include "base/sequence_token.h"
-#include "base/task/task_scheduler/scheduler_parallel_task_runner.h"
-#include "base/task/task_scheduler/sequence_sort_key.h"
-#include "base/task/task_scheduler/task.h"
-#include "base/task/task_scheduler/task_source.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/scheduler_parallel_task_runner.h"
+#include "base/task/thread_pool/sequence_sort_key.h"
+#include "base/task/thread_pool/task.h"
+#include "base/task/thread_pool/task_source.h"
#include "base/threading/sequence_local_storage_map.h"
namespace base {
@@ -125,4 +125,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SEQUENCE_H_
+#endif // BASE_TASK_THREAD_POOL_SEQUENCE_H_
diff --git a/base/task/task_scheduler/sequence_sort_key.cc b/base/task/thread_pool/sequence_sort_key.cc
similarity index 94%
rename from base/task/task_scheduler/sequence_sort_key.cc
rename to base/task/thread_pool/sequence_sort_key.cc
index 98be8699..44011f7 100644
--- a/base/task/task_scheduler/sequence_sort_key.cc
+++ b/base/task/thread_pool/sequence_sort_key.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/sequence_sort_key.h"
+#include "base/task/thread_pool/sequence_sort_key.h"
namespace base {
namespace internal {
diff --git a/base/task/task_scheduler/sequence_sort_key.h b/base/task/thread_pool/sequence_sort_key.h
similarity index 89%
rename from base/task/task_scheduler/sequence_sort_key.h
rename to base/task/thread_pool/sequence_sort_key.h
index 2d33def..8121bf0 100644
--- a/base/task/task_scheduler/sequence_sort_key.h
+++ b/base/task/thread_pool/sequence_sort_key.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SEQUENCE_SORT_KEY_H_
-#define BASE_TASK_TASK_SCHEDULER_SEQUENCE_SORT_KEY_H_
+#ifndef BASE_TASK_THREAD_POOL_SEQUENCE_SORT_KEY_H_
+#define BASE_TASK_THREAD_POOL_SEQUENCE_SORT_KEY_H_
#include "base/base_export.h"
#include "base/task/task_traits.h"
@@ -50,4 +50,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SEQUENCE_SORT_KEY_H_
+#endif // BASE_TASK_THREAD_POOL_SEQUENCE_SORT_KEY_H_
diff --git a/base/task/task_scheduler/sequence_sort_key_unittest.cc b/base/task/thread_pool/sequence_sort_key_unittest.cc
similarity index 95%
rename from base/task/task_scheduler/sequence_sort_key_unittest.cc
rename to base/task/thread_pool/sequence_sort_key_unittest.cc
index 93704a9..4791486f 100644
--- a/base/task/task_scheduler/sequence_sort_key_unittest.cc
+++ b/base/task/thread_pool/sequence_sort_key_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/sequence_sort_key.h"
+#include "base/task/thread_pool/sequence_sort_key.h"
#include "base/task/task_traits.h"
#include "base/time/time.h"
@@ -11,7 +11,7 @@
namespace base {
namespace internal {
-TEST(TaskSchedulerSequenceSortKeyTest, OperatorLessThanOrEqual) {
+TEST(ThreadPoolSequenceSortKeyTest, OperatorLessThanOrEqual) {
SequenceSortKey key_a(TaskPriority::USER_BLOCKING,
TimeTicks::FromInternalValue(1000));
SequenceSortKey key_b(TaskPriority::USER_BLOCKING,
@@ -68,7 +68,7 @@
EXPECT_LE(key_f, key_f);
}
-TEST(TaskSchedulerSequenceSortKeyTest, OperatorEqual) {
+TEST(ThreadPoolSequenceSortKeyTest, OperatorEqual) {
SequenceSortKey key_a(TaskPriority::USER_BLOCKING,
TimeTicks::FromInternalValue(1000));
SequenceSortKey key_b(TaskPriority::USER_BLOCKING,
@@ -125,7 +125,7 @@
EXPECT_EQ(key_f, key_f);
}
-TEST(TaskSchedulerSequenceSortKeyTest, OperatorNotEqual) {
+TEST(ThreadPoolSequenceSortKeyTest, OperatorNotEqual) {
SequenceSortKey key_a(TaskPriority::USER_BLOCKING,
TimeTicks::FromInternalValue(1000));
SequenceSortKey key_b(TaskPriority::USER_BLOCKING,
diff --git a/base/task/task_scheduler/sequence_unittest.cc b/base/task/thread_pool/sequence_unittest.cc
similarity index 93%
rename from base/task/task_scheduler/sequence_unittest.cc
rename to base/task/thread_pool/sequence_unittest.cc
index dc1d8029..4f0890f 100644
--- a/base/task/task_scheduler/sequence_unittest.cc
+++ b/base/task/thread_pool/sequence_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/sequence.h"
+#include "base/task/thread_pool/sequence.h"
#include <utility>
@@ -37,7 +37,7 @@
} // namespace
-TEST(TaskSchedulerSequenceTest, PushTakeRemove) {
+TEST(ThreadPoolSequenceTest, PushTakeRemove) {
testing::StrictMock<MockTask> mock_task_a;
testing::StrictMock<MockTask> mock_task_b;
testing::StrictMock<MockTask> mock_task_c;
@@ -98,7 +98,7 @@
}
// Verifies the sort key of a BEST_EFFORT sequence that contains one task.
-TEST(TaskSchedulerSequenceTest, GetSortKeyBestEffort) {
+TEST(ThreadPoolSequenceTest, GetSortKeyBestEffort) {
// Create a BEST_EFFORT sequence with a task.
Task best_effort_task(FROM_HERE, DoNothing(), TimeDelta());
scoped_refptr<Sequence> best_effort_sequence =
@@ -125,9 +125,9 @@
best_effort_sequence_transaction.DidRunTask();
}
-// Same as TaskSchedulerSequenceTest.GetSortKeyBestEffort, but with a
+// Same as ThreadPoolSequenceTest.GetSortKeyBestEffort, but with a
// USER_VISIBLE sequence.
-TEST(TaskSchedulerSequenceTest, GetSortKeyForeground) {
+TEST(ThreadPoolSequenceTest, GetSortKeyForeground) {
// Create a USER_VISIBLE sequence with a task.
Task foreground_task(FROM_HERE, DoNothing(), TimeDelta());
scoped_refptr<Sequence> foreground_sequence =
@@ -156,7 +156,7 @@
// Verify that a DCHECK fires if DidRunTask() is called on a sequence which
// didn't return a Task.
-TEST(TaskSchedulerSequenceTest, DidRunTaskWithoutTakeTask) {
+TEST(ThreadPoolSequenceTest, DidRunTaskWithoutTakeTask) {
scoped_refptr<Sequence> sequence = MakeRefCounted<Sequence>(
TaskTraits(), nullptr, TaskSourceExecutionMode::kParallel);
Sequence::Transaction sequence_transaction(sequence->BeginTransaction());
@@ -167,7 +167,7 @@
// Verify that a DCHECK fires if TakeTask() is called on a sequence whose front
// slot is empty.
-TEST(TaskSchedulerSequenceTest, TakeEmptyFrontSlot) {
+TEST(ThreadPoolSequenceTest, TakeEmptyFrontSlot) {
scoped_refptr<Sequence> sequence = MakeRefCounted<Sequence>(
TaskTraits(), nullptr, TaskSourceExecutionMode::kParallel);
Sequence::Transaction sequence_transaction(sequence->BeginTransaction());
@@ -178,7 +178,7 @@
}
// Verify that a DCHECK fires if TakeTask() is called on an empty sequence.
-TEST(TaskSchedulerSequenceTest, TakeEmptySequence) {
+TEST(ThreadPoolSequenceTest, TakeEmptySequence) {
scoped_refptr<Sequence> sequence = MakeRefCounted<Sequence>(
TaskTraits(), nullptr, TaskSourceExecutionMode::kParallel);
Sequence::Transaction sequence_transaction(sequence->BeginTransaction());
diff --git a/base/task/task_scheduler/service_thread.cc b/base/task/thread_pool/service_thread.cc
similarity index 90%
rename from base/task/task_scheduler/service_thread.cc
rename to base/task/thread_pool/service_thread.cc
index a4a38ff..40ccddf 100644
--- a/base/task/task_scheduler/service_thread.cc
+++ b/base/task/thread_pool/service_thread.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/service_thread.h"
+#include "base/task/thread_pool/service_thread.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -10,9 +10,9 @@
#include "base/rand_util.h"
#include "base/stl_util.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
-#include "base/task/task_scheduler/task_tracker.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/task_tracker.h"
+#include "base/task/thread_pool/thread_pool.h"
namespace base {
namespace internal {
@@ -25,7 +25,7 @@
ServiceThread::ServiceThread(const TaskTracker* task_tracker,
RepeatingClosure report_heartbeat_metrics_callback)
- : Thread("TaskSchedulerServiceThread"),
+ : Thread("ThreadPoolServiceThread"),
task_tracker_(task_tracker),
report_heartbeat_metrics_callback_(
std::move(report_heartbeat_metrics_callback)) {}
@@ -38,10 +38,10 @@
}
void ServiceThread::Init() {
- // In unit tests we sometimes do not have a fully functional TaskScheduler
+ // In unit tests we sometimes do not have a fully functional ThreadPool
// environment, do not perform the heartbeat report in that case since it
// relies on such an environment.
- if (TaskScheduler::GetInstance()) {
+ if (ThreadPool::GetInstance()) {
// Compute the histogram every hour (with a slight offset to drift if that
// hour tick happens to line up with specific events). Once per hour per
// user was deemed sufficient to gather a reliable metric.
@@ -79,8 +79,8 @@
// Only record latency for one set of TaskTraits per report to avoid bias in
// the order in which tasks are posted (should we record all at once) as well
// as to avoid spinning up many worker threads to process this report if the
- // scheduler is currently idle (each pool keeps at least one idle thread so a
- // single task isn't an issue).
+ // thread pool is currently idle (each pool keeps at least one idle thread so
+ // a single task isn't an issue).
// Invoke RandInt() out-of-line to ensure it's obtained before
// TimeTicks::Now().
diff --git a/base/task/task_scheduler/service_thread.h b/base/task/thread_pool/service_thread.h
similarity index 87%
rename from base/task/task_scheduler/service_thread.h
rename to base/task/thread_pool/service_thread.h
index 1790622..c656be771 100644
--- a/base/task/task_scheduler/service_thread.h
+++ b/base/task/thread_pool/service_thread.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_SERVICE_THREAD_H_
-#define BASE_TASK_TASK_SCHEDULER_SERVICE_THREAD_H_
+#ifndef BASE_TASK_THREAD_POOL_SERVICE_THREAD_H_
+#define BASE_TASK_THREAD_POOL_SERVICE_THREAD_H_
#include "base/base_export.h"
#include "base/macros.h"
@@ -16,7 +16,7 @@
class TaskTracker;
-// The TaskScheduler's ServiceThread is a mostly idle thread that is responsible
+// The ThreadPool's ServiceThread is a mostly idle thread that is responsible
// for handling async events (e.g. delayed tasks and async I/O). Its role is to
// merely forward such events to their destination (hence staying mostly idle
// and highly responsive).
@@ -27,7 +27,7 @@
// Constructs a ServiceThread which will record heartbeat metrics. This
// includes metrics recorded through |report_heartbeat_metrics_callback|,
// in addition to latency metrics through |task_tracker| if non-null. In that
- // case, this ServiceThread will assume a registered TaskScheduler instance
+ // case, this ServiceThread will assume a registered ThreadPool instance
// and that |task_tracker| will outlive this ServiceThread.
explicit ServiceThread(const TaskTracker* task_tracker,
RepeatingClosure report_heartbeat_metrics_callback);
@@ -65,4 +65,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_SERVICE_THREAD_H_
+#endif // BASE_TASK_THREAD_POOL_SERVICE_THREAD_H_
diff --git a/base/task/task_scheduler/service_thread_unittest.cc b/base/task/thread_pool/service_thread_unittest.cc
similarity index 74%
rename from base/task/task_scheduler/service_thread_unittest.cc
rename to base/task/thread_pool/service_thread_unittest.cc
index 646dd51..be5a09d2 100644
--- a/base/task/task_scheduler/service_thread_unittest.cc
+++ b/base/task/thread_pool/service_thread_unittest.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/service_thread.h"
+#include "base/task/thread_pool/service_thread.h"
#include <string>
#include "base/bind.h"
#include "base/debug/stack_trace.h"
-#include "base/task/task_scheduler/task_scheduler.h"
-#include "base/task/task_scheduler/task_scheduler_impl.h"
+#include "base/task/thread_pool/thread_pool.h"
+#include "base/task/thread_pool/thread_pool_impl.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
@@ -42,7 +42,7 @@
#define MAYBE_StackHasIdentifyingFrame StackHasIdentifyingFrame
#endif
-TEST(TaskSchedulerServiceThreadTest, MAYBE_StackHasIdentifyingFrame) {
+TEST(ThreadPoolServiceThreadTest, MAYBE_StackHasIdentifyingFrame) {
ServiceThread service_thread(nullptr, DoNothing());
service_thread.Start();
@@ -53,27 +53,26 @@
}
// Integration test verifying that a service thread running in a fully
-// integrated TaskScheduler environment results in reporting
+// integrated ThreadPool environment results in reporting
// HeartbeatLatencyMicroseconds metrics.
-TEST(TaskSchedulerServiceThreadIntegrationTest, HeartbeatLatencyReport) {
+TEST(ThreadPoolServiceThreadIntegrationTest, HeartbeatLatencyReport) {
ServiceThread::SetHeartbeatIntervalForTesting(TimeDelta::FromMilliseconds(1));
- TaskScheduler::SetInstance(
- std::make_unique<internal::TaskSchedulerImpl>("Test"));
- TaskScheduler::GetInstance()->StartWithDefaultParams();
+ ThreadPool::SetInstance(std::make_unique<internal::ThreadPoolImpl>("Test"));
+ ThreadPool::GetInstance()->StartWithDefaultParams();
static constexpr const char* kExpectedMetrics[] = {
- "TaskScheduler.HeartbeatLatencyMicroseconds.Test."
+ "ThreadPool.HeartbeatLatencyMicroseconds.Test."
"UserBlockingTaskPriority",
- "TaskScheduler.HeartbeatLatencyMicroseconds.Test."
+ "ThreadPool.HeartbeatLatencyMicroseconds.Test."
"UserBlockingTaskPriority_MayBlock",
- "TaskScheduler.HeartbeatLatencyMicroseconds.Test."
+ "ThreadPool.HeartbeatLatencyMicroseconds.Test."
"UserVisibleTaskPriority",
- "TaskScheduler.HeartbeatLatencyMicroseconds.Test."
+ "ThreadPool.HeartbeatLatencyMicroseconds.Test."
"UserVisibleTaskPriority_MayBlock",
- "TaskScheduler.HeartbeatLatencyMicroseconds.Test."
+ "ThreadPool.HeartbeatLatencyMicroseconds.Test."
"BackgroundTaskPriority",
- "TaskScheduler.HeartbeatLatencyMicroseconds.Test."
+ "ThreadPool.HeartbeatLatencyMicroseconds.Test."
"BackgroundTaskPriority_MayBlock"};
// Each report hits a single histogram above (randomly selected). But 1000
@@ -93,8 +92,8 @@
}
}
- TaskScheduler::GetInstance()->JoinForTesting();
- TaskScheduler::SetInstance(nullptr);
+ ThreadPool::GetInstance()->JoinForTesting();
+ ThreadPool::SetInstance(nullptr);
ServiceThread::SetHeartbeatIntervalForTesting(TimeDelta());
}
diff --git a/base/task/task_scheduler/task.cc b/base/task/thread_pool/task.cc
similarity index 85%
rename from base/task/task_scheduler/task.cc
rename to base/task/thread_pool/task.cc
index 17f7202..33f19f1 100644
--- a/base/task/task_scheduler/task.cc
+++ b/base/task/thread_pool/task.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/task.h"
+#include "base/task/thread_pool/task.h"
#include <utility>
@@ -24,9 +24,9 @@
std::move(task),
delay.is_zero() ? TimeTicks() : TimeTicks::Now() + delay,
Nestable::kNonNestable) {
- // TaskScheduler doesn't use |sequence_num| but tracing (toplevel.flow) relies
+ // ThreadPool doesn't use |sequence_num| but tracing (toplevel.flow) relies
// on it being unique. While this subtle dependency is a bit overreaching,
- // TaskScheduler is the only task system that doesn't use |sequence_num| and
+ // ThreadPool is the only task system that doesn't use |sequence_num| and
// the dependent code rarely changes so this isn't worth a big change and
// faking it here isn't too bad for now (posting tasks is full of atomic ops
// already).
diff --git a/base/task/task_scheduler/task.h b/base/task/thread_pool/task.h
similarity index 78%
rename from base/task/task_scheduler/task.h
rename to base/task/thread_pool/task.h
index 10e021a..0414e1d 100644
--- a/base/task/task_scheduler/task.h
+++ b/base/task/thread_pool/task.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_TASK_H_
-#define BASE_TASK_TASK_SCHEDULER_TASK_H_
+#ifndef BASE_TASK_THREAD_POOL_TASK_H_
+#define BASE_TASK_THREAD_POOL_TASK_H_
#include "base/base_export.h"
#include "base/callback.h"
@@ -18,7 +18,7 @@
namespace base {
namespace internal {
-// A task is a unit of work inside the task scheduler. Support for tracing and
+// A task is a unit of work inside the thread pool. Support for tracing and
// profiling inherited from PendingTask.
// TODO(etiennep): This class is now equivalent to PendingTask, remove it.
struct BASE_EXPORT Task : public PendingTask {
@@ -26,9 +26,7 @@
// |posted_from| is the site the task was posted from. |task| is the closure
// to run. |delay| is a delay that must expire before the Task runs.
- Task(const Location& posted_from,
- OnceClosure task,
- TimeDelta delay);
+ Task(const Location& posted_from, OnceClosure task, TimeDelta delay);
// Task is move-only to avoid mistakes that cause reference counts to be
// accidentally bumped.
@@ -45,4 +43,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_TASK_H_
+#endif // BASE_TASK_THREAD_POOL_TASK_H_
diff --git a/base/task/task_scheduler/task_source.cc b/base/task/thread_pool/task_source.cc
similarity index 97%
rename from base/task/task_scheduler/task_source.cc
rename to base/task/thread_pool/task_source.cc
index 3949401..52922a2 100644
--- a/base/task/task_scheduler/task_source.cc
+++ b/base/task/thread_pool/task_source.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/task_source.h"
+#include "base/task/thread_pool/task_source.h"
#include <utility>
diff --git a/base/task/task_scheduler/task_source.h b/base/task/thread_pool/task_source.h
similarity index 94%
rename from base/task/task_scheduler/task_source.h
rename to base/task/thread_pool/task_source.h
index edb1b93..92f1fda 100644
--- a/base/task/task_scheduler/task_source.h
+++ b/base/task/thread_pool/task_source.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_TASK_SOURCE_H_
-#define BASE_TASK_TASK_SCHEDULER_TASK_SOURCE_H_
+#ifndef BASE_TASK_THREAD_POOL_TASK_SOURCE_H_
+#define BASE_TASK_THREAD_POOL_TASK_SOURCE_H_
#include <stddef.h>
@@ -13,10 +13,10 @@
#include "base/optional.h"
#include "base/sequence_token.h"
#include "base/task/common/intrusive_heap.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
-#include "base/task/task_scheduler/sequence_sort_key.h"
-#include "base/task/task_scheduler/task.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/scheduler_lock.h"
+#include "base/task/thread_pool/sequence_sort_key.h"
+#include "base/task/thread_pool/task.h"
#include "base/threading/sequence_local_storage_map.h"
namespace base {
@@ -76,7 +76,7 @@
//
// Because this method cannot be called on an empty TaskSource, the returned
// Optional<Task> is never nullptr. An Optional is used in preparation for
- // the merge between TaskScheduler and TaskQueueManager (in Blink).
+ // the merge between ThreadPool and TaskQueueManager (in Blink).
// https://crbug.com/783309
Optional<Task> TakeTask();
@@ -206,4 +206,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_TASK_SOURCE_H_
+#endif // BASE_TASK_THREAD_POOL_TASK_SOURCE_H_
diff --git a/base/task/task_scheduler/task_source_unittest.cc b/base/task/thread_pool/task_source_unittest.cc
similarity index 91%
rename from base/task/task_scheduler/task_source_unittest.cc
rename to base/task/thread_pool/task_source_unittest.cc
index 88ac83d..1b2d882 100644
--- a/base/task/task_scheduler/task_source_unittest.cc
+++ b/base/task/thread_pool/task_source_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/task_source.h"
+#include "base/task/thread_pool/task_source.h"
#include <utility>
@@ -40,7 +40,7 @@
} // namespace
-TEST(TaskSchedulerTaskSourceTest, TakeTaskDidRunTask) {
+TEST(ThreadPoolTaskSourceTest, TakeTaskDidRunTask) {
scoped_refptr<MockTaskSource> task_source =
MakeRefCounted<MockTaskSource>(TaskTraits(TaskPriority::BEST_EFFORT));
TaskSource::Transaction task_source_transaction(
@@ -57,7 +57,7 @@
EXPECT_TRUE(task_source_transaction.DidRunTask());
}
-TEST(TaskSchedulerTaskSourceTest, InvalidTakeTask) {
+TEST(ThreadPoolTaskSourceTest, InvalidTakeTask) {
scoped_refptr<MockTaskSource> task_source =
MakeRefCounted<MockTaskSource>(TaskTraits(TaskPriority::BEST_EFFORT));
TaskSource::Transaction task_source_transaction(
@@ -68,7 +68,7 @@
EXPECT_DCHECK_DEATH(task_source_transaction.TakeTask());
}
-TEST(TaskSchedulerTaskSourceTest, InvalidDidRunTask) {
+TEST(ThreadPoolTaskSourceTest, InvalidDidRunTask) {
scoped_refptr<MockTaskSource> task_source =
MakeRefCounted<MockTaskSource>(TaskTraits(TaskPriority::BEST_EFFORT));
TaskSource::Transaction task_source_transaction(
diff --git a/base/task/task_scheduler/task_tracker.cc b/base/task/thread_pool/task_tracker.cc
similarity index 97%
rename from base/task/task_scheduler/task_tracker.cc
rename to base/task/thread_pool/task_tracker.cc
index 6a218ab3..edc215f7 100644
--- a/base/task/task_scheduler/task_tracker.cc
+++ b/base/task/thread_pool/task_tracker.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/task_tracker.h"
+#include "base/task/thread_pool/task_tracker.h"
#include <atomic>
#include <string>
@@ -76,7 +76,7 @@
}
// Constructs a histogram to track latency which is logging to
-// "TaskScheduler.{histogram_name}.{histogram_label}.{task_type_suffix}".
+// "ThreadPool.{histogram_name}.{histogram_label}.{task_type_suffix}".
HistogramBase* GetLatencyHistogram(StringPiece histogram_name,
StringPiece histogram_label,
StringPiece task_type_suffix) {
@@ -89,8 +89,7 @@
// below 1ms (most of them) and enough info to assess how bad the latency is
// for tasks that exceed this threshold.
const std::string histogram = JoinString(
- {"TaskScheduler", histogram_name, histogram_label, task_type_suffix},
- ".");
+ {"ThreadPool", histogram_name, histogram_label, task_type_suffix}, ".");
return Histogram::FactoryMicrosecondsTimeGet(
histogram, TimeDelta::FromMicroseconds(1),
TimeDelta::FromMilliseconds(20), 50,
@@ -98,7 +97,7 @@
}
// Constructs a histogram to track task count which is logging to
-// "TaskScheduler.{histogram_name}.{histogram_label}.{task_type_suffix}".
+// "ThreadPool.{histogram_name}.{histogram_label}.{task_type_suffix}".
HistogramBase* GetCountHistogram(StringPiece histogram_name,
StringPiece histogram_label,
StringPiece task_type_suffix) {
@@ -107,8 +106,7 @@
DCHECK(!task_type_suffix.empty());
// Mimics the UMA_HISTOGRAM_CUSTOM_COUNTS macro.
const std::string histogram = JoinString(
- {"TaskScheduler", histogram_name, histogram_label, task_type_suffix},
- ".");
+ {"ThreadPool", histogram_name, histogram_label, task_type_suffix}, ".");
// 500 was chosen as the maximum number of tasks run while queuing because
// values this high would likely indicate an error, beyond which knowing the
// actual number of tasks is not informative.
@@ -133,7 +131,7 @@
// Returns the maximum number of TaskPriority::BEST_EFFORT sequences that can be
// scheduled concurrently based on command line flags.
int GetMaxNumScheduledBestEffortSequences() {
- // The CommandLine might not be initialized if TaskScheduler is initialized
+ // The CommandLine might not be initialized if ThreadPool is initialized
// in a dynamic library which doesn't have access to argc/argv.
if (CommandLine::InitializedForCurrentProcess() &&
CommandLine::ForCurrentProcess()->HasSwitch(
@@ -439,7 +437,7 @@
subtle::NoBarrier_AtomicIncrement(&num_incomplete_undelayed_tasks_, 1);
// TODO(scheduler-dev): Record the task traits here.
- task_annotator_.WillQueueTask("TaskScheduler_PostTask", task, "");
+ task_annotator_.WillQueueTask("ThreadPool_PostTask", task, "");
return true;
}
@@ -630,12 +628,12 @@
}
if (can_run_task) {
- TRACE_TASK_EXECUTION("TaskScheduler_RunTask", task);
+ TRACE_TASK_EXECUTION("ThreadPool_RunTask", task);
// TODO(gab): In a better world this would be tacked on as an extra arg
// to the trace event generated above. This is not possible however until
// http://crbug.com/652692 is resolved.
- TRACE_EVENT1("task_scheduler", "TaskScheduler_TaskInfo", "task_info",
+ TRACE_EVENT1("thread_pool", "ThreadPool_TaskInfo", "task_info",
std::make_unique<TaskTracingInfo>(
traits,
kExecutionModeString[static_cast<size_t>(
@@ -931,19 +929,19 @@
NOINLINE void TaskTracker::RunContinueOnShutdown(Task* task) {
const int line_number = __LINE__;
- task_annotator_.RunTask("TaskScheduler_RunTask_ContinueOnShutdown", task);
+ task_annotator_.RunTask("ThreadPool_RunTask_ContinueOnShutdown", task);
base::debug::Alias(&line_number);
}
NOINLINE void TaskTracker::RunSkipOnShutdown(Task* task) {
const int line_number = __LINE__;
- task_annotator_.RunTask("TaskScheduler_RunTask_SkipOnShutdown", task);
+ task_annotator_.RunTask("ThreadPool_RunTask_SkipOnShutdown", task);
base::debug::Alias(&line_number);
}
NOINLINE void TaskTracker::RunBlockShutdown(Task* task) {
const int line_number = __LINE__;
- task_annotator_.RunTask("TaskScheduler_RunTask_BlockShutdown", task);
+ task_annotator_.RunTask("ThreadPool_RunTask_BlockShutdown", task);
base::debug::Alias(&line_number);
}
diff --git a/base/task/task_scheduler/task_tracker.h b/base/task/thread_pool/task_tracker.h
similarity index 95%
rename from base/task/task_scheduler/task_tracker.h
rename to base/task/thread_pool/task_tracker.h
index 8dd9fe4..f602820b 100644
--- a/base/task/task_scheduler/task_tracker.h
+++ b/base/task/thread_pool/task_tracker.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_TASK_TRACKER_H_
-#define BASE_TASK_TASK_SCHEDULER_TASK_TRACKER_H_
+#ifndef BASE_TASK_THREAD_POOL_TASK_TRACKER_H_
+#define BASE_TASK_THREAD_POOL_TASK_TRACKER_H_
#include <atomic>
#include <functional>
@@ -21,12 +21,12 @@
#include "base/strings/string_piece.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/common/task_annotator.h"
-#include "base/task/task_scheduler/can_schedule_sequence_observer.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
-#include "base/task/task_scheduler/sequence.h"
-#include "base/task/task_scheduler/task.h"
-#include "base/task/task_scheduler/tracked_ref.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/can_schedule_sequence_observer.h"
+#include "base/task/thread_pool/scheduler_lock.h"
+#include "base/task/thread_pool/sequence.h"
+#include "base/task/thread_pool/task.h"
+#include "base/task/thread_pool/tracked_ref.h"
namespace base {
@@ -106,7 +106,7 @@
virtual ~TaskTracker();
- // Synchronously shuts down the scheduler. Once this is called, only tasks
+ // Synchronously shuts down the thread pool. Once this is called, only tasks
// posted with the BLOCK_SHUTDOWN behavior will be run. Returns when:
// - All SKIP_ON_SHUTDOWN tasks that were already running have completed their
// execution.
@@ -186,9 +186,9 @@
void SetHasShutdownStartedForTesting();
// Records two histograms
- // 1. TaskScheduler.[label].HeartbeatLatencyMicroseconds.[suffix]:
+ // 1. ThreadPool.[label].HeartbeatLatencyMicroseconds.[suffix]:
// Now() - posted_time
- // 2. TaskScheduler.[label].NumTasksRunWhileQueuing.[suffix]:
+ // 2. ThreadPool.[label].NumTasksRunWhileQueuing.[suffix]:
// GetNumTasksRun() - num_tasks_run_when_posted.
// [label] is the histogram label provided to the constructor.
// [suffix] is derived from |task_priority| and |may_block|.
@@ -386,9 +386,9 @@
// a task queued to histogram.
std::atomic_int num_tasks_run_{0};
- // TaskScheduler.TaskLatencyMicroseconds.*,
- // TaskScheduler.HeartbeatLatencyMicroseconds.*, and
- // TaskScheduler.NumTasksRunWhileQueuing.* histograms. The first index is
+ // ThreadPool.TaskLatencyMicroseconds.*,
+ // ThreadPool.HeartbeatLatencyMicroseconds.*, and
+ // ThreadPool.NumTasksRunWhileQueuing.* histograms. The first index is
// a TaskPriority. The second index is 0 for non-blocking tasks, 1 for
// blocking tasks. Intentionally leaked.
// TODO(scheduler-dev): Consider using STATIC_HISTOGRAM_POINTER_GROUP for
@@ -424,4 +424,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_TASK_TRACKER_H_
+#endif // BASE_TASK_THREAD_POOL_TASK_TRACKER_H_
diff --git a/base/task/task_scheduler/task_tracker_posix.cc b/base/task/thread_pool/task_tracker_posix.cc
similarity index 93%
rename from base/task/task_scheduler/task_tracker_posix.cc
rename to base/task/thread_pool/task_tracker_posix.cc
index 1f153cde..210ab34 100644
--- a/base/task/task_scheduler/task_tracker_posix.cc
+++ b/base/task/thread_pool/task_tracker_posix.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/task_tracker_posix.h"
+#include "base/task/thread_pool/task_tracker_posix.h"
#include <utility>
diff --git a/base/task/task_scheduler/task_tracker_posix.h b/base/task/thread_pool/task_tracker_posix.h
similarity index 87%
rename from base/task/task_scheduler/task_tracker_posix.h
rename to base/task/thread_pool/task_tracker_posix.h
index 2cef39e9..14ed817 100644
--- a/base/task/task_scheduler/task_tracker_posix.h
+++ b/base/task/thread_pool/task_tracker_posix.h
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_TASK_TRACKER_POSIX_H_
-#define BASE_TASK_TASK_SCHEDULER_TASK_TRACKER_POSIX_H_
+#ifndef BASE_TASK_THREAD_POOL_TASK_TRACKER_POSIX_H_
+#define BASE_TASK_THREAD_POOL_TASK_TRACKER_POSIX_H_
#include <memory>
#include "base/base_export.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/task/task_scheduler/task_tracker.h"
+#include "base/task/thread_pool/task_tracker.h"
#include "base/threading/platform_thread.h"
namespace base {
@@ -54,4 +54,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_TASK_TRACKER_POSIX_H_
+#endif // BASE_TASK_THREAD_POOL_TASK_TRACKER_POSIX_H_
diff --git a/base/task/task_scheduler/task_tracker_posix_unittest.cc b/base/task/thread_pool/task_tracker_posix_unittest.cc
similarity index 86%
rename from base/task/task_scheduler/task_tracker_posix_unittest.cc
rename to base/task/thread_pool/task_tracker_posix_unittest.cc
index 8d35b08..18591523 100644
--- a/base/task/task_scheduler/task_tracker_posix_unittest.cc
+++ b/base/task/thread_pool/task_tracker_posix_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/task_tracker_posix.h"
+#include "base/task/thread_pool/task_tracker_posix.h"
#include <unistd.h>
@@ -18,9 +18,9 @@
#include "base/posix/eintr_wrapper.h"
#include "base/run_loop.h"
#include "base/sequence_token.h"
-#include "base/task/task_scheduler/task.h"
-#include "base/task/task_scheduler/test_utils.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/task.h"
+#include "base/task/thread_pool/test_utils.h"
#include "base/test/null_task_runner.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
@@ -31,9 +31,9 @@
namespace {
-class TaskSchedulerTaskTrackerPosixTest : public testing::Test {
+class ThreadPoolTaskTrackerPosixTest : public testing::Test {
public:
- TaskSchedulerTaskTrackerPosixTest() : service_thread_("ServiceThread") {
+ ThreadPoolTaskTrackerPosixTest() : service_thread_("ServiceThread") {
Thread::Options service_thread_options;
service_thread_options.message_loop_type = MessageLoop::TYPE_IO;
service_thread_.StartWithOptions(service_thread_options);
@@ -45,13 +45,13 @@
TaskTrackerPosix tracker_ = {"Test"};
private:
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerTaskTrackerPosixTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolTaskTrackerPosixTest);
};
} // namespace
// Verify that TaskTrackerPosix runs a Task it receives.
-TEST_F(TaskSchedulerTaskTrackerPosixTest, RunTask) {
+TEST_F(ThreadPoolTaskTrackerPosixTest, RunTask) {
bool did_run = false;
Task task(FROM_HERE,
Bind([](bool* did_run) { *did_run = true; }, Unretained(&did_run)),
@@ -72,7 +72,7 @@
// Verify that FileDescriptorWatcher::WatchReadable() can be called from a task
// running in TaskTrackerPosix without a crash.
-TEST_F(TaskSchedulerTaskTrackerPosixTest, FileDescriptorWatcher) {
+TEST_F(ThreadPoolTaskTrackerPosixTest, FileDescriptorWatcher) {
int fds[2];
ASSERT_EQ(0, pipe(fds));
Task task(FROM_HERE,
diff --git a/base/task/task_scheduler/task_tracker_unittest.cc b/base/task/thread_pool/task_tracker_unittest.cc
similarity index 93%
rename from base/task/task_scheduler/task_tracker_unittest.cc
rename to base/task/thread_pool/task_tracker_unittest.cc
index 798dd823..f503318 100644
--- a/base/task/task_scheduler/task_tracker_unittest.cc
+++ b/base/task/thread_pool/task_tracker_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/task_tracker.h"
+#include "base/task/thread_pool/task_tracker.h"
#include <stdint.h>
@@ -25,10 +25,10 @@
#include "base/single_thread_task_runner.h"
#include "base/synchronization/atomic_flag.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
-#include "base/task/task_scheduler/task.h"
-#include "base/task/task_scheduler/test_utils.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/scheduler_lock.h"
+#include "base/task/thread_pool/task.h"
+#include "base/task/thread_pool/test_utils.h"
#include "base/test/gtest_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/test_simple_task_runner.h"
@@ -168,16 +168,16 @@
const bool previous_value_;
};
-class TaskSchedulerTaskTrackerTest
+class ThreadPoolTaskTrackerTest
: public testing::TestWithParam<TaskShutdownBehavior> {
protected:
- TaskSchedulerTaskTrackerTest() = default;
+ ThreadPoolTaskTrackerTest() = default;
// Creates a task.
Task CreateTask() {
return Task(
FROM_HERE,
- Bind(&TaskSchedulerTaskTrackerTest::RunTaskCallback, Unretained(this)),
+ Bind(&ThreadPoolTaskTrackerTest::RunTaskCallback, Unretained(this)),
TimeDelta());
}
@@ -255,7 +255,7 @@
size_t num_tasks_executed_ = 0;
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerTaskTrackerTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolTaskTrackerTest);
};
#define WAIT_FOR_ASYNC_SHUTDOWN_COMPLETED() \
@@ -284,7 +284,7 @@
} // namespace
-TEST_P(TaskSchedulerTaskTrackerTest, WillPostAndRunBeforeShutdown) {
+TEST_P(ThreadPoolTaskTrackerTest, WillPostAndRunBeforeShutdown) {
Task task(CreateTask());
// Inform |task_tracker_| that |task| will be posted.
@@ -300,7 +300,7 @@
tracker_.Shutdown();
}
-TEST_P(TaskSchedulerTaskTrackerTest, WillPostAndRunLongTaskBeforeShutdown) {
+TEST_P(ThreadPoolTaskTrackerTest, WillPostAndRunLongTaskBeforeShutdown) {
// Create a task that signals |task_running| and blocks until |task_barrier|
// is signaled.
WaitableEvent task_running(WaitableEvent::ResetPolicy::AUTOMATIC,
@@ -348,7 +348,7 @@
WAIT_FOR_ASYNC_SHUTDOWN_COMPLETED();
}
-TEST_P(TaskSchedulerTaskTrackerTest, WillPostBeforeShutdownRunDuringShutdown) {
+TEST_P(ThreadPoolTaskTrackerTest, WillPostBeforeShutdownRunDuringShutdown) {
// Inform |task_tracker_| that a task will be posted.
Task task(CreateTask());
EXPECT_TRUE(tracker_.WillPostTask(&task, GetParam()));
@@ -379,7 +379,7 @@
WAIT_FOR_ASYNC_SHUTDOWN_COMPLETED();
}
-TEST_P(TaskSchedulerTaskTrackerTest, WillPostBeforeShutdownRunAfterShutdown) {
+TEST_P(ThreadPoolTaskTrackerTest, WillPostBeforeShutdownRunAfterShutdown) {
// Inform |task_tracker_| that a task will be posted.
Task task(CreateTask());
EXPECT_TRUE(tracker_.WillPostTask(&task, GetParam()));
@@ -408,7 +408,7 @@
}
}
-TEST_P(TaskSchedulerTaskTrackerTest, WillPostAndRunDuringShutdown) {
+TEST_P(ThreadPoolTaskTrackerTest, WillPostAndRunDuringShutdown) {
// Inform |task_tracker_| that a BLOCK_SHUTDOWN task will be posted just to
// block shutdown.
Task block_shutdown_task(CreateTask());
@@ -445,7 +445,7 @@
WAIT_FOR_ASYNC_SHUTDOWN_COMPLETED();
}
-TEST_P(TaskSchedulerTaskTrackerTest, WillPostAfterShutdown) {
+TEST_P(ThreadPoolTaskTrackerTest, WillPostAfterShutdown) {
tracker_.Shutdown();
Task task(CreateTask());
@@ -456,7 +456,7 @@
// Verify that BLOCK_SHUTDOWN and SKIP_ON_SHUTDOWN tasks can
// AssertSingletonAllowed() but CONTINUE_ON_SHUTDOWN tasks can't.
-TEST_P(TaskSchedulerTaskTrackerTest, SingletonAllowed) {
+TEST_P(ThreadPoolTaskTrackerTest, SingletonAllowed) {
const bool can_use_singletons =
(GetParam() != TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN);
@@ -479,7 +479,7 @@
}
// Verify that AssertIOAllowed() succeeds only for a MayBlock() task.
-TEST_P(TaskSchedulerTaskTrackerTest, IOAllowed) {
+TEST_P(ThreadPoolTaskTrackerTest, IOAllowed) {
// Unset the IO allowed bit. Expect TaskTracker to set it before running a
// task with the MayBlock() trait.
ThreadRestrictions::SetIOAllowed(false);
@@ -544,7 +544,7 @@
EXPECT_FALSE(SequencedTaskRunnerHandle::IsSet());
}
-TEST_P(TaskSchedulerTaskTrackerTest, TaskRunnerHandleIsNotSetOnParallel) {
+TEST_P(ThreadPoolTaskTrackerTest, TaskRunnerHandleIsNotSetOnParallel) {
// Create a task that will verify that TaskRunnerHandles are not set in its
// scope per no TaskRunner ref being set to it.
Task verify_task(FROM_HERE, BindOnce(&VerifyNoTaskRunnerHandle), TimeDelta());
@@ -561,8 +561,7 @@
EXPECT_EQ(expected_task_runner, SequencedTaskRunnerHandle::Get());
}
-TEST_P(TaskSchedulerTaskTrackerTest,
- SequencedTaskRunnerHandleIsSetOnSequenced) {
+TEST_P(ThreadPoolTaskTrackerTest, SequencedTaskRunnerHandleIsSetOnSequenced) {
scoped_refptr<SequencedTaskRunner> test_task_runner(new TestSimpleTaskRunner);
// Create a task that will verify that SequencedTaskRunnerHandle is properly
@@ -586,8 +585,7 @@
EXPECT_EQ(expected_task_runner, ThreadTaskRunnerHandle::Get());
}
-TEST_P(TaskSchedulerTaskTrackerTest,
- ThreadTaskRunnerHandleIsSetOnSingleThreaded) {
+TEST_P(ThreadPoolTaskTrackerTest, ThreadTaskRunnerHandleIsSetOnSingleThreaded) {
scoped_refptr<SingleThreadTaskRunner> test_task_runner(
new TestSimpleTaskRunner);
@@ -604,14 +602,14 @@
std::move(test_task_runner), TaskSourceExecutionMode::kSingleThread);
}
-TEST_P(TaskSchedulerTaskTrackerTest, FlushPendingDelayedTask) {
+TEST_P(ThreadPoolTaskTrackerTest, FlushPendingDelayedTask) {
Task delayed_task(FROM_HERE, DoNothing(), TimeDelta::FromDays(1));
tracker_.WillPostTask(&delayed_task, GetParam());
// FlushForTesting() should return even if the delayed task didn't run.
tracker_.FlushForTesting();
}
-TEST_P(TaskSchedulerTaskTrackerTest, FlushAsyncForTestingPendingDelayedTask) {
+TEST_P(ThreadPoolTaskTrackerTest, FlushAsyncForTestingPendingDelayedTask) {
Task delayed_task(FROM_HERE, DoNothing(), TimeDelta::FromDays(1));
tracker_.WillPostTask(&delayed_task, GetParam());
// FlushAsyncForTesting() should callback even if the delayed task didn't run.
@@ -622,7 +620,7 @@
EXPECT_TRUE(called_back);
}
-TEST_P(TaskSchedulerTaskTrackerTest, FlushPendingUndelayedTask) {
+TEST_P(ThreadPoolTaskTrackerTest, FlushPendingUndelayedTask) {
Task undelayed_task(FROM_HERE, DoNothing(), TimeDelta());
tracker_.WillPostTask(&undelayed_task, GetParam());
@@ -636,7 +634,7 @@
WAIT_FOR_ASYNC_FLUSH_RETURNED();
}
-TEST_P(TaskSchedulerTaskTrackerTest, FlushAsyncForTestingPendingUndelayedTask) {
+TEST_P(ThreadPoolTaskTrackerTest, FlushAsyncForTestingPendingUndelayedTask) {
Task undelayed_task(FROM_HERE, DoNothing(), TimeDelta());
tracker_.WillPostTask(&undelayed_task, GetParam());
@@ -652,7 +650,7 @@
event.Wait();
}
-TEST_P(TaskSchedulerTaskTrackerTest, PostTaskDuringFlush) {
+TEST_P(ThreadPoolTaskTrackerTest, PostTaskDuringFlush) {
Task undelayed_task(FROM_HERE, DoNothing(), TimeDelta());
tracker_.WillPostTask(&undelayed_task, GetParam());
@@ -677,7 +675,7 @@
WAIT_FOR_ASYNC_FLUSH_RETURNED();
}
-TEST_P(TaskSchedulerTaskTrackerTest, PostTaskDuringFlushAsyncForTesting) {
+TEST_P(ThreadPoolTaskTrackerTest, PostTaskDuringFlushAsyncForTesting) {
Task undelayed_task(FROM_HERE, DoNothing(), TimeDelta());
tracker_.WillPostTask(&undelayed_task, GetParam());
@@ -706,7 +704,7 @@
event.Wait();
}
-TEST_P(TaskSchedulerTaskTrackerTest, RunDelayedTaskDuringFlush) {
+TEST_P(ThreadPoolTaskTrackerTest, RunDelayedTaskDuringFlush) {
// Simulate posting a delayed and an undelayed task.
Task delayed_task(FROM_HERE, DoNothing(), TimeDelta::FromDays(1));
tracker_.WillPostTask(&delayed_task, GetParam());
@@ -733,7 +731,7 @@
WAIT_FOR_ASYNC_FLUSH_RETURNED();
}
-TEST_P(TaskSchedulerTaskTrackerTest, RunDelayedTaskDuringFlushAsyncForTesting) {
+TEST_P(ThreadPoolTaskTrackerTest, RunDelayedTaskDuringFlushAsyncForTesting) {
// Simulate posting a delayed and an undelayed task.
Task delayed_task(FROM_HERE, DoNothing(), TimeDelta::FromDays(1));
tracker_.WillPostTask(&delayed_task, GetParam());
@@ -762,7 +760,7 @@
event.Wait();
}
-TEST_P(TaskSchedulerTaskTrackerTest, FlushAfterShutdown) {
+TEST_P(ThreadPoolTaskTrackerTest, FlushAfterShutdown) {
if (GetParam() == TaskShutdownBehavior::BLOCK_SHUTDOWN)
return;
@@ -779,7 +777,7 @@
tracker_.FlushForTesting();
}
-TEST_P(TaskSchedulerTaskTrackerTest, FlushAfterShutdownAsync) {
+TEST_P(ThreadPoolTaskTrackerTest, FlushAfterShutdownAsync) {
if (GetParam() == TaskShutdownBehavior::BLOCK_SHUTDOWN)
return;
@@ -800,7 +798,7 @@
EXPECT_TRUE(called_back);
}
-TEST_P(TaskSchedulerTaskTrackerTest, ShutdownDuringFlush) {
+TEST_P(ThreadPoolTaskTrackerTest, ShutdownDuringFlush) {
if (GetParam() == TaskShutdownBehavior::BLOCK_SHUTDOWN)
return;
@@ -822,7 +820,7 @@
WAIT_FOR_ASYNC_FLUSH_RETURNED();
}
-TEST_P(TaskSchedulerTaskTrackerTest, ShutdownDuringFlushAsyncForTesting) {
+TEST_P(ThreadPoolTaskTrackerTest, ShutdownDuringFlushAsyncForTesting) {
if (GetParam() == TaskShutdownBehavior::BLOCK_SHUTDOWN)
return;
@@ -847,7 +845,7 @@
event.Wait();
}
-TEST_P(TaskSchedulerTaskTrackerTest, DoublePendingFlushAsyncForTestingFails) {
+TEST_P(ThreadPoolTaskTrackerTest, DoublePendingFlushAsyncForTestingFails) {
Task undelayed_task(FROM_HERE, DoNothing(), TimeDelta());
tracker_.WillPostTask(&undelayed_task, GetParam());
@@ -862,7 +860,7 @@
// Verify that a delayed task does not block shutdown, regardless of its
// shutdown behavior.
-TEST_P(TaskSchedulerTaskTrackerTest, DelayedTasksDoNotBlockShutdown) {
+TEST_P(ThreadPoolTaskTrackerTest, DelayedTasksDoNotBlockShutdown) {
// Simulate posting a delayed task.
Task delayed_task(FROM_HERE, DoNothing(), TimeDelta::FromDays(1));
EXPECT_TRUE(tracker_.WillPostTask(&delayed_task, GetParam()));
@@ -874,15 +872,15 @@
INSTANTIATE_TEST_SUITE_P(
ContinueOnShutdown,
- TaskSchedulerTaskTrackerTest,
+ ThreadPoolTaskTrackerTest,
::testing::Values(TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN));
INSTANTIATE_TEST_SUITE_P(
SkipOnShutdown,
- TaskSchedulerTaskTrackerTest,
+ ThreadPoolTaskTrackerTest,
::testing::Values(TaskShutdownBehavior::SKIP_ON_SHUTDOWN));
INSTANTIATE_TEST_SUITE_P(
BlockShutdown,
- TaskSchedulerTaskTrackerTest,
+ ThreadPoolTaskTrackerTest,
::testing::Values(TaskShutdownBehavior::BLOCK_SHUTDOWN));
namespace {
@@ -895,7 +893,7 @@
// Verify that SequenceToken::GetForCurrentThread() returns the Sequence's token
// when a Task runs.
-TEST_F(TaskSchedulerTaskTrackerTest, CurrentSequenceToken) {
+TEST_F(ThreadPoolTaskTrackerTest, CurrentSequenceToken) {
scoped_refptr<Sequence> sequence = MakeRefCounted<Sequence>(
TaskTraits(), nullptr, TaskSourceExecutionMode::kParallel);
@@ -916,7 +914,7 @@
EXPECT_FALSE(SequenceToken::GetForCurrentThread().IsValid());
}
-TEST_F(TaskSchedulerTaskTrackerTest, LoadWillPostAndRunBeforeShutdown) {
+TEST_F(ThreadPoolTaskTrackerTest, LoadWillPostAndRunBeforeShutdown) {
// Post and run tasks asynchronously.
std::vector<std::unique_ptr<ThreadPostingAndRunningTask>> threads;
@@ -950,7 +948,7 @@
tracker_.Shutdown();
}
-TEST_F(TaskSchedulerTaskTrackerTest,
+TEST_F(ThreadPoolTaskTrackerTest,
LoadWillPostBeforeShutdownAndRunDuringShutdown) {
// Post tasks asynchronously.
std::vector<Task> tasks_continue_on_shutdown;
@@ -1023,7 +1021,7 @@
EXPECT_EQ(kLoadTestNumIterations, NumTasksExecuted());
}
-TEST_F(TaskSchedulerTaskTrackerTest, LoadWillPostAndRunDuringShutdown) {
+TEST_F(ThreadPoolTaskTrackerTest, LoadWillPostAndRunDuringShutdown) {
// Inform |task_tracker_| that a BLOCK_SHUTDOWN task will be posted just to
// block shutdown.
Task block_shutdown_task(CreateTask());
@@ -1075,7 +1073,7 @@
// Verify that RunAndPopNextTask() returns the sequence from which it ran a task
// when it can be rescheduled.
-TEST_F(TaskSchedulerTaskTrackerTest,
+TEST_F(ThreadPoolTaskTrackerTest,
RunAndPopNextTaskReturnsSequenceToReschedule) {
TaskTraits default_traits = {};
Task task_1(FROM_HERE, DoNothing(), TimeDelta());
@@ -1171,7 +1169,7 @@
// be scheduled concurrently is reached. Verify that an observer is notified
// when a best-effort sequence can be scheduled (i.e. when one of the previously
// scheduled best-effort sequences has run).
-TEST_F(TaskSchedulerTaskTrackerTest,
+TEST_F(ThreadPoolTaskTrackerTest,
WillScheduleBestEffortSequenceWithMaxBestEffortSequences) {
constexpr int kMaxNumScheduledBestEffortSequences = 2;
TaskTracker tracker("Test", kMaxNumScheduledBestEffortSequences);
@@ -1181,7 +1179,7 @@
// Verify that providing a cap for the number of BEST_EFFORT tasks to the
// constructor of TaskTracker is compatible with using an execution fence.
-TEST_F(TaskSchedulerTaskTrackerTest,
+TEST_F(ThreadPoolTaskTrackerTest,
WillScheduleBestEffortSequenceWithMaxBestEffortSequencesAndFence) {
constexpr int kMaxNumScheduledBestEffortSequences = 2;
TaskTracker tracker("Test", kMaxNumScheduledBestEffortSequences);
@@ -1203,7 +1201,7 @@
// Verify that enabling the ScopedExecutionFence will prevent
// WillScheduleSequence() returning sequence.
-TEST_F(TaskSchedulerTaskTrackerTest,
+TEST_F(ThreadPoolTaskTrackerTest,
WillScheduleSequenceWithScopedExecutionFence) {
TaskTraits default_traits = {};
Task task_a(FROM_HERE, DoNothing(), TimeDelta());
@@ -1307,7 +1305,7 @@
// it was assigned if there is a preempted best-effort sequence with an earlier
// sequence time (compared to the next task in the sequence assigned to
// RunAndPopNextTask()).
-TEST_F(TaskSchedulerTaskTrackerTest,
+TEST_F(ThreadPoolTaskTrackerTest,
RunNextBestEffortTaskWithEarlierPendingBestEffortTask) {
constexpr int kMaxNumScheduledBestEffortSequences = 1;
TaskTracker tracker("Test", kMaxNumScheduledBestEffortSequences);
@@ -1379,7 +1377,7 @@
// Verify that preempted best-effort sequences are scheduled when shutdown
// starts.
-TEST_F(TaskSchedulerTaskTrackerTest,
+TEST_F(ThreadPoolTaskTrackerTest,
SchedulePreemptedBestEffortSequencesOnShutdown) {
constexpr int kMaxNumScheduledBestEffortSequences = 0;
TaskTracker tracker("Test", kMaxNumScheduledBestEffortSequences);
@@ -1388,8 +1386,7 @@
// Simulate scheduling sequences. TaskTracker should prevent this.
std::vector<scoped_refptr<Sequence>> preempted_sequences;
for (int i = 0; i < 3; ++i) {
- Task task(FROM_HERE, DoNothing(),
- TimeDelta());
+ Task task(FROM_HERE, DoNothing(), TimeDelta());
EXPECT_TRUE(
tracker.WillPostTask(&task, TaskShutdownBehavior::BLOCK_SHUTDOWN));
scoped_refptr<Sequence> sequence = test::CreateSequenceWithTask(
@@ -1483,7 +1480,7 @@
// Verify that AssertIOAllowed() succeeds only for a WithBaseSyncPrimitives()
// task.
-TEST(TaskSchedulerTaskTrackerWaitAllowedTest, WaitAllowed) {
+TEST(ThreadPoolTaskTrackerWaitAllowedTest, WaitAllowed) {
// Run the test on the separate thread since it is not possible to reset the
// "wait allowed" bit of a thread without being a friend of
// ThreadRestrictions.
@@ -1493,9 +1490,9 @@
wait_allowed_test_thread.Join();
}
-// Verify that TaskScheduler.TaskLatency.* histograms are correctly recorded
+// Verify that ThreadPool.TaskLatency.* histograms are correctly recorded
// when a task runs.
-TEST(TaskSchedulerTaskTrackerHistogramTest, TaskLatency) {
+TEST(ThreadPoolTaskTrackerHistogramTest, TaskLatency) {
auto statistics_recorder = StatisticsRecorder::CreateTemporaryForTesting();
TaskTracker tracker("Test");
@@ -1506,31 +1503,31 @@
const char* const expected_histogram;
} static constexpr kTests[] = {
{{TaskPriority::BEST_EFFORT},
- "TaskScheduler.TaskLatencyMicroseconds.Test."
+ "ThreadPool.TaskLatencyMicroseconds.Test."
"BackgroundTaskPriority"},
{{MayBlock(), TaskPriority::BEST_EFFORT},
- "TaskScheduler.TaskLatencyMicroseconds.Test."
+ "ThreadPool.TaskLatencyMicroseconds.Test."
"BackgroundTaskPriority_MayBlock"},
{{WithBaseSyncPrimitives(), TaskPriority::BEST_EFFORT},
- "TaskScheduler.TaskLatencyMicroseconds.Test."
+ "ThreadPool.TaskLatencyMicroseconds.Test."
"BackgroundTaskPriority_MayBlock"},
{{TaskPriority::USER_VISIBLE},
- "TaskScheduler.TaskLatencyMicroseconds.Test."
+ "ThreadPool.TaskLatencyMicroseconds.Test."
"UserVisibleTaskPriority"},
{{MayBlock(), TaskPriority::USER_VISIBLE},
- "TaskScheduler.TaskLatencyMicroseconds.Test."
+ "ThreadPool.TaskLatencyMicroseconds.Test."
"UserVisibleTaskPriority_MayBlock"},
{{WithBaseSyncPrimitives(), TaskPriority::USER_VISIBLE},
- "TaskScheduler.TaskLatencyMicroseconds.Test."
+ "ThreadPool.TaskLatencyMicroseconds.Test."
"UserVisibleTaskPriority_MayBlock"},
{{TaskPriority::USER_BLOCKING},
- "TaskScheduler.TaskLatencyMicroseconds.Test."
+ "ThreadPool.TaskLatencyMicroseconds.Test."
"UserBlockingTaskPriority"},
{{MayBlock(), TaskPriority::USER_BLOCKING},
- "TaskScheduler.TaskLatencyMicroseconds.Test."
+ "ThreadPool.TaskLatencyMicroseconds.Test."
"UserBlockingTaskPriority_MayBlock"},
{{WithBaseSyncPrimitives(), TaskPriority::USER_BLOCKING},
- "TaskScheduler.TaskLatencyMicroseconds.Test."
+ "ThreadPool.TaskLatencyMicroseconds.Test."
"UserBlockingTaskPriority_MayBlock"}};
for (const auto& test : kTests) {
diff --git a/base/task/task_scheduler/test_task_factory.cc b/base/task/thread_pool/test_task_factory.cc
similarity index 98%
rename from base/task/task_scheduler/test_task_factory.cc
rename to base/task/thread_pool/test_task_factory.cc
index 9365c6a..1650ff3 100644
--- a/base/task/task_scheduler/test_task_factory.cc
+++ b/base/task/thread_pool/test_task_factory.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/test_task_factory.h"
+#include "base/task/thread_pool/test_task_factory.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
diff --git a/base/task/task_scheduler/test_task_factory.h b/base/task/thread_pool/test_task_factory.h
similarity index 93%
rename from base/task/task_scheduler/test_task_factory.h
rename to base/task/thread_pool/test_task_factory.h
index 3e3d7f9..3dadd107 100644
--- a/base/task/task_scheduler/test_task_factory.h
+++ b/base/task/thread_pool/test_task_factory.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_TEST_TASK_FACTORY_H_
-#define BASE_TASK_TASK_SCHEDULER_TEST_TASK_FACTORY_H_
+#ifndef BASE_TASK_THREAD_POOL_TEST_TASK_FACTORY_H_
+#define BASE_TASK_THREAD_POOL_TEST_TASK_FACTORY_H_
#include <stddef.h>
@@ -14,8 +14,8 @@
#include "base/memory/ref_counted.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
-#include "base/task/task_scheduler/test_utils.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/test_utils.h"
#include "base/task_runner.h"
#include "base/threading/thread_checker_impl.h"
@@ -96,4 +96,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_TEST_TASK_FACTORY_H_
+#endif // BASE_TASK_THREAD_POOL_TEST_TASK_FACTORY_H_
diff --git a/base/task/task_scheduler/test_utils.cc b/base/task/thread_pool/test_utils.cc
similarity index 96%
rename from base/task/task_scheduler/test_utils.cc
rename to base/task/thread_pool/test_utils.cc
index c9e2e57..6eb250c 100644
--- a/base/task/task_scheduler/test_utils.cc
+++ b/base/task/thread_pool/test_utils.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/test_utils.h"
+#include "base/task/thread_pool/test_utils.h"
#include <utility>
#include "base/bind.h"
#include "base/synchronization/condition_variable.h"
-#include "base/task/task_scheduler/scheduler_parallel_task_runner.h"
-#include "base/task/task_scheduler/scheduler_sequenced_task_runner.h"
+#include "base/task/thread_pool/scheduler_parallel_task_runner.h"
+#include "base/task/thread_pool/scheduler_sequenced_task_runner.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/thread_restrictions.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/base/task/task_scheduler/test_utils.h b/base/task/thread_pool/test_utils.h
similarity index 83%
rename from base/task/task_scheduler/test_utils.h
rename to base/task/thread_pool/test_utils.h
index bd82a22..66b0a39d 100644
--- a/base/task/task_scheduler/test_utils.h
+++ b/base/task/thread_pool/test_utils.h
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_TEST_UTILS_H_
-#define BASE_TASK_TASK_SCHEDULER_TEST_UTILS_H_
+#ifndef BASE_TASK_THREAD_POOL_TEST_UTILS_H_
+#define BASE_TASK_THREAD_POOL_TEST_UTILS_H_
-#include "base/task/task_scheduler/delayed_task_manager.h"
-#include "base/task/task_scheduler/scheduler_lock.h"
-#include "base/task/task_scheduler/scheduler_task_runner_delegate.h"
-#include "base/task/task_scheduler/scheduler_worker_observer.h"
-#include "base/task/task_scheduler/scheduler_worker_pool.h"
-#include "base/task/task_scheduler/sequence.h"
-#include "base/task/task_scheduler/task_tracker.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/delayed_task_manager.h"
+#include "base/task/thread_pool/scheduler_lock.h"
+#include "base/task/thread_pool/scheduler_task_runner_delegate.h"
+#include "base/task/thread_pool/scheduler_worker_observer.h"
+#include "base/task/thread_pool/scheduler_worker_pool.h"
+#include "base/task/thread_pool/sequence.h"
+#include "base/task/thread_pool/task_tracker.h"
#include "base/task_runner.h"
#include "base/thread_annotations.h"
#include "build/build_config.h"
@@ -68,13 +68,13 @@
SchedulerWorkerPool* worker_pool_ = nullptr;
};
-// An enumeration of possible task scheduler TaskRunner types. Used to
-// parametrize relevant task_scheduler tests.
+// An enumeration of possible thread pool TaskRunner types. Used to
+// parametrize relevant thread_pool tests.
// TODO(etiennep): Migrate to TaskSourceExecutionMode.
enum class ExecutionMode { PARALLEL, SEQUENCED, SINGLE_THREADED };
// An enumeration of possible pool types. Used to parametrize relevant
-// task_scheduler tests.
+// thread_pool tests.
enum class PoolType {
GENERIC,
#if defined(OS_WIN) || defined(OS_MACOSX)
@@ -114,4 +114,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_TEST_UTILS_H_
+#endif // BASE_TASK_THREAD_POOL_TEST_UTILS_H_
diff --git a/base/task/thread_pool/thread_pool.cc b/base/task/thread_pool/thread_pool.cc
new file mode 100644
index 0000000..a1399d8
--- /dev/null
+++ b/base/task/thread_pool/thread_pool.cc
@@ -0,0 +1,88 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/task/thread_pool/thread_pool.h"
+
+#include <algorithm>
+
+#include "base/logging.h"
+#include "base/memory/ptr_util.h"
+#include "base/system/sys_info.h"
+#include "base/task/thread_pool/scheduler_worker_pool_params.h"
+#include "base/task/thread_pool/thread_pool_impl.h"
+#include "base/threading/platform_thread.h"
+#include "base/time/time.h"
+
+namespace base {
+
+namespace {
+
+// |g_thread_pool| is intentionally leaked on shutdown.
+ThreadPool* g_thread_pool = nullptr;
+
+} // namespace
+
+ThreadPool::InitParams::InitParams(
+ const SchedulerWorkerPoolParams& background_worker_pool_params_in,
+ const SchedulerWorkerPoolParams& foreground_worker_pool_params_in,
+ SharedWorkerPoolEnvironment shared_worker_pool_environment_in)
+ : background_worker_pool_params(background_worker_pool_params_in),
+ foreground_worker_pool_params(foreground_worker_pool_params_in),
+ shared_worker_pool_environment(shared_worker_pool_environment_in) {}
+
+ThreadPool::InitParams::~InitParams() = default;
+
+ThreadPool::ScopedExecutionFence::ScopedExecutionFence() {
+ DCHECK(g_thread_pool);
+ g_thread_pool->SetExecutionFenceEnabled(true);
+}
+
+ThreadPool::ScopedExecutionFence::~ScopedExecutionFence() {
+ DCHECK(g_thread_pool);
+ g_thread_pool->SetExecutionFenceEnabled(false);
+}
+
+#if !defined(OS_NACL)
+// static
+void ThreadPool::CreateAndStartWithDefaultParams(StringPiece name) {
+ Create(name);
+ GetInstance()->StartWithDefaultParams();
+}
+
+void ThreadPool::StartWithDefaultParams() {
+ // Values were chosen so that:
+ // * There are few background threads.
+ // * Background threads never outnumber foreground threads.
+ // * The system is utilized maximally by foreground threads.
+ // * The main thread is assumed to be busy, cap foreground workers at
+ // |num_cores - 1|.
+ const int num_cores = SysInfo::NumberOfProcessors();
+
+ // TODO(etiennep): Change this to 2.
+ constexpr int kBackgroundMaxThreads = 3;
+ const int kForegroundMaxThreads = std::max(3, num_cores - 1);
+
+ constexpr TimeDelta kSuggestedReclaimTime = TimeDelta::FromSeconds(30);
+
+ Start({{kBackgroundMaxThreads, kSuggestedReclaimTime},
+ {kForegroundMaxThreads, kSuggestedReclaimTime}});
+}
+#endif // !defined(OS_NACL)
+
+void ThreadPool::Create(StringPiece name) {
+ SetInstance(std::make_unique<internal::ThreadPoolImpl>(name));
+}
+
+// static
+void ThreadPool::SetInstance(std::unique_ptr<ThreadPool> thread_pool) {
+ delete g_thread_pool;
+ g_thread_pool = thread_pool.release();
+}
+
+// static
+ThreadPool* ThreadPool::GetInstance() {
+ return g_thread_pool;
+}
+
+} // namespace base
diff --git a/base/task/task_scheduler/task_scheduler.h b/base/task/thread_pool/thread_pool.h
similarity index 71%
rename from base/task/task_scheduler/task_scheduler.h
rename to base/task/thread_pool/thread_pool.h
index 185e8536..74e7d264 100644
--- a/base/task/task_scheduler/task_scheduler.h
+++ b/base/task/thread_pool/thread_pool.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_TASK_SCHEDULER_H_
-#define BASE_TASK_TASK_SCHEDULER_TASK_SCHEDULER_H_
+#ifndef BASE_TASK_THREAD_POOL_THREAD_POOL_H_
+#define BASE_TASK_THREAD_POOL_THREAD_POOL_H_
#include <memory>
#include <vector>
@@ -17,8 +17,8 @@
#include "base/strings/string_piece.h"
#include "base/task/single_thread_task_runner_thread_mode.h"
#include "base/task/task_executor.h"
-#include "base/task/task_scheduler/scheduler_worker_pool_params.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/scheduler_worker_pool_params.h"
#include "base/task_runner.h"
#include "base/time/time.h"
#include "build/build_config.h"
@@ -36,20 +36,20 @@
namespace base {
class SchedulerWorkerObserver;
-class TaskSchedulerTestHelpers;
+class ThreadPoolTestHelpers;
-// Interface for a task scheduler and static methods to manage the instance used
+// Interface for a thread pool and static methods to manage the instance used
// by the post_task.h API.
//
-// The task scheduler doesn't create threads until Start() is called. Tasks can
+// The thread pool doesn't create threads until Start() is called. Tasks can
// be posted at any time but will not run until after Start() is called.
//
// The instance methods of this class are thread-safe.
//
-// Note: All TaskScheduler users should go through base/task/post_task.h instead
+// Note: All ThreadPool users should go through base/task/post_task.h instead
// of this interface except for the one callsite per process which manages the
// process's instance.
-class BASE_EXPORT TaskScheduler : public TaskExecutor {
+class BASE_EXPORT ThreadPool : public TaskExecutor {
public:
struct BASE_EXPORT InitParams {
enum class SharedWorkerPoolEnvironment {
@@ -74,7 +74,7 @@
};
// A ScopedExecutionFence prevents any new task from being scheduled in
- // TaskScheduler within its scope. Upon its destruction, all tasks that were
+ // ThreadPool within its scope. Upon its destruction, all tasks that were
// preeempted are released. Note: the constructor of ScopedExecutionFence will
// not wait for currently running tasks (as they were posted before entering
// this scope and do not violate the contract; some of them could be
@@ -88,12 +88,12 @@
DISALLOW_COPY_AND_ASSIGN(ScopedExecutionFence);
};
- // Destroying a TaskScheduler is not allowed in production; it is always
+ // Destroying a ThreadPool is not allowed in production; it is always
// leaked. In tests, it should only be destroyed after JoinForTesting() has
// returned.
- ~TaskScheduler() override = default;
+ ~ThreadPool() override = default;
- // Allows the task scheduler to create threads and run tasks following the
+ // Allows the thread pool to create threads and run tasks following the
// |init_params| specification.
//
// If specified, |scheduler_worker_observer| will be notified when a worker
@@ -105,7 +105,7 @@
const InitParams& init_params,
SchedulerWorkerObserver* scheduler_worker_observer = nullptr) = 0;
- // Synchronously shuts down the scheduler. Once this is called, only tasks
+ // Synchronously shuts down the thread pool. Once this is called, only tasks
// posted with the BLOCK_SHUTDOWN behavior will be run. When this returns:
// - All SKIP_ON_SHUTDOWN tasks that were already running have completed their
// execution.
@@ -131,29 +131,29 @@
virtual void FlushAsyncForTesting(OnceClosure flush_callback) = 0;
// Joins all threads. Tasks that are already running are allowed to complete
- // their execution. This can only be called once. Using this task scheduler
+ // their execution. This can only be called once. Using this thread pool
// instance to create task runners or post tasks is not permitted during or
// after this call.
virtual void JoinForTesting() = 0;
-// CreateAndStartWithDefaultParams(), Create(), and SetInstance() register a
-// TaskScheduler to handle tasks posted through the post_task.h API for this
-// process.
-//
-// Processes that need to initialize TaskScheduler with custom params or that
-// need to allow tasks to be posted before the TaskScheduler creates its
-// threads should use Create() followed by Start(). Other processes can use
-// CreateAndStartWithDefaultParams().
-//
-// A registered TaskScheduler is only deleted when a new TaskScheduler is
-// registered. The last registered TaskScheduler is leaked on shutdown. The
-// methods below must not be called when TaskRunners created by a previous
-// TaskScheduler are still alive. The methods are not thread-safe; proper
-// synchronization is required to use the post_task.h API after registering a
-// new TaskScheduler.
+ // CreateAndStartWithDefaultParams(), Create(), and SetInstance() register a
+ // ThreadPool to handle tasks posted through the post_task.h API for this
+ // process.
+ //
+ // Processes that need to initialize ThreadPool with custom params or that
+ // need to allow tasks to be posted before the ThreadPool creates its
+ // threads should use Create() followed by Start(). Other processes can use
+ // CreateAndStartWithDefaultParams().
+ //
+ // A registered ThreadPool is only deleted when a new ThreadPool is
+ // registered. The last registered ThreadPool is leaked on shutdown. The
+ // methods below must not be called when TaskRunners created by a previous
+ // ThreadPool are still alive. The methods are not thread-safe; proper
+ // synchronization is required to use the post_task.h API after registering a
+ // new ThreadPool.
#if !defined(OS_NACL)
- // Creates and starts a task scheduler using default params. |name| is used to
+ // Creates and starts a thread pool using default params. |name| is used to
// label histograms, it must not be empty. It should identify the component
// that calls this. Start() is called by this method; it is invalid to call it
// again afterwards. CHECKs on failure. For tests, prefer
@@ -165,39 +165,39 @@
void StartWithDefaultParams();
#endif // !defined(OS_NACL)
- // Creates a ready to start task scheduler. |name| is used to label
+ // Creates a ready to start thread pool. |name| is used to label
// histograms, it must not be empty. It should identify the component that
- // creates the TaskScheduler. The task scheduler doesn't create threads until
+ // creates the ThreadPool. The thread pool doesn't create threads until
// Start() is called. Tasks can be posted at any time but will not run until
// after Start() is called. For tests, prefer
// base::test::ScopedTaskEnvironment (ensures isolation).
static void Create(StringPiece name);
- // Registers |task_scheduler| to handle tasks posted through the post_task.h
+ // Registers |thread_pool| to handle tasks posted through the post_task.h
// API for this process. For tests, prefer base::test::ScopedTaskEnvironment
// (ensures isolation).
- static void SetInstance(std::unique_ptr<TaskScheduler> task_scheduler);
+ static void SetInstance(std::unique_ptr<ThreadPool> thread_pool);
- // Retrieve the TaskScheduler set via SetInstance() or
- // CreateAndSet(Simple|Default)TaskScheduler(). This should be used very
- // rarely; most users of TaskScheduler should use the post_task.h API. In
+ // Retrieve the ThreadPool set via SetInstance() or
+ // CreateAndSet(Simple|Default)ThreadPool(). This should be used very
+ // rarely; most users of ThreadPool should use the post_task.h API. In
// particular, refrain from doing
- // if (!TaskScheduler::GetInstance()) {
- // TaskScheduler::SetInstance(...);
+ // if (!ThreadPool::GetInstance()) {
+ // ThreadPool::SetInstance(...);
// base::PostTask(...);
// }
// instead make sure to SetInstance() early in one determinstic place in the
// process' initialization phase.
- // In doubt, consult with //base/task/task_scheduler/OWNERS.
- static TaskScheduler* GetInstance();
+ // In doubt, consult with //base/task/thread_pool/OWNERS.
+ static ThreadPool* GetInstance();
private:
- friend class TaskSchedulerTestHelpers;
+ friend class ThreadPoolTestHelpers;
friend class gin::V8Platform;
friend class content::BrowserMainLoopTest_CreateThreadsInSingleProcess_Test;
// Returns the maximum number of non-single-threaded non-blocked tasks posted
- // with |traits| that can run concurrently in this TaskScheduler. |traits|
+ // with |traits| that can run concurrently in this ThreadPool. |traits|
// can't contain TaskPriority::BEST_EFFORT.
//
// Do not use this method. To process n items, post n tasks that each process
@@ -215,4 +215,4 @@
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_TASK_SCHEDULER_H_
+#endif // BASE_TASK_THREAD_POOL_THREAD_POOL_H_
diff --git a/base/task/task_scheduler/task_scheduler_impl.cc b/base/task/thread_pool/thread_pool_impl.cc
similarity index 78%
rename from base/task/task_scheduler/task_scheduler_impl.cc
rename to base/task/thread_pool/thread_pool_impl.cc
index 7acd6f68..8798338f 100644
--- a/base/task/task_scheduler/task_scheduler_impl.cc
+++ b/base/task/thread_pool/thread_pool_impl.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/task_scheduler_impl.h"
+#include "base/task/thread_pool/thread_pool_impl.h"
#include <algorithm>
#include <string>
@@ -17,13 +17,13 @@
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/task/task_features.h"
-#include "base/task/task_scheduler/scheduler_parallel_task_runner.h"
-#include "base/task/task_scheduler/scheduler_sequenced_task_runner.h"
-#include "base/task/task_scheduler/scheduler_worker_pool_params.h"
-#include "base/task/task_scheduler/sequence.h"
-#include "base/task/task_scheduler/sequence_sort_key.h"
-#include "base/task/task_scheduler/service_thread.h"
-#include "base/task/task_scheduler/task.h"
+#include "base/task/thread_pool/scheduler_parallel_task_runner.h"
+#include "base/task/thread_pool/scheduler_sequenced_task_runner.h"
+#include "base/task/thread_pool/scheduler_worker_pool_params.h"
+#include "base/task/thread_pool/sequence.h"
+#include "base/task/thread_pool/sequence_sort_key.h"
+#include "base/task/thread_pool/service_thread.h"
+#include "base/task/thread_pool/task.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
@@ -40,17 +40,16 @@
} // namespace
-TaskSchedulerImpl::TaskSchedulerImpl(StringPiece histogram_label)
- : TaskSchedulerImpl(histogram_label,
- std::make_unique<TaskTrackerImpl>(histogram_label)) {}
+ThreadPoolImpl::ThreadPoolImpl(StringPiece histogram_label)
+ : ThreadPoolImpl(histogram_label,
+ std::make_unique<TaskTrackerImpl>(histogram_label)) {}
-TaskSchedulerImpl::TaskSchedulerImpl(
- StringPiece histogram_label,
- std::unique_ptr<TaskTrackerImpl> task_tracker)
+ThreadPoolImpl::ThreadPoolImpl(StringPiece histogram_label,
+ std::unique_ptr<TaskTrackerImpl> task_tracker)
: task_tracker_(std::move(task_tracker)),
service_thread_(std::make_unique<ServiceThread>(
task_tracker_.get(),
- BindRepeating(&TaskSchedulerImpl::ReportHeartbeatMetrics,
+ BindRepeating(&ThreadPoolImpl::ReportHeartbeatMetrics,
Unretained(this)))),
single_thread_task_runner_manager_(task_tracker_->GetTrackedRef(),
&delayed_task_manager_),
@@ -75,7 +74,7 @@
}
}
-TaskSchedulerImpl::~TaskSchedulerImpl() {
+ThreadPoolImpl::~ThreadPoolImpl() {
#if DCHECK_IS_ON()
DCHECK(join_for_testing_returned_.IsSet());
#endif
@@ -88,13 +87,12 @@
#endif
}
-void TaskSchedulerImpl::Start(
- const TaskScheduler::InitParams& init_params,
- SchedulerWorkerObserver* scheduler_worker_observer) {
+void ThreadPoolImpl::Start(const ThreadPool::InitParams& init_params,
+ SchedulerWorkerObserver* scheduler_worker_observer) {
internal::InitializeThreadPrioritiesFeature();
// This is set in Start() and not in the constructor because variation params
- // are usually not ready when TaskSchedulerImpl is instantiated in a process.
+ // are usually not ready when ThreadPoolImpl is instantiated in a process.
if (FeatureList::IsEnabled(kAllTasksUserBlocking))
all_tasks_user_blocking_.Set();
@@ -174,10 +172,10 @@
}
}
-bool TaskSchedulerImpl::PostDelayedTaskWithTraits(const Location& from_here,
- const TaskTraits& traits,
- OnceClosure task,
- TimeDelta delay) {
+bool ThreadPoolImpl::PostDelayedTaskWithTraits(const Location& from_here,
+ const TaskTraits& traits,
+ OnceClosure task,
+ TimeDelta delay) {
// Post |task| as part of a one-off single-task Sequence.
const TaskTraits new_traits = SetUserBlockingPriorityIfNeeded(traits);
return PostTaskWithSequence(
@@ -186,21 +184,20 @@
TaskSourceExecutionMode::kParallel));
}
-scoped_refptr<TaskRunner> TaskSchedulerImpl::CreateTaskRunnerWithTraits(
+scoped_refptr<TaskRunner> ThreadPoolImpl::CreateTaskRunnerWithTraits(
const TaskTraits& traits) {
const TaskTraits new_traits = SetUserBlockingPriorityIfNeeded(traits);
return MakeRefCounted<SchedulerParallelTaskRunner>(new_traits, this);
}
scoped_refptr<SequencedTaskRunner>
-TaskSchedulerImpl::CreateSequencedTaskRunnerWithTraits(
- const TaskTraits& traits) {
+ThreadPoolImpl::CreateSequencedTaskRunnerWithTraits(const TaskTraits& traits) {
const TaskTraits new_traits = SetUserBlockingPriorityIfNeeded(traits);
return MakeRefCounted<SchedulerSequencedTaskRunner>(new_traits, this);
}
scoped_refptr<SingleThreadTaskRunner>
-TaskSchedulerImpl::CreateSingleThreadTaskRunnerWithTraits(
+ThreadPoolImpl::CreateSingleThreadTaskRunnerWithTraits(
const TaskTraits& traits,
SingleThreadTaskRunnerThreadMode thread_mode) {
return single_thread_task_runner_manager_
@@ -210,7 +207,7 @@
#if defined(OS_WIN)
scoped_refptr<SingleThreadTaskRunner>
-TaskSchedulerImpl::CreateCOMSTATaskRunnerWithTraits(
+ThreadPoolImpl::CreateCOMSTATaskRunnerWithTraits(
const TaskTraits& traits,
SingleThreadTaskRunnerThreadMode thread_mode) {
return single_thread_task_runner_manager_.CreateCOMSTATaskRunnerWithTraits(
@@ -219,13 +216,13 @@
#endif // defined(OS_WIN)
scoped_refptr<UpdateableSequencedTaskRunner>
-TaskSchedulerImpl::CreateUpdateableSequencedTaskRunnerWithTraitsForTesting(
+ThreadPoolImpl::CreateUpdateableSequencedTaskRunnerWithTraitsForTesting(
const TaskTraits& traits) {
const TaskTraits new_traits = SetUserBlockingPriorityIfNeeded(traits);
return MakeRefCounted<SchedulerSequencedTaskRunner>(new_traits, this);
}
-int TaskSchedulerImpl::GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
+int ThreadPoolImpl::GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
const TaskTraits& traits) const {
// This method does not support getting the maximum number of BEST_EFFORT
// tasks that can run concurrently in a pool.
@@ -234,19 +231,19 @@
->GetMaxConcurrentNonBlockedTasksDeprecated();
}
-void TaskSchedulerImpl::Shutdown() {
+void ThreadPoolImpl::Shutdown() {
task_tracker_->Shutdown();
}
-void TaskSchedulerImpl::FlushForTesting() {
+void ThreadPoolImpl::FlushForTesting() {
task_tracker_->FlushForTesting();
}
-void TaskSchedulerImpl::FlushAsyncForTesting(OnceClosure flush_callback) {
+void ThreadPoolImpl::FlushAsyncForTesting(OnceClosure flush_callback) {
task_tracker_->FlushAsyncForTesting(std::move(flush_callback));
}
-void TaskSchedulerImpl::JoinForTesting() {
+void ThreadPoolImpl::JoinForTesting() {
#if DCHECK_IS_ON()
DCHECK(!join_for_testing_returned_.IsSet());
#endif
@@ -264,12 +261,12 @@
#endif
}
-void TaskSchedulerImpl::SetExecutionFenceEnabled(bool execution_fence_enabled) {
+void ThreadPoolImpl::SetExecutionFenceEnabled(bool execution_fence_enabled) {
task_tracker_->SetExecutionFenceEnabled(execution_fence_enabled);
}
-bool TaskSchedulerImpl::PostTaskWithSequence(Task task,
- scoped_refptr<Sequence> sequence) {
+bool ThreadPoolImpl::PostTaskWithSequence(Task task,
+ scoped_refptr<Sequence> sequence) {
// Use CHECK instead of DCHECK to crash earlier. See http://crbug.com/711167
// for details.
CHECK(task.task);
@@ -292,12 +289,12 @@
std::move(task),
BindOnce(
[](scoped_refptr<Sequence> sequence,
- TaskSchedulerImpl* task_scheduler_impl, Task task) {
+ ThreadPoolImpl* thread_pool_impl, Task task) {
auto sequence_and_transaction =
SequenceAndTransaction::FromSequence(std::move(sequence));
const TaskTraits traits =
sequence_and_transaction.transaction.traits();
- task_scheduler_impl->GetWorkerPoolForTraits(traits)
+ thread_pool_impl->GetWorkerPoolForTraits(traits)
->PostTaskWithSequenceNow(
std::move(task), std::move(sequence_and_transaction));
},
@@ -308,13 +305,12 @@
return true;
}
-bool TaskSchedulerImpl::IsRunningPoolWithTraits(
- const TaskTraits& traits) const {
+bool ThreadPoolImpl::IsRunningPoolWithTraits(const TaskTraits& traits) const {
return GetWorkerPoolForTraits(traits)->IsBoundToCurrentThread();
}
-void TaskSchedulerImpl::UpdatePriority(scoped_refptr<Sequence> sequence,
- TaskPriority priority) {
+void ThreadPoolImpl::UpdatePriority(scoped_refptr<Sequence> sequence,
+ TaskPriority priority) {
auto sequence_and_transaction =
SequenceAndTransaction::FromSequence(std::move(sequence));
@@ -340,12 +336,12 @@
}
}
-const SchedulerWorkerPool* TaskSchedulerImpl::GetWorkerPoolForTraits(
+const SchedulerWorkerPool* ThreadPoolImpl::GetWorkerPoolForTraits(
const TaskTraits& traits) const {
- return const_cast<TaskSchedulerImpl*>(this)->GetWorkerPoolForTraits(traits);
+ return const_cast<ThreadPoolImpl*>(this)->GetWorkerPoolForTraits(traits);
}
-SchedulerWorkerPool* TaskSchedulerImpl::GetWorkerPoolForTraits(
+SchedulerWorkerPool* ThreadPoolImpl::GetWorkerPoolForTraits(
const TaskTraits& traits) {
if (traits.priority() == TaskPriority::BEST_EFFORT &&
background_pool_.has_value()) {
@@ -355,11 +351,11 @@
return GetForegroundWorkerPool();
}
-const SchedulerWorkerPool* TaskSchedulerImpl::GetForegroundWorkerPool() const {
- return const_cast<TaskSchedulerImpl*>(this)->GetForegroundWorkerPool();
+const SchedulerWorkerPool* ThreadPoolImpl::GetForegroundWorkerPool() const {
+ return const_cast<ThreadPoolImpl*>(this)->GetForegroundWorkerPool();
}
-SchedulerWorkerPool* TaskSchedulerImpl::GetForegroundWorkerPool() {
+SchedulerWorkerPool* ThreadPoolImpl::GetForegroundWorkerPool() {
#if defined(OS_WIN) || defined(OS_MACOSX)
if (native_foreground_pool_) {
return &native_foreground_pool_.value();
@@ -368,14 +364,14 @@
return &foreground_pool_.value();
}
-TaskTraits TaskSchedulerImpl::SetUserBlockingPriorityIfNeeded(
+TaskTraits ThreadPoolImpl::SetUserBlockingPriorityIfNeeded(
TaskTraits traits) const {
if (all_tasks_user_blocking_.IsSet())
traits.UpdatePriority(TaskPriority::USER_BLOCKING);
return traits;
}
-void TaskSchedulerImpl::ReportHeartbeatMetrics() const {
+void ThreadPoolImpl::ReportHeartbeatMetrics() const {
GetForegroundWorkerPool()->ReportHeartbeatMetrics();
if (background_pool_.has_value())
background_pool_->ReportHeartbeatMetrics();
diff --git a/base/task/task_scheduler/task_scheduler_impl.h b/base/task/thread_pool/thread_pool_impl.h
similarity index 74%
rename from base/task/task_scheduler/task_scheduler_impl.h
rename to base/task/thread_pool/thread_pool_impl.h
index adad3a4..f838325d 100644
--- a/base/task/task_scheduler/task_scheduler_impl.h
+++ b/base/task/thread_pool/thread_pool_impl.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
-#define BASE_TASK_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
+#ifndef BASE_TASK_THREAD_POOL_THREAD_POOL_IMPL_H_
+#define BASE_TASK_THREAD_POOL_THREAD_POOL_IMPL_H_
#include <memory>
#include <vector>
@@ -17,28 +17,28 @@
#include "base/strings/string_piece.h"
#include "base/synchronization/atomic_flag.h"
#include "base/task/single_thread_task_runner_thread_mode.h"
-#include "base/task/task_scheduler/delayed_task_manager.h"
-#include "base/task/task_scheduler/environment_config.h"
-#include "base/task/task_scheduler/scheduler_single_thread_task_runner_manager.h"
-#include "base/task/task_scheduler/scheduler_task_runner_delegate.h"
-#include "base/task/task_scheduler/scheduler_worker_pool_impl.h"
-#include "base/task/task_scheduler/task_scheduler.h"
-#include "base/task/task_scheduler/task_tracker.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/delayed_task_manager.h"
+#include "base/task/thread_pool/environment_config.h"
+#include "base/task/thread_pool/scheduler_single_thread_task_runner_manager.h"
+#include "base/task/thread_pool/scheduler_task_runner_delegate.h"
+#include "base/task/thread_pool/scheduler_worker_pool_impl.h"
+#include "base/task/thread_pool/task_tracker.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/updateable_sequenced_task_runner.h"
#include "build/build_config.h"
#if defined(OS_POSIX) && !defined(OS_NACL_SFI)
-#include "base/task/task_scheduler/task_tracker_posix.h"
+#include "base/task/thread_pool/task_tracker_posix.h"
#endif
#if defined(OS_WIN)
-#include "base/task/task_scheduler/platform_native_worker_pool_win.h"
+#include "base/task/thread_pool/platform_native_worker_pool_win.h"
#include "base/win/com_init_check_hook.h"
#endif
#if defined(OS_MACOSX)
-#include "base/task/task_scheduler/platform_native_worker_pool_mac.h"
+#include "base/task/thread_pool/platform_native_worker_pool_mac.h"
#endif
namespace base {
@@ -47,10 +47,10 @@
namespace internal {
-// Default TaskScheduler implementation. This class is thread-safe.
-class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler,
- public SchedulerWorkerPool::Delegate,
- public SchedulerTaskRunnerDelegate {
+// Default ThreadPool implementation. This class is thread-safe.
+class BASE_EXPORT ThreadPoolImpl : public ThreadPool,
+ public SchedulerWorkerPool::Delegate,
+ public SchedulerTaskRunnerDelegate {
public:
using TaskTrackerImpl =
#if defined(OS_POSIX) && !defined(OS_NACL_SFI)
@@ -59,18 +59,18 @@
TaskTracker;
#endif
- // Creates a TaskSchedulerImpl with a production TaskTracker.
+ // Creates a ThreadPoolImpl with a production TaskTracker.
//|histogram_label| is used to label histograms, it must not be empty.
- explicit TaskSchedulerImpl(StringPiece histogram_label);
+ explicit ThreadPoolImpl(StringPiece histogram_label);
- // For testing only. Creates a TaskSchedulerImpl with a custom TaskTracker.
- TaskSchedulerImpl(StringPiece histogram_label,
- std::unique_ptr<TaskTrackerImpl> task_tracker);
+ // For testing only. Creates a ThreadPoolImpl with a custom TaskTracker.
+ ThreadPoolImpl(StringPiece histogram_label,
+ std::unique_ptr<TaskTrackerImpl> task_tracker);
- ~TaskSchedulerImpl() override;
+ ~ThreadPoolImpl() override;
- // TaskScheduler:
- void Start(const TaskScheduler::InitParams& init_params,
+ // ThreadPool:
+ void Start(const ThreadPool::InitParams& init_params,
SchedulerWorkerObserver* scheduler_worker_observer) override;
int GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
const TaskTraits& traits) const override;
@@ -160,10 +160,10 @@
TrackedRefFactory<SchedulerWorkerPool::Delegate> tracked_ref_factory_;
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolImpl);
};
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
+#endif // BASE_TASK_THREAD_POOL_THREAD_POOL_IMPL_H_
diff --git a/base/task/task_scheduler/task_scheduler_impl_unittest.cc b/base/task/thread_pool/thread_pool_impl_unittest.cc
similarity index 80%
rename from base/task/task_scheduler/task_scheduler_impl_unittest.cc
rename to base/task/thread_pool/thread_pool_impl_unittest.cc
index f5c710ef..3f0478e 100644
--- a/base/task/task_scheduler/task_scheduler_impl_unittest.cc
+++ b/base/task/thread_pool/thread_pool_impl_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/task_scheduler_impl.h"
+#include "base/task/thread_pool/thread_pool_impl.h"
#include <stddef.h>
@@ -21,12 +21,12 @@
#include "base/metrics/field_trial_params.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/task_features.h"
-#include "base/task/task_scheduler/environment_config.h"
-#include "base/task/task_scheduler/scheduler_worker_observer.h"
-#include "base/task/task_scheduler/scheduler_worker_pool_params.h"
-#include "base/task/task_scheduler/test_task_factory.h"
-#include "base/task/task_scheduler/test_utils.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/environment_config.h"
+#include "base/task/thread_pool/scheduler_worker_observer.h"
+#include "base/task/thread_pool/scheduler_worker_pool_params.h"
+#include "base/task/thread_pool/test_task_factory.h"
+#include "base/task/thread_pool/test_utils.h"
#include "base/test/bind_test_util.h"
#include "base/test/gtest_util.h"
#include "base/test/scoped_feature_list.h"
@@ -59,10 +59,10 @@
namespace {
-struct TaskSchedulerImplTestParams {
- TaskSchedulerImplTestParams(const TaskTraits& traits,
- test::ExecutionMode execution_mode,
- test::PoolType pool_type)
+struct ThreadPoolImplTestParams {
+ ThreadPoolImplTestParams(const TaskTraits& traits,
+ test::ExecutionMode execution_mode,
+ test::PoolType pool_type)
: traits(traits), execution_mode(execution_mode), pool_type(pool_type) {}
TaskTraits traits;
@@ -109,7 +109,7 @@
#endif
// Verify that the thread the task is running on is named as expected.
- EXPECT_NE(std::string::npos, current_thread_name.find("TaskScheduler"));
+ EXPECT_NE(std::string::npos, current_thread_name.find("ThreadPool"));
if (is_single_threaded) {
// For now, single-threaded best-effort tasks run on their own threads.
@@ -164,18 +164,18 @@
}
scoped_refptr<TaskRunner> CreateTaskRunnerWithTraitsAndExecutionMode(
- TaskScheduler* scheduler,
+ ThreadPool* thread_pool,
const TaskTraits& traits,
test::ExecutionMode execution_mode,
SingleThreadTaskRunnerThreadMode default_single_thread_task_runner_mode =
SingleThreadTaskRunnerThreadMode::SHARED) {
switch (execution_mode) {
case test::ExecutionMode::PARALLEL:
- return scheduler->CreateTaskRunnerWithTraits(traits);
+ return thread_pool->CreateTaskRunnerWithTraits(traits);
case test::ExecutionMode::SEQUENCED:
- return scheduler->CreateSequencedTaskRunnerWithTraits(traits);
+ return thread_pool->CreateSequencedTaskRunnerWithTraits(traits);
case test::ExecutionMode::SINGLE_THREADED: {
- return scheduler->CreateSingleThreadTaskRunnerWithTraits(
+ return thread_pool->CreateSingleThreadTaskRunnerWithTraits(
traits, default_single_thread_task_runner_mode);
}
}
@@ -185,16 +185,16 @@
class ThreadPostingTasks : public SimpleThread {
public:
- // Creates a thread that posts Tasks to |scheduler| with |traits| and
+ // Creates a thread that posts Tasks to |thread_pool| with |traits| and
// |execution_mode|.
- ThreadPostingTasks(TaskSchedulerImpl* scheduler,
+ ThreadPostingTasks(ThreadPoolImpl* thread_pool,
const TaskTraits& traits,
test::PoolType pool_type,
test::ExecutionMode execution_mode)
: SimpleThread("ThreadPostingTasks"),
traits_(traits),
pool_type_(pool_type),
- factory_(CreateTaskRunnerWithTraitsAndExecutionMode(scheduler,
+ factory_(CreateTaskRunnerWithTraitsAndExecutionMode(thread_pool,
traits,
execution_mode),
execution_mode) {}
@@ -219,10 +219,10 @@
DISALLOW_COPY_AND_ASSIGN(ThreadPostingTasks);
};
-// Returns a vector with a TaskSchedulerImplTestParams for each valid
+// Returns a vector with a ThreadPoolImplTestParams for each valid
// combination of {PoolType, ExecutionMode, TaskPriority, MayBlock()}.
-std::vector<TaskSchedulerImplTestParams> GetTaskSchedulerImplTestParams() {
- std::vector<TaskSchedulerImplTestParams> params;
+std::vector<ThreadPoolImplTestParams> GetThreadPoolImplTestParams() {
+ std::vector<ThreadPoolImplTestParams> params;
const test::ExecutionMode execution_modes[] = {
test::ExecutionMode::PARALLEL, test::ExecutionMode::SEQUENCED,
@@ -242,9 +242,9 @@
++priority_index) {
const TaskPriority priority = static_cast<TaskPriority>(priority_index);
params.push_back(
- TaskSchedulerImplTestParams({priority}, execution_mode, pool_type));
- params.push_back(TaskSchedulerImplTestParams(
- {priority, MayBlock()}, execution_mode, pool_type));
+ ThreadPoolImplTestParams({priority}, execution_mode, pool_type));
+ params.push_back(ThreadPoolImplTestParams({priority, MayBlock()},
+ execution_mode, pool_type));
}
}
}
@@ -252,10 +252,10 @@
return params;
}
-class TaskSchedulerImplTest
- : public testing::TestWithParam<TaskSchedulerImplTestParams> {
+class ThreadPoolImplTest
+ : public testing::TestWithParam<ThreadPoolImplTestParams> {
protected:
- TaskSchedulerImplTest() : scheduler_("Test") {}
+ ThreadPoolImplTest() : thread_pool_("Test") {}
void EnableAllTasksUserBlocking() {
should_enable_all_tasks_user_blocking_ = true;
@@ -266,27 +266,27 @@
scheduler_worker_observer_ = scheduler_worker_observer;
}
- void StartTaskScheduler(TimeDelta reclaim_time = TimeDelta::FromSeconds(30)) {
+ void StartThreadPool(TimeDelta reclaim_time = TimeDelta::FromSeconds(30)) {
constexpr int kMaxNumBackgroundThreads = 1;
constexpr int kMaxNumForegroundThreads = 4;
SetupFeatures();
- scheduler_.Start({{kMaxNumBackgroundThreads, reclaim_time},
- {kMaxNumForegroundThreads, reclaim_time}},
- scheduler_worker_observer_);
+ thread_pool_.Start({{kMaxNumBackgroundThreads, reclaim_time},
+ {kMaxNumForegroundThreads, reclaim_time}},
+ scheduler_worker_observer_);
}
void TearDown() override {
if (did_tear_down_)
return;
- scheduler_.FlushForTesting();
- scheduler_.JoinForTesting();
+ thread_pool_.FlushForTesting();
+ thread_pool_.JoinForTesting();
did_tear_down_ = true;
}
- TaskSchedulerImpl scheduler_;
+ ThreadPoolImpl thread_pool_;
private:
void SetupFeatures() {
@@ -309,7 +309,7 @@
bool did_tear_down_ = false;
bool should_enable_all_tasks_user_blocking_ = false;
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImplTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolImplTest);
};
} // namespace
@@ -317,10 +317,10 @@
// Verifies that a Task posted via PostDelayedTaskWithTraits with parameterized
// TaskTraits and no delay runs on a thread with the expected priority and I/O
// restrictions. The ExecutionMode parameter is ignored by this test.
-TEST_P(TaskSchedulerImplTest, PostDelayedTaskWithTraitsNoDelay) {
- StartTaskScheduler();
+TEST_P(ThreadPoolImplTest, PostDelayedTaskWithTraitsNoDelay) {
+ StartThreadPool();
WaitableEvent task_ran;
- scheduler_.PostDelayedTaskWithTraits(
+ thread_pool_.PostDelayedTaskWithTraits(
FROM_HERE, GetParam().traits,
BindOnce(&VerifyTaskEnvironmentAndSignalEvent, GetParam().traits,
GetParam().pool_type, Unretained(&task_ran)),
@@ -332,10 +332,10 @@
// TaskTraits and a non-zero delay runs on a thread with the expected priority
// and I/O restrictions after the delay expires. The ExecutionMode parameter is
// ignored by this test.
-TEST_P(TaskSchedulerImplTest, PostDelayedTaskWithTraitsWithDelay) {
- StartTaskScheduler();
+TEST_P(ThreadPoolImplTest, PostDelayedTaskWithTraitsWithDelay) {
+ StartThreadPool();
WaitableEvent task_ran;
- scheduler_.PostDelayedTaskWithTraits(
+ thread_pool_.PostDelayedTaskWithTraits(
FROM_HERE, GetParam().traits,
BindOnce(&VerifyTimeAndTaskEnvironmentAndSignalEvent, GetParam().traits,
GetParam().pool_type,
@@ -348,11 +348,11 @@
// Verifies that Tasks posted via a TaskRunner with parameterized TaskTraits and
// ExecutionMode run on a thread with the expected priority and I/O restrictions
// and respect the characteristics of their ExecutionMode.
-TEST_P(TaskSchedulerImplTest, PostTasksViaTaskRunner) {
- StartTaskScheduler();
+TEST_P(ThreadPoolImplTest, PostTasksViaTaskRunner) {
+ StartThreadPool();
test::TestTaskFactory factory(
- CreateTaskRunnerWithTraitsAndExecutionMode(&scheduler_, GetParam().traits,
- GetParam().execution_mode),
+ CreateTaskRunnerWithTraitsAndExecutionMode(
+ &thread_pool_, GetParam().traits, GetParam().execution_mode),
GetParam().execution_mode);
EXPECT_FALSE(factory.task_runner()->RunsTasksInCurrentSequence());
@@ -368,9 +368,9 @@
// Verifies that a task posted via PostDelayedTaskWithTraits without a delay
// doesn't run before Start() is called.
-TEST_P(TaskSchedulerImplTest, PostDelayedTaskWithTraitsNoDelayBeforeStart) {
+TEST_P(ThreadPoolImplTest, PostDelayedTaskWithTraitsNoDelayBeforeStart) {
WaitableEvent task_running;
- scheduler_.PostDelayedTaskWithTraits(
+ thread_pool_.PostDelayedTaskWithTraits(
FROM_HERE, GetParam().traits,
BindOnce(&VerifyTaskEnvironmentAndSignalEvent, GetParam().traits,
GetParam().pool_type, Unretained(&task_running)),
@@ -383,15 +383,15 @@
PlatformThread::Sleep(TestTimeouts::tiny_timeout());
EXPECT_FALSE(task_running.IsSignaled());
- StartTaskScheduler();
+ StartThreadPool();
task_running.Wait();
}
// Verifies that a task posted via PostDelayedTaskWithTraits with a delay
// doesn't run before Start() is called.
-TEST_P(TaskSchedulerImplTest, PostDelayedTaskWithTraitsWithDelayBeforeStart) {
+TEST_P(ThreadPoolImplTest, PostDelayedTaskWithTraitsWithDelayBeforeStart) {
WaitableEvent task_running;
- scheduler_.PostDelayedTaskWithTraits(
+ thread_pool_.PostDelayedTaskWithTraits(
FROM_HERE, GetParam().traits,
BindOnce(&VerifyTimeAndTaskEnvironmentAndSignalEvent, GetParam().traits,
GetParam().pool_type,
@@ -406,15 +406,15 @@
PlatformThread::Sleep(TestTimeouts::tiny_timeout());
EXPECT_FALSE(task_running.IsSignaled());
- StartTaskScheduler();
+ StartThreadPool();
task_running.Wait();
}
// Verifies that a task posted via a TaskRunner doesn't run before Start() is
// called.
-TEST_P(TaskSchedulerImplTest, PostTaskViaTaskRunnerBeforeStart) {
+TEST_P(ThreadPoolImplTest, PostTaskViaTaskRunnerBeforeStart) {
WaitableEvent task_running;
- CreateTaskRunnerWithTraitsAndExecutionMode(&scheduler_, GetParam().traits,
+ CreateTaskRunnerWithTraitsAndExecutionMode(&thread_pool_, GetParam().traits,
GetParam().execution_mode)
->PostTask(FROM_HERE, BindOnce(&VerifyTaskEnvironmentAndSignalEvent,
GetParam().traits, GetParam().pool_type,
@@ -427,7 +427,7 @@
PlatformThread::Sleep(TestTimeouts::tiny_timeout());
EXPECT_FALSE(task_running.IsSignaled());
- StartTaskScheduler();
+ StartThreadPool();
// This should not hang if the task runs after Start().
task_running.Wait();
@@ -436,15 +436,15 @@
// Verify that all tasks posted to a TaskRunner after Start() run in a
// USER_BLOCKING environment when the AllTasksUserBlocking variation param of
// the BrowserScheduler experiment is true.
-TEST_P(TaskSchedulerImplTest, AllTasksAreUserBlockingTaskRunner) {
+TEST_P(ThreadPoolImplTest, AllTasksAreUserBlockingTaskRunner) {
TaskTraits user_blocking_traits = GetParam().traits;
user_blocking_traits.UpdatePriority(TaskPriority::USER_BLOCKING);
EnableAllTasksUserBlocking();
- StartTaskScheduler();
+ StartThreadPool();
WaitableEvent task_running;
- CreateTaskRunnerWithTraitsAndExecutionMode(&scheduler_, GetParam().traits,
+ CreateTaskRunnerWithTraitsAndExecutionMode(&thread_pool_, GetParam().traits,
GetParam().execution_mode)
->PostTask(FROM_HERE, BindOnce(&VerifyTaskEnvironmentAndSignalEvent,
user_blocking_traits, GetParam().pool_type,
@@ -455,16 +455,16 @@
// Verify that all tasks posted via PostDelayedTaskWithTraits() after Start()
// run in a USER_BLOCKING environment when the AllTasksUserBlocking variation
// param of the BrowserScheduler experiment is true.
-TEST_P(TaskSchedulerImplTest, AllTasksAreUserBlocking) {
+TEST_P(ThreadPoolImplTest, AllTasksAreUserBlocking) {
TaskTraits user_blocking_traits = GetParam().traits;
user_blocking_traits.UpdatePriority(TaskPriority::USER_BLOCKING);
EnableAllTasksUserBlocking();
- StartTaskScheduler();
+ StartThreadPool();
WaitableEvent task_running;
// Ignore |params.execution_mode| in this test.
- scheduler_.PostDelayedTaskWithTraits(
+ thread_pool_.PostDelayedTaskWithTraits(
FROM_HERE, GetParam().traits,
BindOnce(&VerifyTaskEnvironmentAndSignalEvent, user_blocking_traits,
GetParam().pool_type, Unretained(&task_running)),
@@ -474,18 +474,18 @@
// Verifies that FlushAsyncForTesting() calls back correctly for all trait and
// execution mode pairs.
-TEST_P(TaskSchedulerImplTest, FlushAsyncForTestingSimple) {
- StartTaskScheduler();
+TEST_P(ThreadPoolImplTest, FlushAsyncForTestingSimple) {
+ StartThreadPool();
WaitableEvent unblock_task;
CreateTaskRunnerWithTraitsAndExecutionMode(
- &scheduler_, GetParam().traits, GetParam().execution_mode,
+ &thread_pool_, GetParam().traits, GetParam().execution_mode,
SingleThreadTaskRunnerThreadMode::DEDICATED)
->PostTask(FROM_HERE, BindOnce(&test::WaitWithoutBlockingObserver,
Unretained(&unblock_task)));
WaitableEvent flush_event;
- scheduler_.FlushAsyncForTesting(
+ thread_pool_.FlushAsyncForTesting(
BindOnce(&WaitableEvent::Signal, Unretained(&flush_event)));
PlatformThread::Sleep(TestTimeouts::tiny_timeout());
EXPECT_FALSE(flush_event.IsSignaled());
@@ -495,20 +495,20 @@
flush_event.Wait();
}
-INSTANTIATE_TEST_SUITE_P(OneTaskSchedulerImplTestParams,
- TaskSchedulerImplTest,
- ::testing::ValuesIn(GetTaskSchedulerImplTestParams()));
+INSTANTIATE_TEST_SUITE_P(OneThreadPoolImplTestParams,
+ ThreadPoolImplTest,
+ ::testing::ValuesIn(GetThreadPoolImplTestParams()));
// Spawns threads that simultaneously post Tasks to TaskRunners with various
// TaskTraits and ExecutionModes. Verifies that each Task runs on a thread with
// the expected priority and I/O restrictions and respects the characteristics
// of its ExecutionMode.
-TEST_P(TaskSchedulerImplTest, MultipleTaskSchedulerImplTestParams) {
- StartTaskScheduler();
+TEST_P(ThreadPoolImplTest, MultipleThreadPoolImplTestParams) {
+ StartThreadPool();
std::vector<std::unique_ptr<ThreadPostingTasks>> threads_posting_tasks;
- for (const auto& test_params : GetTaskSchedulerImplTestParams()) {
+ for (const auto& test_params : GetThreadPoolImplTestParams()) {
threads_posting_tasks.push_back(std::make_unique<ThreadPostingTasks>(
- &scheduler_, test_params.traits, GetParam().pool_type,
+ &thread_pool_, test_params.traits, GetParam().pool_type,
test_params.execution_mode));
threads_posting_tasks.back()->Start();
}
@@ -519,9 +519,9 @@
}
}
-TEST_P(TaskSchedulerImplTest,
+TEST_P(ThreadPoolImplTest,
GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated) {
- StartTaskScheduler();
+ StartThreadPool();
#if defined(OS_WIN) || defined(OS_MACOSX)
if (GetParam().pool_type == test::PoolType::NATIVE)
@@ -532,33 +532,33 @@
// TaskPriority::BEST_EFFORT.
testing::GTEST_FLAG(death_test_style) = "threadsafe";
EXPECT_DCHECK_DEATH({
- scheduler_.GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
+ thread_pool_.GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
{TaskPriority::BEST_EFFORT});
});
EXPECT_DCHECK_DEATH({
- scheduler_.GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
+ thread_pool_.GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
{MayBlock(), TaskPriority::BEST_EFFORT});
});
- EXPECT_EQ(4, scheduler_.GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
+ EXPECT_EQ(4, thread_pool_.GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
{TaskPriority::USER_VISIBLE}));
- EXPECT_EQ(4, scheduler_.GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
+ EXPECT_EQ(4, thread_pool_.GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
{MayBlock(), TaskPriority::USER_VISIBLE}));
- EXPECT_EQ(4, scheduler_.GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
+ EXPECT_EQ(4, thread_pool_.GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
{TaskPriority::USER_BLOCKING}));
- EXPECT_EQ(4, scheduler_.GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
+ EXPECT_EQ(4, thread_pool_.GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
{MayBlock(), TaskPriority::USER_BLOCKING}));
}
// Verify that the RunsTasksInCurrentSequence() method of a SequencedTaskRunner
// returns false when called from a task that isn't part of the sequence.
-TEST_P(TaskSchedulerImplTest, SequencedRunsTasksInCurrentSequence) {
- StartTaskScheduler();
+TEST_P(ThreadPoolImplTest, SequencedRunsTasksInCurrentSequence) {
+ StartThreadPool();
auto single_thread_task_runner =
- scheduler_.CreateSingleThreadTaskRunnerWithTraits(
+ thread_pool_.CreateSingleThreadTaskRunnerWithTraits(
TaskTraits(), SingleThreadTaskRunnerThreadMode::SHARED);
auto sequenced_task_runner =
- scheduler_.CreateSequencedTaskRunnerWithTraits(TaskTraits());
+ thread_pool_.CreateSequencedTaskRunnerWithTraits(TaskTraits());
WaitableEvent task_ran;
single_thread_task_runner->PostTask(
@@ -576,12 +576,12 @@
// Verify that the RunsTasksInCurrentSequence() method of a
// SingleThreadTaskRunner returns false when called from a task that isn't part
// of the sequence.
-TEST_P(TaskSchedulerImplTest, SingleThreadRunsTasksInCurrentSequence) {
- StartTaskScheduler();
+TEST_P(ThreadPoolImplTest, SingleThreadRunsTasksInCurrentSequence) {
+ StartThreadPool();
auto sequenced_task_runner =
- scheduler_.CreateSequencedTaskRunnerWithTraits(TaskTraits());
+ thread_pool_.CreateSequencedTaskRunnerWithTraits(TaskTraits());
auto single_thread_task_runner =
- scheduler_.CreateSingleThreadTaskRunnerWithTraits(
+ thread_pool_.CreateSingleThreadTaskRunnerWithTraits(
TaskTraits(), SingleThreadTaskRunnerThreadMode::SHARED);
WaitableEvent task_ran;
@@ -599,9 +599,9 @@
}
#if defined(OS_WIN)
-TEST_P(TaskSchedulerImplTest, COMSTATaskRunnersRunWithCOMSTA) {
- StartTaskScheduler();
- auto com_sta_task_runner = scheduler_.CreateCOMSTATaskRunnerWithTraits(
+TEST_P(ThreadPoolImplTest, COMSTATaskRunnersRunWithCOMSTA) {
+ StartThreadPool();
+ auto com_sta_task_runner = thread_pool_.CreateCOMSTATaskRunnerWithTraits(
TaskTraits(), SingleThreadTaskRunnerThreadMode::SHARED);
WaitableEvent task_ran;
@@ -616,8 +616,8 @@
}
#endif // defined(OS_WIN)
-TEST_P(TaskSchedulerImplTest, DelayedTasksNotRunAfterShutdown) {
- StartTaskScheduler();
+TEST_P(ThreadPoolImplTest, DelayedTasksNotRunAfterShutdown) {
+ StartThreadPool();
// As with delayed tasks in general, this is racy. If the task does happen to
// run after Shutdown within the timeout, it will fail this test.
//
@@ -630,23 +630,23 @@
// and signalling the WaitableEvent after Shutdown() on a different thread
// since Shutdown() will block. However, the cost of managing this extra
// thread was deemed to be too great for the unlikely race.
- scheduler_.PostDelayedTaskWithTraits(FROM_HERE, TaskTraits(),
- BindOnce([]() { ADD_FAILURE(); }),
- TestTimeouts::tiny_timeout());
- scheduler_.Shutdown();
+ thread_pool_.PostDelayedTaskWithTraits(FROM_HERE, TaskTraits(),
+ BindOnce([]() { ADD_FAILURE(); }),
+ TestTimeouts::tiny_timeout());
+ thread_pool_.Shutdown();
PlatformThread::Sleep(TestTimeouts::tiny_timeout() * 2);
}
#if defined(OS_POSIX)
-TEST_P(TaskSchedulerImplTest, FileDescriptorWatcherNoOpsAfterShutdown) {
- StartTaskScheduler();
+TEST_P(ThreadPoolImplTest, FileDescriptorWatcherNoOpsAfterShutdown) {
+ StartThreadPool();
int pipes[2];
ASSERT_EQ(0, pipe(pipes));
scoped_refptr<TaskRunner> blocking_task_runner =
- scheduler_.CreateSequencedTaskRunnerWithTraits(
+ thread_pool_.CreateSequencedTaskRunnerWithTraits(
{TaskShutdownBehavior::BLOCK_SHUTDOWN});
blocking_task_runner->PostTask(
FROM_HERE,
@@ -659,7 +659,7 @@
// This test is for components that intentionally leak their
// watchers at shutdown. We can't clean |controller| up because its
// destructor will assert that it's being called from the correct
- // sequence. After the task scheduler is shutdown, it is not
+ // sequence. After the thread pool is shutdown, it is not
// possible to run tasks on this sequence.
//
// Note: Do not inline the controller.release() call into the
@@ -671,7 +671,7 @@
},
pipes[0]));
- scheduler_.Shutdown();
+ thread_pool_.Shutdown();
constexpr char kByte = '!';
ASSERT_TRUE(WriteFileDescriptor(pipes[1], &kByte, sizeof(kByte)));
@@ -686,14 +686,14 @@
// Verify that tasks posted on the same sequence access the same values on
// SequenceLocalStorage, and tasks on different sequences see different values.
-TEST_P(TaskSchedulerImplTest, SequenceLocalStorage) {
- StartTaskScheduler();
+TEST_P(ThreadPoolImplTest, SequenceLocalStorage) {
+ StartThreadPool();
SequenceLocalStorageSlot<int> slot;
auto sequenced_task_runner1 =
- scheduler_.CreateSequencedTaskRunnerWithTraits(TaskTraits());
+ thread_pool_.CreateSequencedTaskRunnerWithTraits(TaskTraits());
auto sequenced_task_runner2 =
- scheduler_.CreateSequencedTaskRunnerWithTraits(TaskTraits());
+ thread_pool_.CreateSequencedTaskRunnerWithTraits(TaskTraits());
sequenced_task_runner1->PostTask(
FROM_HERE,
@@ -714,13 +714,13 @@
},
&slot));
- scheduler_.FlushForTesting();
+ thread_pool_.FlushForTesting();
}
-TEST_P(TaskSchedulerImplTest, FlushAsyncNoTasks) {
- StartTaskScheduler();
+TEST_P(ThreadPoolImplTest, FlushAsyncNoTasks) {
+ StartThreadPool();
bool called_back = false;
- scheduler_.FlushAsyncForTesting(
+ thread_pool_.FlushAsyncForTesting(
BindOnce([](bool* called_back) { *called_back = true; },
Unretained(&called_back)));
EXPECT_TRUE(called_back);
@@ -761,8 +761,8 @@
// Integration test that verifies that workers have a frame on their stacks
// which easily identifies the type of worker and shutdown behavior (useful to
// diagnose issues from logs without memory dumps).
-TEST_P(TaskSchedulerImplTest, MAYBE_IdentifiableStacks) {
- StartTaskScheduler();
+TEST_P(ThreadPoolImplTest, MAYBE_IdentifiableStacks) {
+ StartThreadPool();
// Shutdown behaviors and expected stack frames.
constexpr std::pair<TaskShutdownBehavior, const char*> shutdown_behaviors[] =
@@ -775,34 +775,34 @@
const TaskTraits best_effort_traits = {shutdown_behavior.first,
TaskPriority::BEST_EFFORT};
- scheduler_.CreateSequencedTaskRunnerWithTraits(traits)->PostTask(
+ thread_pool_.CreateSequencedTaskRunnerWithTraits(traits)->PostTask(
FROM_HERE, BindOnce(&VerifyHasStringsOnStack, "RunPooledWorker",
shutdown_behavior.second));
- scheduler_.CreateSequencedTaskRunnerWithTraits(best_effort_traits)
+ thread_pool_.CreateSequencedTaskRunnerWithTraits(best_effort_traits)
->PostTask(FROM_HERE, BindOnce(&VerifyHasStringsOnStack,
"RunBackgroundPooledWorker",
shutdown_behavior.second));
- scheduler_
+ thread_pool_
.CreateSingleThreadTaskRunnerWithTraits(
traits, SingleThreadTaskRunnerThreadMode::SHARED)
->PostTask(FROM_HERE,
BindOnce(&VerifyHasStringsOnStack, "RunSharedWorker",
shutdown_behavior.second));
- scheduler_
+ thread_pool_
.CreateSingleThreadTaskRunnerWithTraits(
best_effort_traits, SingleThreadTaskRunnerThreadMode::SHARED)
->PostTask(FROM_HERE, BindOnce(&VerifyHasStringsOnStack,
"RunBackgroundSharedWorker",
shutdown_behavior.second));
- scheduler_
+ thread_pool_
.CreateSingleThreadTaskRunnerWithTraits(
traits, SingleThreadTaskRunnerThreadMode::DEDICATED)
->PostTask(FROM_HERE,
BindOnce(&VerifyHasStringsOnStack, "RunDedicatedWorker",
shutdown_behavior.second));
- scheduler_
+ thread_pool_
.CreateSingleThreadTaskRunnerWithTraits(
best_effort_traits, SingleThreadTaskRunnerThreadMode::DEDICATED)
->PostTask(FROM_HERE, BindOnce(&VerifyHasStringsOnStack,
@@ -810,26 +810,26 @@
shutdown_behavior.second));
#if defined(OS_WIN)
- scheduler_
+ thread_pool_
.CreateCOMSTATaskRunnerWithTraits(
traits, SingleThreadTaskRunnerThreadMode::SHARED)
->PostTask(FROM_HERE,
BindOnce(&VerifyHasStringsOnStack, "RunSharedCOMWorker",
shutdown_behavior.second));
- scheduler_
+ thread_pool_
.CreateCOMSTATaskRunnerWithTraits(
best_effort_traits, SingleThreadTaskRunnerThreadMode::SHARED)
->PostTask(FROM_HERE, BindOnce(&VerifyHasStringsOnStack,
"RunBackgroundSharedCOMWorker",
shutdown_behavior.second));
- scheduler_
+ thread_pool_
.CreateCOMSTATaskRunnerWithTraits(
traits, SingleThreadTaskRunnerThreadMode::DEDICATED)
->PostTask(FROM_HERE,
BindOnce(&VerifyHasStringsOnStack, "RunDedicatedCOMWorker",
shutdown_behavior.second));
- scheduler_
+ thread_pool_
.CreateCOMSTATaskRunnerWithTraits(
best_effort_traits, SingleThreadTaskRunnerThreadMode::DEDICATED)
->PostTask(FROM_HERE, BindOnce(&VerifyHasStringsOnStack,
@@ -838,17 +838,17 @@
#endif // defined(OS_WIN)
}
- scheduler_.FlushForTesting();
+ thread_pool_.FlushForTesting();
}
-TEST_P(TaskSchedulerImplTest, SchedulerWorkerObserver) {
+TEST_P(ThreadPoolImplTest, SchedulerWorkerObserver) {
#if defined(OS_WIN) || defined(OS_MACOSX)
// SchedulerWorkers are not created (and hence not observed) when using the
- // native thread pools. We still start the TaskScheduler in this case since
+ // native thread pools. We still start the ThreadPool in this case since
// JoinForTesting is always called on TearDown, and DCHECKs that all worker
// pools are started.
if (GetParam().pool_type == test::PoolType::NATIVE) {
- StartTaskScheduler();
+ StartThreadPool();
return;
}
#endif
@@ -874,56 +874,56 @@
// Infinite detach time to prevent workers from invoking
// OnSchedulerWorkerMainExit() earlier than expected.
- StartTaskScheduler(TimeDelta::Max());
+ StartThreadPool(TimeDelta::Max());
std::vector<scoped_refptr<SingleThreadTaskRunner>> task_runners;
- task_runners.push_back(scheduler_.CreateSingleThreadTaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateSingleThreadTaskRunnerWithTraits(
{TaskPriority::BEST_EFFORT}, SingleThreadTaskRunnerThreadMode::SHARED));
- task_runners.push_back(scheduler_.CreateSingleThreadTaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateSingleThreadTaskRunnerWithTraits(
{TaskPriority::BEST_EFFORT, MayBlock()},
SingleThreadTaskRunnerThreadMode::SHARED));
- task_runners.push_back(scheduler_.CreateSingleThreadTaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateSingleThreadTaskRunnerWithTraits(
{TaskPriority::USER_BLOCKING}, SingleThreadTaskRunnerThreadMode::SHARED));
- task_runners.push_back(scheduler_.CreateSingleThreadTaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateSingleThreadTaskRunnerWithTraits(
{TaskPriority::USER_BLOCKING, MayBlock()},
SingleThreadTaskRunnerThreadMode::SHARED));
- task_runners.push_back(scheduler_.CreateSingleThreadTaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateSingleThreadTaskRunnerWithTraits(
{TaskPriority::BEST_EFFORT},
SingleThreadTaskRunnerThreadMode::DEDICATED));
- task_runners.push_back(scheduler_.CreateSingleThreadTaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateSingleThreadTaskRunnerWithTraits(
{TaskPriority::BEST_EFFORT, MayBlock()},
SingleThreadTaskRunnerThreadMode::DEDICATED));
- task_runners.push_back(scheduler_.CreateSingleThreadTaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateSingleThreadTaskRunnerWithTraits(
{TaskPriority::USER_BLOCKING},
SingleThreadTaskRunnerThreadMode::DEDICATED));
- task_runners.push_back(scheduler_.CreateSingleThreadTaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateSingleThreadTaskRunnerWithTraits(
{TaskPriority::USER_BLOCKING, MayBlock()},
SingleThreadTaskRunnerThreadMode::DEDICATED));
#if defined(OS_WIN)
- task_runners.push_back(scheduler_.CreateCOMSTATaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateCOMSTATaskRunnerWithTraits(
{TaskPriority::BEST_EFFORT}, SingleThreadTaskRunnerThreadMode::SHARED));
- task_runners.push_back(scheduler_.CreateCOMSTATaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateCOMSTATaskRunnerWithTraits(
{TaskPriority::BEST_EFFORT, MayBlock()},
SingleThreadTaskRunnerThreadMode::SHARED));
- task_runners.push_back(scheduler_.CreateCOMSTATaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateCOMSTATaskRunnerWithTraits(
{TaskPriority::USER_BLOCKING}, SingleThreadTaskRunnerThreadMode::SHARED));
- task_runners.push_back(scheduler_.CreateCOMSTATaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateCOMSTATaskRunnerWithTraits(
{TaskPriority::USER_BLOCKING, MayBlock()},
SingleThreadTaskRunnerThreadMode::SHARED));
- task_runners.push_back(scheduler_.CreateCOMSTATaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateCOMSTATaskRunnerWithTraits(
{TaskPriority::BEST_EFFORT},
SingleThreadTaskRunnerThreadMode::DEDICATED));
- task_runners.push_back(scheduler_.CreateCOMSTATaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateCOMSTATaskRunnerWithTraits(
{TaskPriority::BEST_EFFORT, MayBlock()},
SingleThreadTaskRunnerThreadMode::DEDICATED));
- task_runners.push_back(scheduler_.CreateCOMSTATaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateCOMSTATaskRunnerWithTraits(
{TaskPriority::USER_BLOCKING},
SingleThreadTaskRunnerThreadMode::DEDICATED));
- task_runners.push_back(scheduler_.CreateCOMSTATaskRunnerWithTraits(
+ task_runners.push_back(thread_pool_.CreateCOMSTATaskRunnerWithTraits(
{TaskPriority::USER_BLOCKING, MayBlock()},
SingleThreadTaskRunnerThreadMode::DEDICATED));
#endif
@@ -961,8 +961,8 @@
} // namespace
// Regression test for https://crbug.com/945087.
-TEST_P(TaskSchedulerImplTest, NoLeakWhenPostingNestedTask) {
- StartTaskScheduler();
+TEST_P(ThreadPoolImplTest, NoLeakWhenPostingNestedTask) {
+ StartThreadPool();
SequenceLocalStorageSlot<std::unique_ptr<MustBeDestroyed>> sls;
@@ -970,7 +970,7 @@
auto must_be_destroyed = std::make_unique<MustBeDestroyed>(&was_destroyed);
auto task_runner = CreateTaskRunnerWithTraitsAndExecutionMode(
- &scheduler_, GetParam().traits, GetParam().execution_mode);
+ &thread_pool_, GetParam().traits, GetParam().execution_mode);
task_runner->PostTask(FROM_HERE, BindLambdaForTesting([&] {
sls.Set(std::move(must_be_destroyed));
@@ -986,8 +986,8 @@
EXPECT_TRUE(was_destroyed);
}
-class TaskSchedulerPriorityUpdateTest
- : public testing::TestWithParam<TaskSchedulerImplTestParams> {
+class ThreadPoolPriorityUpdateTest
+ : public testing::TestWithParam<ThreadPoolImplTestParams> {
protected:
struct PoolBlockingEvents {
PoolBlockingEvents(const TaskTraits& pool_traits)
@@ -1013,14 +1013,14 @@
WaitableEvent* expected_previous_event;
};
- TaskSchedulerPriorityUpdateTest() : scheduler_("Test") {}
+ ThreadPoolPriorityUpdateTest() : thread_pool_("Test") {}
- void StartTaskSchedulerWithNumThreadsPerPool(int threads_per_pool) {
+ void StartThreadPoolWithNumThreadsPerPool(int threads_per_pool) {
constexpr TimeDelta kSuggestedReclaimTime = TimeDelta::FromSeconds(30);
- scheduler_.Start({{threads_per_pool, kSuggestedReclaimTime},
- {threads_per_pool, kSuggestedReclaimTime}},
- nullptr);
+ thread_pool_.Start({{threads_per_pool, kSuggestedReclaimTime},
+ {threads_per_pool, kSuggestedReclaimTime}},
+ nullptr);
}
// Create a series of sample task runners that will post tasks at various
@@ -1029,14 +1029,14 @@
// Task runner that will start as USER_VISIBLE and update to USER_BLOCKING.
// Its task is expected to run first.
task_runners_and_events_.push_back(std::make_unique<TaskRunnerAndEvents>(
- scheduler_.CreateUpdateableSequencedTaskRunnerWithTraitsForTesting(
+ thread_pool_.CreateUpdateableSequencedTaskRunnerWithTraitsForTesting(
TaskTraits({TaskPriority::USER_VISIBLE})),
TaskPriority::USER_BLOCKING, nullptr));
// Task runner that will start as BEST_EFFORT and update to USER_VISIBLE.
// Its task is expected to run after the USER_BLOCKING task runner's task.
task_runners_and_events_.push_back(std::make_unique<TaskRunnerAndEvents>(
- scheduler_.CreateUpdateableSequencedTaskRunnerWithTraitsForTesting(
+ thread_pool_.CreateUpdateableSequencedTaskRunnerWithTraitsForTesting(
TaskTraits({TaskPriority::BEST_EFFORT})),
TaskPriority::USER_VISIBLE,
&task_runners_and_events_.back()->task_ran));
@@ -1046,7 +1046,7 @@
// task runners' tasks if background pools exist, or after the USER_VISIBLE
// task runner's task if not.
task_runners_and_events_.push_back(std::make_unique<TaskRunnerAndEvents>(
- scheduler_.CreateUpdateableSequencedTaskRunnerWithTraitsForTesting(
+ thread_pool_.CreateUpdateableSequencedTaskRunnerWithTraitsForTesting(
TaskTraits({TaskPriority::USER_BLOCKING})),
TaskPriority::BEST_EFFORT,
CanUseBackgroundPriorityForSchedulerWorker()
@@ -1055,15 +1055,15 @@
}
void TearDown() override {
- scheduler_.FlushForTesting();
- scheduler_.JoinForTesting();
+ thread_pool_.FlushForTesting();
+ thread_pool_.JoinForTesting();
}
- TaskSchedulerImpl scheduler_;
+ ThreadPoolImpl thread_pool_;
std::vector<std::unique_ptr<TaskRunnerAndEvents>> task_runners_and_events_;
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerPriorityUpdateTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolPriorityUpdateTest);
};
// Update the priority of a sequence when it is not scheduled.
@@ -1071,8 +1071,8 @@
// TODO(adityakeerthi): Parameterize this test once we have a way to prevent
// sequences from being scheduled without flooding the pool. It is not possible
// to flood the native pools.
-TEST_F(TaskSchedulerPriorityUpdateTest, UpdatePrioritySequenceNotScheduled) {
- StartTaskSchedulerWithNumThreadsPerPool(1);
+TEST_F(ThreadPoolPriorityUpdateTest, UpdatePrioritySequenceNotScheduled) {
+ StartThreadPoolWithNumThreadsPerPool(1);
// Schedule blocking tasks on all threads to prevent tasks from being
// scheduled later in the test.
@@ -1088,7 +1088,7 @@
// When all blocking tasks signal |scheduled|, there is a task blocked in
// each pool.
for (auto& pool_blocking_event : pool_blocking_events) {
- scheduler_
+ thread_pool_
.CreateUpdateableSequencedTaskRunnerWithTraitsForTesting(
pool_blocking_event->pool_traits)
->PostTask(
@@ -1133,7 +1133,7 @@
// Update the priority of a sequence when it is scheduled, i.e. not currently
// in a priority queue.
-TEST_P(TaskSchedulerPriorityUpdateTest, UpdatePrioritySequenceScheduled) {
+TEST_P(ThreadPoolPriorityUpdateTest, UpdatePrioritySequenceScheduled) {
#if defined(OS_WIN) || defined(OS_MACOSX)
base::test::ScopedFeatureList feature_list;
if (GetParam().pool_type == test::PoolType::NATIVE) {
@@ -1143,7 +1143,7 @@
}
#endif
- StartTaskSchedulerWithNumThreadsPerPool(5);
+ StartThreadPoolWithNumThreadsPerPool(5);
CreateTaskRunnersAndEvents();
@@ -1188,9 +1188,9 @@
}
}
-INSTANTIATE_TEST_SUITE_P(OneTaskSchedulerPriorityUpdateTestParams,
- TaskSchedulerPriorityUpdateTest,
- ::testing::ValuesIn(GetTaskSchedulerImplTestParams()));
+INSTANTIATE_TEST_SUITE_P(OneThreadPoolPriorityUpdateTestParams,
+ ThreadPoolPriorityUpdateTest,
+ ::testing::ValuesIn(GetThreadPoolImplTestParams()));
} // namespace internal
} // namespace base
diff --git a/base/task/task_scheduler/task_scheduler_perftest.cc b/base/task/thread_pool/thread_pool_perftest.cc
similarity index 74%
rename from base/task/task_scheduler/task_scheduler_perftest.cc
rename to base/task/thread_pool/thread_pool_perftest.cc
index 5976687..dc87ee0 100644
--- a/base/task/task_scheduler/task_scheduler_perftest.cc
+++ b/base/task/thread_pool/thread_pool_perftest.cc
@@ -14,7 +14,7 @@
#include "base/optional.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/simple_thread.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -64,7 +64,7 @@
DISALLOW_COPY_AND_ASSIGN(PostingThread);
};
-class TaskSchedulerPerfTest : public testing::Test {
+class ThreadPoolPerfTest : public testing::Test {
public:
// Posting actions:
@@ -113,24 +113,24 @@
}
protected:
- TaskSchedulerPerfTest() { TaskScheduler::Create("PerfTest"); }
+ ThreadPoolPerfTest() { ThreadPool::Create("PerfTest"); }
- ~TaskSchedulerPerfTest() override { TaskScheduler::SetInstance(nullptr); }
+ ~ThreadPoolPerfTest() override { ThreadPool::SetInstance(nullptr); }
- void StartTaskScheduler(size_t num_running_threads,
- size_t num_posting_threads,
- base::RepeatingClosure post_action) {
+ void StartThreadPool(size_t num_running_threads,
+ size_t num_posting_threads,
+ base::RepeatingClosure post_action) {
constexpr TimeDelta kSuggestedReclaimTime = TimeDelta::FromSeconds(30);
constexpr int kMaxNumBackgroundThreads = 1;
- TaskScheduler::GetInstance()->Start(
+ ThreadPool::GetInstance()->Start(
{{kMaxNumBackgroundThreads, kSuggestedReclaimTime},
{num_running_threads, kSuggestedReclaimTime}},
nullptr);
base::RepeatingClosure done = BarrierClosure(
num_posting_threads,
- base::BindOnce(&TaskSchedulerPerfTest::OnCompletePostingTasks,
+ base::BindOnce(&ThreadPoolPerfTest::OnCompletePostingTasks,
base::Unretained(this)));
for (size_t i = 0; i < num_posting_threads; ++i) {
@@ -142,7 +142,7 @@
void OnCompletePostingTasks() { complete_posting_tasks_.Signal(); }
void Benchmark(const std::string& trace, ExecutionMode execution_mode) {
- base::Optional<TaskScheduler::ScopedExecutionFence> execution_fence;
+ base::Optional<ThreadPool::ScopedExecutionFence> execution_fence;
if (execution_mode == ExecutionMode::kPostThenRun) {
execution_fence.emplace();
}
@@ -157,13 +157,13 @@
}
// Wait for no pending tasks.
- TaskScheduler::GetInstance()->FlushForTesting();
+ ThreadPool::GetInstance()->FlushForTesting();
tasks_run_duration_ = TimeTicks::Now() - tasks_run_start;
ASSERT_EQ(0U, num_tasks_pending_);
for (auto& thread : threads_)
thread->Join();
- TaskScheduler::GetInstance()->JoinForTesting();
+ ThreadPool::GetInstance()->JoinForTesting();
perf_test::PrintResult(
"Posting tasks throughput", "", trace,
@@ -191,66 +191,60 @@
std::vector<std::unique_ptr<PostingThread>> threads_;
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerPerfTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolPerfTest);
};
} // namespace
-TEST_F(TaskSchedulerPerfTest, BindPostThenRunNoOpTasks) {
- StartTaskScheduler(
+TEST_F(ThreadPoolPerfTest, BindPostThenRunNoOpTasks) {
+ StartThreadPool(
1, 1,
- BindRepeating(&TaskSchedulerPerfTest::ContinuouslyBindAndPostNoOpTasks,
+ BindRepeating(&ThreadPoolPerfTest::ContinuouslyBindAndPostNoOpTasks,
Unretained(this), 10000));
Benchmark("Bind+Post-then-run no-op tasks", ExecutionMode::kPostThenRun);
}
-TEST_F(TaskSchedulerPerfTest, PostThenRunNoOpTasks) {
- StartTaskScheduler(
- 1, 1,
- BindRepeating(&TaskSchedulerPerfTest::ContinuouslyPostNoOpTasks,
- Unretained(this), 10000));
+TEST_F(ThreadPoolPerfTest, PostThenRunNoOpTasks) {
+ StartThreadPool(1, 1,
+ BindRepeating(&ThreadPoolPerfTest::ContinuouslyPostNoOpTasks,
+ Unretained(this), 10000));
Benchmark("Post-then-run no-op tasks", ExecutionMode::kPostThenRun);
}
-TEST_F(TaskSchedulerPerfTest, PostThenRunNoOpTasksManyThreads) {
- StartTaskScheduler(
- 4, 4,
- BindRepeating(&TaskSchedulerPerfTest::ContinuouslyPostNoOpTasks,
- Unretained(this), 10000));
+TEST_F(ThreadPoolPerfTest, PostThenRunNoOpTasksManyThreads) {
+ StartThreadPool(4, 4,
+ BindRepeating(&ThreadPoolPerfTest::ContinuouslyPostNoOpTasks,
+ Unretained(this), 10000));
Benchmark("Post-then-run no-op tasks many threads",
ExecutionMode::kPostThenRun);
}
-TEST_F(TaskSchedulerPerfTest,
- PostThenRunNoOpTasksMorePostingThanRunningThreads) {
- StartTaskScheduler(
- 1, 4,
- BindRepeating(&TaskSchedulerPerfTest::ContinuouslyPostNoOpTasks,
- Unretained(this), 10000));
+TEST_F(ThreadPoolPerfTest, PostThenRunNoOpTasksMorePostingThanRunningThreads) {
+ StartThreadPool(1, 4,
+ BindRepeating(&ThreadPoolPerfTest::ContinuouslyPostNoOpTasks,
+ Unretained(this), 10000));
Benchmark("Post-then-run no-op tasks more posting than running threads",
ExecutionMode::kPostThenRun);
}
-TEST_F(TaskSchedulerPerfTest, PostRunNoOpTasks) {
- StartTaskScheduler(
- 1, 1,
- BindRepeating(&TaskSchedulerPerfTest::ContinuouslyPostNoOpTasks,
- Unretained(this), 10000));
+TEST_F(ThreadPoolPerfTest, PostRunNoOpTasks) {
+ StartThreadPool(1, 1,
+ BindRepeating(&ThreadPoolPerfTest::ContinuouslyPostNoOpTasks,
+ Unretained(this), 10000));
Benchmark("Post/run no-op tasks", ExecutionMode::kPostAndRun);
}
-TEST_F(TaskSchedulerPerfTest, PostRunNoOpTasksManyThreads) {
- StartTaskScheduler(
- 4, 4,
- BindRepeating(&TaskSchedulerPerfTest::ContinuouslyPostNoOpTasks,
- Unretained(this), 10000));
+TEST_F(ThreadPoolPerfTest, PostRunNoOpTasksManyThreads) {
+ StartThreadPool(4, 4,
+ BindRepeating(&ThreadPoolPerfTest::ContinuouslyPostNoOpTasks,
+ Unretained(this), 10000));
Benchmark("Post/run no-op tasks many threads", ExecutionMode::kPostAndRun);
}
-TEST_F(TaskSchedulerPerfTest, PostRunBusyTasksManyThreads) {
- StartTaskScheduler(
+TEST_F(ThreadPoolPerfTest, PostRunBusyTasksManyThreads) {
+ StartThreadPool(
4, 4,
- BindRepeating(&TaskSchedulerPerfTest::ContinuouslyPostBusyWaitTasks,
+ BindRepeating(&ThreadPoolPerfTest::ContinuouslyPostBusyWaitTasks,
Unretained(this), 10000,
base::TimeDelta::FromMicroseconds(200)));
Benchmark("Post/run busy tasks many threads", ExecutionMode::kPostAndRun);
diff --git a/base/task/task_scheduler/tracked_ref.h b/base/task/thread_pool/tracked_ref.h
similarity index 92%
rename from base/task/task_scheduler/tracked_ref.h
rename to base/task/thread_pool/tracked_ref.h
index d4bc15a..4fc29faf 100644
--- a/base/task/task_scheduler/tracked_ref.h
+++ b/base/task/thread_pool/tracked_ref.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TASK_TASK_SCHEDULER_TRACKED_REF_H_
-#define BASE_TASK_TASK_SCHEDULER_TRACKED_REF_H_
+#ifndef BASE_TASK_THREAD_POOL_TRACKED_REF_H_
+#define BASE_TASK_THREAD_POOL_TRACKED_REF_H_
#include <memory>
@@ -37,20 +37,20 @@
// impractical in production -- ref. ScopedAllowBaseSyncPrimitivesForTesting
// below).
//
-// Why would we ever need such a thing? In task_scheduler there is a clear
+// Why would we ever need such a thing? In thread_pool there is a clear
// ownership hierarchy with mostly single owners and little refcounting. In
// production nothing is ever torn down so this isn't a problem. In tests
// however we must JoinForTesting(). At that point, all the raw back T* refs
// used by the worker threads are problematic because they can result in use-
// after-frees if a worker outlives the deletion of its corresponding
-// TaskScheduler/TaskTracker/SchedulerWorkerPool/etc.
+// ThreadPool/TaskTracker/SchedulerWorkerPool/etc.
//
// JoinForTesting() isn't so hard when all workers are managed. But with cleanup
// semantics (reclaiming a worker who's been idle for too long) it becomes
// tricky because workers can go unaccounted for before they exit their main
// (https://crbug.com/827615).
//
-// For that reason and to clearly document the ownership model, task_scheduler
+// For that reason and to clearly document the ownership model, thread_pool
// uses TrackedRefs.
//
// On top of being a clearer ownership model than proper refcounting, a hang in
@@ -59,10 +59,10 @@
// (potentially resulting in flakes in unrelated tests running later in the same
// process).
//
-// Note: While there's nothing task_scheduler specific about TrackedRefs it
+// Note: While there's nothing thread_pool specific about TrackedRefs it
// requires an ownership model where all the TrackedRefs are released on other
// threads in sync with ~T(). This isn't a typical use case beyond shutting down
-// TaskScheduler in tests and as such this is kept internal here for now.
+// ThreadPool in tests and as such this is kept internal here for now.
template <class T>
class TrackedRefFactory;
@@ -177,4 +177,4 @@
} // namespace internal
} // namespace base
-#endif // BASE_TASK_TASK_SCHEDULER_TRACKED_REF_H_
+#endif // BASE_TASK_THREAD_POOL_TRACKED_REF_H_
diff --git a/base/task/task_scheduler/tracked_ref_unittest.cc b/base/task/thread_pool/tracked_ref_unittest.cc
similarity index 98%
rename from base/task/task_scheduler/tracked_ref_unittest.cc
rename to base/task/thread_pool/tracked_ref_unittest.cc
index 995aa5c..c3eb9ad 100644
--- a/base/task/task_scheduler/tracked_ref_unittest.cc
+++ b/base/task/thread_pool/tracked_ref_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task/task_scheduler/tracked_ref.h"
+#include "base/task/thread_pool/tracked_ref.h"
#include <memory>
diff --git a/base/test/BUILD.gn b/base/test/BUILD.gn
index a35fd29..1d20e94e 100644
--- a/base/test/BUILD.gn
+++ b/base/test/BUILD.gn
@@ -119,7 +119,6 @@
"simple_test_tick_clock.h",
"task_runner_test_template.cc",
"task_runner_test_template.h",
- "task_scheduler_test_helpers_android.cc",
"test_discardable_memory_allocator.cc",
"test_discardable_memory_allocator.h",
"test_file_util.cc",
@@ -152,6 +151,7 @@
"test_support_android.h",
"test_support_ios.h",
"test_support_ios.mm",
+ "thread_pool_test_helpers_android.cc",
"thread_test_helper.cc",
"thread_test_helper.h",
"trace_event_analyzer.cc",
@@ -452,7 +452,7 @@
"android/java/src/org/chromium/base/MainReturnCodeResult.java",
"android/java/src/org/chromium/base/MultiprocessTestClientLauncher.java",
"android/javatests/src/org/chromium/base/test/ReachedCodeProfiler.java",
- "android/javatests/src/org/chromium/base/test/task/TaskSchedulerTestHelpers.java",
+ "android/javatests/src/org/chromium/base/test/task/ThreadPoolTestHelpers.java",
"android/javatests/src/org/chromium/base/test/util/UrlUtils.java",
]
jni_package = "base"
diff --git a/base/test/android/javatests/src/org/chromium/base/test/task/TaskSchedulerTestHelpers.java b/base/test/android/javatests/src/org/chromium/base/test/task/TaskSchedulerTestHelpers.java
deleted file mode 100644
index 5427cba..0000000
--- a/base/test/android/javatests/src/org/chromium/base/test/task/TaskSchedulerTestHelpers.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.base.test.task;
-
-/** Helpers that allow base::TaskScheduler to be initialized or shutdown for testing. */
-public class TaskSchedulerTestHelpers {
- /**
- * Initializes base::TaskScheduler with default params.
- */
- public static void enableTaskSchedulerExecutionForTesting() {
- nativeEnableTaskSchedulerExecutionForTesting();
- }
-
- /**
- * Shuts down base::TaskScheduler.
- */
- public static void disableTaskSchedulerExecutionForTesting() {
- nativeDisableTaskSchedulerExecutionForTesting();
- }
-
- private static native void nativeEnableTaskSchedulerExecutionForTesting();
- private static native void nativeDisableTaskSchedulerExecutionForTesting();
-}
diff --git a/base/test/android/javatests/src/org/chromium/base/test/task/ThreadPoolTestHelpers.java b/base/test/android/javatests/src/org/chromium/base/test/task/ThreadPoolTestHelpers.java
new file mode 100644
index 0000000..34bf0d6
--- /dev/null
+++ b/base/test/android/javatests/src/org/chromium/base/test/task/ThreadPoolTestHelpers.java
@@ -0,0 +1,25 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.base.test.task;
+
+/** Helpers that allow base::ThreadPool to be initialized or shutdown for testing. */
+public class ThreadPoolTestHelpers {
+ /**
+ * Initializes base::ThreadPool with default params.
+ */
+ public static void enableThreadPoolExecutionForTesting() {
+ nativeEnableThreadPoolExecutionForTesting();
+ }
+
+ /**
+ * Shuts down base::ThreadPool.
+ */
+ public static void disableThreadPoolExecutionForTesting() {
+ nativeDisableThreadPoolExecutionForTesting();
+ }
+
+ private static native void nativeEnableThreadPoolExecutionForTesting();
+ private static native void nativeDisableThreadPoolExecutionForTesting();
+}
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc
index ecf1f45..a6e3de7 100644
--- a/base/test/launcher/test_launcher.cc
+++ b/base/test/launcher/test_launcher.cc
@@ -40,7 +40,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/gtest_util.h"
#include "base/test/launcher/test_launcher_tracer.h"
#include "base/test/launcher/test_results_tracker.h"
@@ -133,19 +133,19 @@
return tracer;
}
-// Creates and starts a TaskScheduler with |num_parallel_jobs| dedicated to
+// Creates and starts a ThreadPool with |num_parallel_jobs| dedicated to
// foreground blocking tasks (corresponds to the traits used to launch and wait
// for child processes).
-void CreateAndStartTaskScheduler(int num_parallel_jobs) {
- // These values are taken from TaskScheduler::StartWithDefaultParams(), which
+void CreateAndStartThreadPool(int num_parallel_jobs) {
+ // These values are taken from ThreadPool::StartWithDefaultParams(), which
// is not used directly to allow a custom number of threads in the foreground
// pool.
// TODO(etiennep): Change this to 2 in future CL.
constexpr int kMaxBackgroundThreads = 3;
constexpr base::TimeDelta kSuggestedReclaimTime =
base::TimeDelta::FromSeconds(30);
- base::TaskScheduler::Create("TestLauncher");
- base::TaskScheduler::GetInstance()->Start(
+ base::ThreadPool::Create("TestLauncher");
+ base::ThreadPool::GetInstance()->Start(
{{kMaxBackgroundThreads, kSuggestedReclaimTime},
{num_parallel_jobs, kSuggestedReclaimTime}});
}
@@ -619,8 +619,8 @@
parallel_jobs_(parallel_jobs) {}
TestLauncher::~TestLauncher() {
- if (base::TaskScheduler::GetInstance()) {
- base::TaskScheduler::GetInstance()->Shutdown();
+ if (base::ThreadPool::GetInstance()) {
+ base::ThreadPool::GetInstance()->Shutdown();
}
}
@@ -1029,7 +1029,7 @@
fprintf(stdout, "Using %" PRIuS " parallel jobs.\n", parallel_jobs_);
fflush(stdout);
- CreateAndStartTaskScheduler(static_cast<int>(parallel_jobs_));
+ CreateAndStartThreadPool(static_cast<int>(parallel_jobs_));
std::vector<std::string> positive_file_filter;
std::vector<std::string> positive_gtest_filter;
diff --git a/base/test/scoped_task_environment.cc b/base/test/scoped_task_environment.cc
index b9827df..724b37e2 100644
--- a/base/test/scoped_task_environment.cc
+++ b/base/test/scoped_task_environment.cc
@@ -15,8 +15,8 @@
#include "base/task/post_task.h"
#include "base/task/sequence_manager/sequence_manager_impl.h"
#include "base/task/sequence_manager/time_domain.h"
-#include "base/task/task_scheduler/task_scheduler.h"
-#include "base/task/task_scheduler/task_scheduler_impl.h"
+#include "base/task/thread_pool/thread_pool.h"
+#include "base/task/thread_pool/thread_pool_impl.h"
#include "base/test/bind_test_util.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/test/test_timeouts.h"
@@ -266,7 +266,7 @@
ScopedTaskEnvironment::MockTimeDomain::current_mock_time_domain_ = nullptr;
class ScopedTaskEnvironment::TestTaskTracker
- : public internal::TaskSchedulerImpl::TaskTrackerImpl {
+ : public internal::ThreadPoolImpl::TaskTrackerImpl {
public:
TestTaskTracker();
@@ -286,7 +286,7 @@
private:
friend class ScopedTaskEnvironment;
- // internal::TaskSchedulerImpl::TaskTrackerImpl:
+ // internal::ThreadPoolImpl::TaskTrackerImpl:
void RunOrSkipTask(internal::Task task,
internal::Sequence* sequence,
const TaskTraits& traits,
@@ -342,8 +342,8 @@
MakeExpectedNotRunClosure(FROM_HERE, "Run() timed out."))) {
CHECK(now_source == NowSource::REAL_TIME || mock_time_domain_)
<< "NowSource must be REAL_TIME unless we're using mock time";
- CHECK(!TaskScheduler::GetInstance())
- << "Someone has already initialized TaskScheduler. If nothing in your "
+ CHECK(!ThreadPool::GetInstance())
+ << "Someone has already initialized ThreadPool. If nothing in your "
"test does so, then a test that ran earlier may have initialized one, "
"and leaked it. base::TestSuite will trap leaked globals, unless "
"someone has explicitly disabled it with "
@@ -363,7 +363,7 @@
CompleteInitialization();
}
- // Instantiate a TaskScheduler with 4 workers per pool. Having multiple
+ // Instantiate a ThreadPool with 4 workers per pool. Having multiple
// threads prevents deadlocks should some blocking APIs not use
// ScopedBlockingCall. It also allows enough concurrency to allow TSAN to spot
// data races.
@@ -371,15 +371,15 @@
const TimeDelta kSuggestedReclaimTime = TimeDelta::Max();
const SchedulerWorkerPoolParams worker_pool_params(kMaxThreads,
kSuggestedReclaimTime);
- TaskScheduler::SetInstance(std::make_unique<internal::TaskSchedulerImpl>(
+ ThreadPool::SetInstance(std::make_unique<internal::ThreadPoolImpl>(
"ScopedTaskEnvironment", WrapUnique(task_tracker_)));
- task_scheduler_ = TaskScheduler::GetInstance();
- TaskScheduler::GetInstance()->Start({
+ thread_pool_ = ThreadPool::GetInstance();
+ ThreadPool::GetInstance()->Start({
worker_pool_params, worker_pool_params
#if defined(OS_WIN)
,
// Enable the MTA in unit tests to match the browser process'
- // TaskScheduler configuration.
+ // ThreadPool configuration.
//
// This has the adverse side-effect of enabling the MTA in non-browser
// unit tests as well but the downside there is not as bad as not having
@@ -389,7 +389,7 @@
// I/O, waits, etc. Such misuse will still be caught in later phases
// (and COM usage should already be pretty much inexistent in sandboxed
// processes).
- TaskScheduler::InitParams::SharedWorkerPoolEnvironment::COM_MTA
+ ThreadPool::InitParams::SharedWorkerPoolEnvironment::COM_MTA
#endif
});
@@ -418,18 +418,18 @@
// infinite post loop in the remaining work but this isn't possible right now
// because base::~MessageLoop() didn't use to do this and adding it here would
// make the migration away from MessageLoop that much harder.
- CHECK_EQ(TaskScheduler::GetInstance(), task_scheduler_);
+ CHECK_EQ(ThreadPool::GetInstance(), thread_pool_);
// Without FlushForTesting(), DeleteSoon() and ReleaseSoon() tasks could be
// skipped, resulting in memory leaks.
task_tracker_->AllowRunTasks();
- TaskScheduler::GetInstance()->FlushForTesting();
- TaskScheduler::GetInstance()->Shutdown();
- TaskScheduler::GetInstance()->JoinForTesting();
- // Destroying TaskScheduler state can result in waiting on worker threads.
+ ThreadPool::GetInstance()->FlushForTesting();
+ ThreadPool::GetInstance()->Shutdown();
+ ThreadPool::GetInstance()->JoinForTesting();
+ // Destroying ThreadPool state can result in waiting on worker threads.
// Make sure this is allowed to avoid flaking tests that have disallowed waits
// on their main thread.
ScopedAllowBaseSyncPrimitivesForTesting allow_waits_to_destroy_task_tracker;
- TaskScheduler::SetInstance(nullptr);
+ ThreadPool::SetInstance(nullptr);
task_queue_ = nullptr;
NotifyDestructionObserversAndReleaseSequenceManager();
}
@@ -516,38 +516,38 @@
task_tracker_->AllowRunTasks();
// First run as many tasks as possible on the main thread in parallel with
- // tasks in TaskScheduler. This increases likelihood of TSAN catching
+ // tasks in ThreadPool. This increases likelihood of TSAN catching
// threading errors and eliminates possibility of hangs should a
- // TaskScheduler task synchronously block on a main thread task
- // (TaskScheduler::FlushForTesting() can't be used here for that reason).
+ // ThreadPool task synchronously block on a main thread task
+ // (ThreadPool::FlushForTesting() can't be used here for that reason).
RunLoop().RunUntilIdle();
- // Then halt TaskScheduler. DisallowRunTasks() failing indicates that there
- // were TaskScheduler tasks currently running. In that case, try again from
+ // Then halt ThreadPool. DisallowRunTasks() failing indicates that there
+ // were ThreadPool tasks currently running. In that case, try again from
// top when DisallowRunTasks() yields control back to this thread as they
// may have posted main thread tasks.
if (!task_tracker_->DisallowRunTasks())
continue;
- // Once TaskScheduler is halted. Run any remaining main thread tasks (which
- // may have been posted by TaskScheduler tasks that completed between the
- // above main thread RunUntilIdle() and TaskScheduler DisallowRunTasks()).
+ // Once ThreadPool is halted. Run any remaining main thread tasks (which
+ // may have been posted by ThreadPool tasks that completed between the
+ // above main thread RunUntilIdle() and ThreadPool DisallowRunTasks()).
// Note: this assumes that no main thread task synchronously blocks on a
- // TaskScheduler tasks (it certainly shouldn't); this call could otherwise
+ // ThreadPool tasks (it certainly shouldn't); this call could otherwise
// hang.
RunLoop().RunUntilIdle();
// The above RunUntilIdle() guarantees there are no remaining main thread
- // tasks (the TaskScheduler being halted during the last RunUntilIdle() is
+ // tasks (the ThreadPool being halted during the last RunUntilIdle() is
// key as it prevents a task being posted to it racily with it determining
// it had no work remaining). Therefore, we're done if there is no more work
- // on TaskScheduler either (there can be TaskScheduler work remaining if
+ // on ThreadPool either (there can be ThreadPool work remaining if
// DisallowRunTasks() preempted work and/or the last RunUntilIdle() posted
- // more TaskScheduler tasks).
+ // more ThreadPool tasks).
// Note: this last |if| couldn't be turned into a |do {} while();|. A
// conditional loop makes it such that |continue;| results in checking the
// condition (not unconditionally loop again) which would be incorrect for
- // the above logic as it'd then be possible for a TaskScheduler task to be
+ // the above logic as it'd then be possible for a ThreadPool task to be
// running during the DisallowRunTasks() test, causing it to fail, but then
// post to the main thread and complete before the loop's condition is
// verified which could result in HasIncompleteUndelayedTasksForTesting()
@@ -620,7 +620,7 @@
}
ScopedTaskEnvironment::TestTaskTracker::TestTaskTracker()
- : internal::TaskSchedulerImpl::TaskTrackerImpl("ScopedTaskEnvironment"),
+ : internal::ThreadPoolImpl::TaskTrackerImpl("ScopedTaskEnvironment"),
can_run_tasks_cv_(&lock_),
task_completed_(&lock_) {}
@@ -660,7 +660,7 @@
++num_tasks_running_;
}
- internal::TaskSchedulerImpl::TaskTrackerImpl::RunOrSkipTask(
+ internal::ThreadPoolImpl::TaskTrackerImpl::RunOrSkipTask(
std::move(task), sequence, traits, can_run_task);
{
diff --git a/base/test/scoped_task_environment.h b/base/test/scoped_task_environment.h
index 2716eea..e6ccfc0 100644
--- a/base/test/scoped_task_environment.h
+++ b/base/test/scoped_task_environment.h
@@ -23,7 +23,7 @@
class Clock;
class FileDescriptorWatcher;
-class TaskScheduler;
+class ThreadPool;
class TickClock;
namespace test {
@@ -81,7 +81,7 @@
// The main thread doesn't pump system messages and uses a mock clock for
// delayed tasks (controllable via FastForward*() methods).
// TODO(gab): Make this the default |main_thread_type|.
- // TODO(gab): Also mock the TaskScheduler's clock simultaneously (this
+ // TODO(gab): Also mock the ThreadPool's clock simultaneously (this
// currently only mocks the main thread's clock).
MOCK_TIME,
// The main thread pumps UI messages.
@@ -149,8 +149,8 @@
trait_helpers::HasTrait<SubclassCreatesDefaultTaskRunner>(args...),
trait_helpers::NotATraitTag()) {}
- // Waits until no undelayed TaskScheduler tasks remain. Then, unregisters the
- // TaskScheduler and the (Thread|Sequenced)TaskRunnerHandle.
+ // Waits until no undelayed ThreadPool tasks remain. Then, unregisters the
+ // ThreadPool and the (Thread|Sequenced)TaskRunnerHandle.
virtual ~ScopedTaskEnvironment();
// Returns a TaskRunner that schedules tasks on the main thread.
@@ -161,7 +161,7 @@
bool MainThreadIsIdle() const;
// Runs tasks until both the (Thread|Sequenced)TaskRunnerHandle and the
- // TaskScheduler's non-delayed queues are empty.
+ // ThreadPool's non-delayed queues are empty.
// While RunUntilIdle() is quite practical and sometimes even necessary -- for
// example, to flush all tasks bound to Unretained() state before destroying
// test members -- it should be used with caution per the following warnings:
@@ -182,7 +182,7 @@
// virtual time by |delta|, causing all tasks on the main thread with a
// remaining delay less than or equal to |delta| to be executed before this
// returns. |delta| must be non-negative.
- // TODO(gab): Make this apply to TaskScheduler delayed tasks as well
+ // TODO(gab): Make this apply to ThreadPool delayed tasks as well
// (currently only main thread time is mocked).
void FastForwardBy(TimeDelta delta);
@@ -276,9 +276,9 @@
std::unique_ptr<FileDescriptorWatcher> file_descriptor_watcher_;
#endif
- const TaskScheduler* task_scheduler_ = nullptr;
+ const ThreadPool* thread_pool_ = nullptr;
- // Owned by |task_scheduler_|.
+ // Owned by |thread_pool_|.
TestTaskTracker* const task_tracker_;
// Ensures destruction of lazy TaskRunners when this is destroyed.
diff --git a/base/test/scoped_task_environment_unittest.cc b/base/test/scoped_task_environment_unittest.cc
index f79a971..0dc605f 100644
--- a/base/test/scoped_task_environment_unittest.cc
+++ b/base/test/scoped_task_environment_unittest.cc
@@ -75,17 +75,17 @@
Unretained(&run_until_idle_returned),
Unretained(&first_main_thread_task_ran)));
- AtomicFlag first_task_scheduler_task_ran;
+ AtomicFlag first_thread_pool_task_ran;
PostTask(FROM_HERE, BindOnce(&VerifyRunUntilIdleDidNotReturnAndSetFlag,
Unretained(&run_until_idle_returned),
- Unretained(&first_task_scheduler_task_ran)));
+ Unretained(&first_thread_pool_task_ran)));
- AtomicFlag second_task_scheduler_task_ran;
+ AtomicFlag second_thread_pool_task_ran;
AtomicFlag second_main_thread_task_ran;
PostTaskAndReply(FROM_HERE,
BindOnce(&VerifyRunUntilIdleDidNotReturnAndSetFlag,
Unretained(&run_until_idle_returned),
- Unretained(&second_task_scheduler_task_ran)),
+ Unretained(&second_thread_pool_task_ran)),
BindOnce(&VerifyRunUntilIdleDidNotReturnAndSetFlag,
Unretained(&run_until_idle_returned),
Unretained(&second_main_thread_task_ran)));
@@ -94,8 +94,8 @@
run_until_idle_returned.Set();
EXPECT_TRUE(first_main_thread_task_ran.IsSet());
- EXPECT_TRUE(first_task_scheduler_task_ran.IsSet());
- EXPECT_TRUE(second_task_scheduler_task_ran.IsSet());
+ EXPECT_TRUE(first_thread_pool_task_ran.IsSet());
+ EXPECT_TRUE(second_thread_pool_task_ran.IsSet());
EXPECT_TRUE(second_main_thread_task_ran.IsSet());
}
@@ -186,7 +186,7 @@
},
Unretained(&counter)),
kShortTaskDelay);
- // TODO(gab): This currently doesn't run because the TaskScheduler's clock
+ // TODO(gab): This currently doesn't run because the ThreadPool's clock
// isn't mocked but it should be.
PostDelayedTask(FROM_HERE,
BindOnce(
@@ -403,7 +403,7 @@
// Regression test to ensure that ScopedTaskEnvironment enables the MTA in the
// thread pool (so that the test environment matches that of the browser process
// and com_init_util.h's assertions are happy in unit tests).
-TEST_F(ScopedTaskEnvironmentTest, TaskSchedulerPoolAllowsMTA) {
+TEST_F(ScopedTaskEnvironmentTest, ThreadPoolPoolAllowsMTA) {
ScopedTaskEnvironment scoped_task_environment;
PostTask(FROM_HERE,
BindOnce(&win::AssertComApartmentType, win::ComApartmentType::MTA));
diff --git a/base/test/task_scheduler_test_helpers_android.cc b/base/test/task_scheduler_test_helpers_android.cc
deleted file mode 100644
index 99471fda25..0000000
--- a/base/test/task_scheduler_test_helpers_android.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/task/task_scheduler/task_scheduler.h"
-#include "jni/TaskSchedulerTestHelpers_jni.h"
-
-namespace base {
-
-// TaskSchedulerTestHelpers is a friend of TaskScheduler which grants access to
-// SetExecutionFenceEnabled.
-class TaskSchedulerTestHelpers {
- public:
- // Enables/disables an execution fence that prevents tasks from running.
- static void SetTaskSchedulerExecutionFenceEnabledForTesting(
- bool execution_fence_enabled);
-};
-
-// static
-void TaskSchedulerTestHelpers::SetTaskSchedulerExecutionFenceEnabledForTesting(
- bool execution_fence_enabled) {
- TaskScheduler::GetInstance()->SetExecutionFenceEnabled(
- execution_fence_enabled);
-}
-
-} // namespace base
-
-void JNI_TaskSchedulerTestHelpers_EnableTaskSchedulerExecutionForTesting(
- JNIEnv* env) {
- base::TaskSchedulerTestHelpers::
- SetTaskSchedulerExecutionFenceEnabledForTesting(false);
-}
-
-void JNI_TaskSchedulerTestHelpers_DisableTaskSchedulerExecutionForTesting(
- JNIEnv* env) {
- base::TaskSchedulerTestHelpers::
- SetTaskSchedulerExecutionFenceEnabledForTesting(true);
-}
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index 33bd735..abe4e54 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -27,7 +27,7 @@
#include "base/path_service.h"
#include "base/process/launch.h"
#include "base/process/memory.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/gtest_xml_unittest_result_printer.h"
#include "base/test/gtest_xml_util.h"
#include "base/test/icu_test_util.h"
@@ -121,25 +121,25 @@
// Check for leaks in individual tests.
void OnTestStart(const testing::TestInfo& test) override {
- scheduler_set_before_test_ = TaskScheduler::GetInstance();
+ thread_pool_set_before_test_ = ThreadPool::GetInstance();
}
void OnTestEnd(const testing::TestInfo& test) override {
- DCHECK_EQ(scheduler_set_before_test_, TaskScheduler::GetInstance())
+ DCHECK_EQ(thread_pool_set_before_test_, ThreadPool::GetInstance())
<< " in test " << test.test_case_name() << "." << test.name();
}
// Check for leaks in test cases (consisting of one or more tests).
void OnTestCaseStart(const testing::TestCase& test_case) override {
- scheduler_set_before_case_ = TaskScheduler::GetInstance();
+ thread_pool_set_before_case_ = ThreadPool::GetInstance();
}
void OnTestCaseEnd(const testing::TestCase& test_case) override {
- DCHECK_EQ(scheduler_set_before_case_, TaskScheduler::GetInstance())
+ DCHECK_EQ(thread_pool_set_before_case_, ThreadPool::GetInstance())
<< " in case " << test_case.name();
}
private:
- TaskScheduler* scheduler_set_before_test_ = nullptr;
- TaskScheduler* scheduler_set_before_case_ = nullptr;
+ ThreadPool* thread_pool_set_before_test_ = nullptr;
+ ThreadPool* thread_pool_set_before_case_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(CheckForLeakedGlobals);
};
diff --git a/base/test/thread_pool_test_helpers_android.cc b/base/test/thread_pool_test_helpers_android.cc
new file mode 100644
index 0000000..7ff3f53
--- /dev/null
+++ b/base/test/thread_pool_test_helpers_android.cc
@@ -0,0 +1,37 @@
+// Copyright (c) 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/task/thread_pool/thread_pool.h"
+#include "jni/ThreadPoolTestHelpers_jni.h"
+
+namespace base {
+
+// ThreadPoolTestHelpers is a friend of ThreadPool which grants access to
+// SetExecutionFenceEnabled.
+class ThreadPoolTestHelpers {
+ public:
+ // Enables/disables an execution fence that prevents tasks from running.
+ static void SetThreadPoolExecutionFenceEnabledForTesting(
+ bool execution_fence_enabled);
+};
+
+// static
+void ThreadPoolTestHelpers::SetThreadPoolExecutionFenceEnabledForTesting(
+ bool execution_fence_enabled) {
+ ThreadPool::GetInstance()->SetExecutionFenceEnabled(execution_fence_enabled);
+}
+
+} // namespace base
+
+void JNI_ThreadPoolTestHelpers_EnableThreadPoolExecutionForTesting(
+ JNIEnv* env) {
+ base::ThreadPoolTestHelpers::SetThreadPoolExecutionFenceEnabledForTesting(
+ false);
+}
+
+void JNI_ThreadPoolTestHelpers_DisableThreadPoolExecutionForTesting(
+ JNIEnv* env) {
+ base::ThreadPoolTestHelpers::SetThreadPoolExecutionFenceEnabledForTesting(
+ true);
+}
diff --git a/base/threading/scoped_blocking_call.h b/base/threading/scoped_blocking_call.h
index 4ca728d..9161f20 100644
--- a/base/threading/scoped_blocking_call.h
+++ b/base/threading/scoped_blocking_call.h
@@ -109,7 +109,7 @@
// FROM_HERE, BlockingType::WILL_BLOCK);
// waitable_event.Wait(); // Wait() instantiates its own ScopedBlockingCall.
//
-// When a ScopedBlockingCall is instantiated from a TaskScheduler parallel or
+// When a ScopedBlockingCall is instantiated from a ThreadPool parallel or
// sequenced task, the thread pool size is incremented to compensate for the
// blocked thread (more or less aggressively depending on BlockingType).
class BASE_EXPORT ScopedBlockingCall
@@ -163,7 +163,7 @@
BASE_EXPORT void ClearBlockingObserverForTesting();
// Unregisters the |blocking_observer| on the current thread within its scope.
-// Used in TaskScheduler tests to prevent calls to //base sync primitives from
+// Used in ThreadPool tests to prevent calls to //base sync primitives from
// affecting the thread pool capacity.
class BASE_EXPORT ScopedClearBlockingObserverForTesting {
public:
diff --git a/base/threading/sequence_local_storage_slot.h b/base/threading/sequence_local_storage_slot.h
index 315df7d..1d6dd7c 100644
--- a/base/threading/sequence_local_storage_slot.h
+++ b/base/threading/sequence_local_storage_slot.h
@@ -46,7 +46,7 @@
//
// SequenceLocalStorageSlot must be used within the scope of a
// ScopedSetSequenceLocalStorageMapForCurrentThread object.
-// Note: this is true on all TaskScheduler workers and on threads bound to a
+// Note: this is true on all ThreadPool workers and on threads bound to a
// MessageLoop.
template <typename T, typename Deleter = std::default_delete<T>>
class SequenceLocalStorageSlot {
diff --git a/base/threading/sequenced_task_runner_handle_unittest.cc b/base/threading/sequenced_task_runner_handle_unittest.cc
index 00d21b8..f178585 100644
--- a/base/threading/sequenced_task_runner_handle_unittest.cc
+++ b/base/threading/sequenced_task_runner_handle_unittest.cc
@@ -57,7 +57,7 @@
RunLoop().RunUntilIdle();
}
-TEST_F(SequencedTaskRunnerHandleTest, FromTaskSchedulerSequencedTask) {
+TEST_F(SequencedTaskRunnerHandleTest, FromThreadPoolSequencedTask) {
base::CreateSequencedTaskRunnerWithTraits({})->PostTask(
FROM_HERE,
base::BindOnce(
diff --git a/base/threading/thread_checker.h b/base/threading/thread_checker.h
index 0d744683..d1f5bb2 100644
--- a/base/threading/thread_checker.h
+++ b/base/threading/thread_checker.h
@@ -89,7 +89,7 @@
// Note that ThreadCheckerImpl::CalledOnValidThread() returns false when called
// from tasks posted to SingleThreadTaskRunners bound to different sequences,
// even if the tasks happen to run on the same thread (e.g. two independent
-// SingleThreadTaskRunners on the TaskScheduler that happen to share a thread).
+// SingleThreadTaskRunners on the ThreadPool that happen to share a thread).
#if DCHECK_IS_ON()
class ThreadChecker : public ThreadCheckerImpl {
};
diff --git a/base/threading/thread_checker_impl.h b/base/threading/thread_checker_impl.h
index 103dfe7..83378f06 100644
--- a/base/threading/thread_checker_impl.h
+++ b/base/threading/thread_checker_impl.h
@@ -51,7 +51,7 @@
mutable TaskToken task_token_;
// SequenceToken for which CalledOnValidThread() may return true. Used to
- // ensure that CalledOnValidThread() doesn't return true for TaskScheduler
+ // ensure that CalledOnValidThread() doesn't return true for ThreadPool
// tasks that happen to run on the same thread but weren't posted to the same
// SingleThreadTaskRunner.
mutable SequenceToken sequence_token_;
diff --git a/base/threading/thread_restrictions.cc b/base/threading/thread_restrictions.cc
index 3b21886a..0f33688 100644
--- a/base/threading/thread_restrictions.cc
+++ b/base/threading/thread_restrictions.cc
@@ -33,7 +33,7 @@
void AssertBlockingAllowed() {
DCHECK(!g_blocking_disallowed.Get().Get())
<< "Function marked as blocking was called from a scope that disallows "
- "blocking! If this task is running inside the TaskScheduler, it needs "
+ "blocking! If this task is running inside the ThreadPool, it needs "
"to have MayBlock() in its TaskTraits. Otherwise, consider making "
"this blocking work asynchronous or, as a last resort, you may use "
"ScopedAllowBlocking (see its documentation for best practices).";
diff --git a/base/threading/thread_restrictions.h b/base/threading/thread_restrictions.h
index 48dad766..6ad6729 100644
--- a/base/threading/thread_restrictions.h
+++ b/base/threading/thread_restrictions.h
@@ -53,7 +53,7 @@
// Avoid using allowances outside of unit tests. In unit tests, use allowances
// with the suffix "ForTesting".
//
-// Prefer making blocking calls from tasks posted to base::TaskScheduler with
+// Prefer making blocking calls from tasks posted to base::ThreadPool with
// base::MayBlock().
//
// Instead of waiting on a WaitableEvent or a ConditionVariable, prefer putting
diff --git a/base/trace_event/builtin_categories.h b/base/trace_event/builtin_categories.h
index f65a2ae..0a0fb37 100644
--- a/base/trace_event/builtin_categories.h
+++ b/base/trace_event/builtin_categories.h
@@ -124,7 +124,7 @@
X("startup") \
X("sync") \
X("sync_lock_contention") \
- X("task_scheduler") \
+ X("thread_pool") \
X("test_gpu") \
X("test_tracing") \
X("toplevel") \
@@ -195,7 +195,7 @@
X(TRACE_DISABLED_BY_DEFAULT("skia.gpu.cache")) \
X(TRACE_DISABLED_BY_DEFAULT("SyncFileSystem")) \
X(TRACE_DISABLED_BY_DEFAULT("system_stats")) \
- X(TRACE_DISABLED_BY_DEFAULT("task_scheduler_diagnostics")) \
+ X(TRACE_DISABLED_BY_DEFAULT("thread_pool_diagnostics")) \
X(TRACE_DISABLED_BY_DEFAULT("toplevel.flow")) \
X(TRACE_DISABLED_BY_DEFAULT("v8.compile")) \
X(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profiler")) \
diff --git a/base/win/com_init_check_hook.cc b/base/win/com_init_check_hook.cc
index 43a9933..e58ec83 100644
--- a/base/win/com_init_check_hook.cc
+++ b/base/win/com_init_check_hook.cc
@@ -269,7 +269,7 @@
// evaluate your threading guarantees and dispatch your work with
// base::CreateCOMSTATaskRunnerWithTraits().
//
- // If you need MTA support, ping //base/task/task_scheduler/OWNERS.
+ // If you need MTA support, ping //base/task/thread_pool/OWNERS.
AssertComInitialized(
"CoCreateInstance calls in Chromium require explicit COM "
"initialization via base::CreateCOMSTATaskRunnerWithTraits() or "
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 9f89fdb..09d95cd 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -1964,7 +1964,7 @@
"//components/sync_bookmarks",
"//components/sync_preferences",
"//components/sync_sessions",
- "//components/task_scheduler_util",
+ "//components/thread_pool_util",
"//components/tracing:startup_tracing",
"//components/translate/content/browser",
"//components/translate/core/browser",
diff --git a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc
index d684832..8537134 100644
--- a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc
+++ b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc
@@ -1231,7 +1231,7 @@
remover_->RemoveAndReply(
delete_begin, delete_end, remove_mask, origin_type_mask,
&completion_observer);
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
completion_observer.BlockUntilCompletion();
}
@@ -1246,7 +1246,7 @@
delete_begin, delete_end, remove_mask,
content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB,
std::move(filter_builder), &completion_observer);
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
completion_observer.BlockUntilCompletion();
}
diff --git a/chrome/browser/browsing_data/counters/autofill_counter_browsertest.cc b/chrome/browser/browsing_data/counters/autofill_counter_browsertest.cc
index f844cd0..325e1b7 100644
--- a/chrome/browser/browsing_data/counters/autofill_counter_browsertest.cc
+++ b/chrome/browser/browsing_data/counters/autofill_counter_browsertest.cc
@@ -332,20 +332,20 @@
AddAutocompleteSuggestion("email", "example@example.com");
AddCreditCard("0000-0000-0000-0000", "1", "2015", "1");
AddAddress("John", "Doe", "Main Street 12345");
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
const base::Time kTime2 = kTime1 + base::TimeDelta::FromSeconds(10);
test_clock.SetNow(kTime2);
AddCreditCard("0123-4567-8910-1112", "10", "2015", "1");
AddAddress("Jane", "Smith", "Main Street 12346");
AddAddress("John", "Smith", "Side Street 47");
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
const base::Time kTime3 = kTime2 + base::TimeDelta::FromSeconds(10);
test_clock.SetNow(kTime3);
AddAutocompleteSuggestion("tel", "+987654321");
AddCreditCard("1211-1098-7654-3210", "10", "2030", "1");
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
// Test the results for different starting points.
struct TestCase {
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 79958b5..135762c8f 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -258,7 +258,7 @@
#include "components/signin/core/browser/account_consistency_method.h"
#include "components/spellcheck/spellcheck_buildflags.h"
#include "components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.h"
-#include "components/task_scheduler_util/variations_util.h"
+#include "components/thread_pool_util/variations_util.h"
#include "components/translate/core/common/translate_switches.h"
#include "components/url_formatter/url_fixer.h"
#include "components/variations/variations_associated_data.h"
@@ -4590,9 +4590,9 @@
}
#endif // BUILDFLAG(ENABLE_MEDIA_REMOTING)
-std::unique_ptr<base::TaskScheduler::InitParams>
-ChromeContentBrowserClient::GetTaskSchedulerInitParams() {
- return task_scheduler_util::GetTaskSchedulerInitParamsForBrowser();
+std::unique_ptr<base::ThreadPool::InitParams>
+ChromeContentBrowserClient::GetThreadPoolInitParams() {
+ return thread_pool_util::GetThreadPoolInitParamsForBrowser();
}
base::FilePath ChromeContentBrowserClient::GetLoggingFileName(
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h
index 138a10e..e8b6c8c 100644
--- a/chrome/browser/chrome_content_browser_client.h
+++ b/chrome/browser/chrome_content_browser_client.h
@@ -453,7 +453,7 @@
media::mojom::RemotingSourcePtr source,
media::mojom::RemoterRequest request) final;
#endif // BUILDFLAG(ENABLE_MEDIA_REMOTING)
- std::unique_ptr<base::TaskScheduler::InitParams> GetTaskSchedulerInitParams()
+ std::unique_ptr<base::ThreadPool::InitParams> GetThreadPoolInitParams()
override;
base::FilePath GetLoggingFileName(
const base::CommandLine& command_line) override;
diff --git a/chrome/browser/chromeos/arc/fileapi/file_stream_forwarder.cc b/chrome/browser/chromeos/arc/fileapi/file_stream_forwarder.cc
index b75e760d..123953c 100644
--- a/chrome/browser/chromeos/arc/fileapi/file_stream_forwarder.cc
+++ b/chrome/browser/chromeos/arc/fileapi/file_stream_forwarder.cc
@@ -10,8 +10,8 @@
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/net_errors.h"
@@ -39,12 +39,12 @@
remaining_size_(size),
fd_dest_(std::move(fd_dest)),
callback_(std::move(callback)),
- task_runner_(base::TaskScheduler::GetInstance()
- ->CreateSequencedTaskRunnerWithTraits(
- // It's safe to shutdown without waiting for the
- // completion of tasks running with this task runner.
- {base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN,
- base::MayBlock()})),
+ task_runner_(
+ base::ThreadPool::GetInstance()->CreateSequencedTaskRunnerWithTraits(
+ // It's safe to shutdown without waiting for the
+ // completion of tasks running with this task runner.
+ {base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN,
+ base::MayBlock()})),
buf_(base::MakeRefCounted<net::IOBufferWithSize>(kBufSize)),
weak_ptr_factory_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
index 8527557..1450ae00 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -30,8 +30,8 @@
#include "base/strings/string_split.h"
#include "base/system/sys_info.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part_chromeos.h"
#include "chrome/browser/chrome_notification_types.h"
diff --git a/chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc b/chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc
index 58acedc..8aab51e 100644
--- a/chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc
+++ b/chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc
@@ -464,8 +464,8 @@
"extension_3", base::Bind(&AddFileWatchCallback));
// event_router->addFileWatch create some tasks which are performed on
- // TaskScheduler. Wait until they are done.
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ // ThreadPool. Wait until they are done.
+ base::ThreadPool::GetInstance()->FlushForTesting();
// We also wait the UI thread here, since some tasks which are performed
// above message loop back results to the UI thread.
base::RunLoop().RunUntilIdle();
@@ -506,8 +506,8 @@
"extension_3");
// event_router->addFileWatch create some tasks which are performed on
- // TaskScheduler. Wait until they are done.
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ // ThreadPool. Wait until they are done.
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, ContentChecksum) {
diff --git a/chrome/browser/chromeos/file_manager/file_watcher_unittest.cc b/chrome/browser/chromeos/file_manager/file_watcher_unittest.cc
index d7ebb9b..486a76b 100644
--- a/chrome/browser/chromeos/file_manager/file_watcher_unittest.cc
+++ b/chrome/browser/chromeos/file_manager/file_watcher_unittest.cc
@@ -9,7 +9,7 @@
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "google_apis/drive/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/browser/chromeos/power/auto_screen_brightness/adapter_unittest.cc b/chrome/browser/chromeos/power/auto_screen_brightness/adapter_unittest.cc
index 5bcba2c83..60dc595d 100644
--- a/chrome/browser/chromeos/power/auto_screen_brightness/adapter_unittest.cc
+++ b/chrome/browser/chromeos/power/auto_screen_brightness/adapter_unittest.cc
@@ -10,7 +10,7 @@
#include "ash/public/cpp/ash_pref_names.h"
#include "base/memory/ptr_util.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_task_environment.h"
@@ -156,7 +156,7 @@
void TearDown() override {
adapter_.reset();
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
chromeos::PowerManagerClient::Shutdown();
}
diff --git a/chrome/browser/chromeos/power/auto_screen_brightness/brightness_monitor_impl_unittest.cc b/chrome/browser/chromeos/power/auto_screen_brightness/brightness_monitor_impl_unittest.cc
index 0ca92674..97ec97b 100644
--- a/chrome/browser/chromeos/power/auto_screen_brightness/brightness_monitor_impl_unittest.cc
+++ b/chrome/browser/chromeos/power/auto_screen_brightness/brightness_monitor_impl_unittest.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/chromeos/power/auto_screen_brightness/brightness_monitor_impl.h"
#include "base/memory/ptr_util.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_task_environment.h"
#include "base/threading/sequenced_task_runner_handle.h"
@@ -80,7 +80,7 @@
test_observer_.reset();
monitor_.reset();
PowerManagerClient::Shutdown();
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
// Creates and initializes |monitor_| and optionally sets initial brightness
diff --git a/chrome/browser/chromeos/power/auto_screen_brightness/model_config_loader_impl_unittest.cc b/chrome/browser/chromeos/power/auto_screen_brightness/model_config_loader_impl_unittest.cc
index 6fbb466..cc33291 100644
--- a/chrome/browser/chromeos/power/auto_screen_brightness/model_config_loader_impl_unittest.cc
+++ b/chrome/browser/chromeos/power/auto_screen_brightness/model_config_loader_impl_unittest.cc
@@ -12,7 +12,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_task_environment.h"
#include "base/test/test_mock_time_task_runner.h"
@@ -62,7 +62,7 @@
}
~ModelConfigLoaderImplTest() override {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
void Init(const std::string& model_params,
diff --git a/chrome/browser/chromeos/power/auto_screen_brightness/modeller_impl_unittest.cc b/chrome/browser/chromeos/power/auto_screen_brightness/modeller_impl_unittest.cc
index f15efbb..9a7a9c4 100644
--- a/chrome/browser/chromeos/power/auto_screen_brightness/modeller_impl_unittest.cc
+++ b/chrome/browser/chromeos/power/auto_screen_brightness/modeller_impl_unittest.cc
@@ -186,7 +186,7 @@
}
~ModellerImplTest() override {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
// Sets up |modeller_| with a FakeTrainer.
diff --git a/chrome/browser/chromeos/settings/device_oauth2_token_service_unittest.cc b/chrome/browser/chromeos/settings/device_oauth2_token_service_unittest.cc
index 2f6414f8..6175128 100644
--- a/chrome/browser/chromeos/settings/device_oauth2_token_service_unittest.cc
+++ b/chrome/browser/chromeos/settings/device_oauth2_token_service_unittest.cc
@@ -11,7 +11,7 @@
#include <utility>
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/chromeos/policy/device_policy_builder.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
@@ -112,7 +112,7 @@
void TearDown() override {
oauth2_service_.reset();
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
DeviceSettingsService::Get()->UnsetSessionManager();
SystemSaltGetter::Shutdown();
CryptohomeClient::Shutdown();
diff --git a/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc b/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc
index 51d7bd7..d039f93 100644
--- a/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc
+++ b/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc
@@ -14,7 +14,7 @@
#include "base/memory/ref_counted.h"
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_task_environment.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/test_mock_time_task_runner.h"
@@ -264,7 +264,7 @@
}
void TestAutomaticRebootManagerTaskRunner::OnBeforeSelectingTask() {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
void TestAutomaticRebootManagerTaskRunner::OnAfterTimePassed() {
@@ -272,7 +272,7 @@
}
void TestAutomaticRebootManagerTaskRunner::OnAfterTaskRun() {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
MockAutomaticRebootManagerObserver::MockAutomaticRebootManagerObserver()
diff --git a/chrome/browser/downgrade/user_data_downgrade_browsertest.cc b/chrome/browser/downgrade/user_data_downgrade_browsertest.cc
index 27716b0..b9a11dd 100644
--- a/chrome/browser/downgrade/user_data_downgrade_browsertest.cc
+++ b/chrome/browser/downgrade/user_data_downgrade_browsertest.cc
@@ -7,7 +7,7 @@
#include "base/files/file_util.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/test_reg_util_win.h"
#include "base/threading/thread_restrictions.h"
#include "base/version.h"
@@ -100,7 +100,7 @@
// downgrade.
IN_PROC_BROWSER_TEST_F(UserDataDowngradeBrowserCopyAndCleanTest, Test) {
base::ScopedAllowBlockingForTesting allow_blocking;
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
EXPECT_EQ(chrome::kChromeVersion, GetLastVersion(user_data_dir_).GetString());
ASSERT_FALSE(base::PathExists(other_file_));
}
diff --git a/chrome/browser/engagement/site_engagement_service.cc b/chrome/browser/engagement/site_engagement_service.cc
index 9c41026..07c6d30 100644
--- a/chrome/browser/engagement/site_engagement_service.cc
+++ b/chrome/browser/engagement/site_engagement_service.cc
@@ -477,7 +477,7 @@
// purposes.
//
// The profile and its KeyedServices are normally destroyed before the
- // TaskScheduler shuts down background threads, so the task needs to hold a
+ // ThreadPool shuts down background threads, so the task needs to hold a
// strong reference to HostContentSettingsMap (which supports outliving the
// profile), and needs to avoid using any members of SiteEngagementService
// (which does not). See https://crbug.com/900022.
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 40e31a2..2f07dd2 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -294,7 +294,7 @@
base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks();
if (net_log_)
- net_log_->ShutDownBeforeTaskScheduler();
+ net_log_->ShutDownBeforeThreadPool();
}
// static
diff --git a/chrome/browser/lifetime/browser_shutdown.cc b/chrome/browser/lifetime/browser_shutdown.cc
index 123028a..a990ab2 100644
--- a/chrome/browser/lifetime/browser_shutdown.cc
+++ b/chrome/browser/lifetime/browser_shutdown.cc
@@ -266,7 +266,7 @@
base::FilePath shutdown_ms_file = GetShutdownMsPath();
// Note: ReadLastShutdownFile() is done as a BLOCK_SHUTDOWN task so there's
// an implicit sequencing between it and this write which happens after
- // threads have been stopped (and thus TaskScheduler::Shutdown() is
+ // threads have been stopped (and thus ThreadPool::Shutdown() is
// complete).
base::WriteFile(shutdown_ms_file, shutdown_ms.c_str(), len);
}
diff --git a/chrome/browser/mac/keystone_glue.mm b/chrome/browser/mac/keystone_glue.mm
index 2394874..985fd3e2 100644
--- a/chrome/browser/mac/keystone_glue.mm
+++ b/chrome/browser/mac/keystone_glue.mm
@@ -73,7 +73,7 @@
return [file stringByStandardizingPath];
}
-// Adaptor for scheduling an Objective-C method call in TaskScheduler.
+// Adaptor for scheduling an Objective-C method call in ThreadPool.
class PerformBridge : public base::RefCountedThreadSafe<PerformBridge> {
public:
diff --git a/chrome/browser/media/router/discovery/discovery_network_monitor_unittest.cc b/chrome/browser/media/router/discovery/discovery_network_monitor_unittest.cc
index 01ffa80..4a10306 100644
--- a/chrome/browser/media/router/discovery/discovery_network_monitor_unittest.cc
+++ b/chrome/browser/media/router/discovery/discovery_network_monitor_unittest.cc
@@ -9,7 +9,7 @@
#include "base/bind.h"
#include "base/memory/ptr_util.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/browser/media/webrtc/webrtc_rtp_dump_handler_unittest.cc b/chrome/browser/media/webrtc/webrtc_rtp_dump_handler_unittest.cc
index 85da228..5d3e765 100644
--- a/chrome/browser/media/webrtc/webrtc_rtp_dump_handler_unittest.cc
+++ b/chrome/browser/media/webrtc/webrtc_rtp_dump_handler_unittest.cc
@@ -18,7 +18,7 @@
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/media/webrtc/webrtc_rtp_dump_writer.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -102,7 +102,7 @@
}
void FlushTaskRunners() {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
base::RunLoop().RunUntilIdle();
}
diff --git a/chrome/browser/notifications/notification_channels_provider_android_unittest.cc b/chrome/browser/notifications/notification_channels_provider_android_unittest.cc
index 96346df..8e3c0a2 100644
--- a/chrome/browser/notifications/notification_channels_provider_android_unittest.cc
+++ b/chrome/browser/notifications/notification_channels_provider_android_unittest.cc
@@ -10,7 +10,7 @@
#include "base/feature_list.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "base/time/clock.h"
diff --git a/chrome/browser/previews/hints_fetcher_browsertest.cc b/chrome/browser/previews/hints_fetcher_browsertest.cc
index fa3a735..219debe 100644
--- a/chrome/browser/previews/hints_fetcher_browsertest.cc
+++ b/chrome/browser/previews/hints_fetcher_browsertest.cc
@@ -10,7 +10,7 @@
#include "base/command_line.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
@@ -65,7 +65,7 @@
int count) {
int total = 0;
while (true) {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
base::RunLoop().RunUntilIdle();
total = GetTotalHistogramSamples(histogram_tester, histogram_name);
diff --git a/chrome/browser/previews/previews_browsertest.cc b/chrome/browser/previews/previews_browsertest.cc
index 07b8714..871e128 100644
--- a/chrome/browser/previews/previews_browsertest.cc
+++ b/chrome/browser/previews/previews_browsertest.cc
@@ -9,7 +9,7 @@
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/values_test_util.h"
@@ -53,7 +53,7 @@
const std::string& histogram_name,
size_t count) {
while (true) {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
base::RunLoop().RunUntilIdle();
content::FetchHistogramsFromChildProcesses();
diff --git a/chrome/browser/previews/resource_loading_hints/resource_loading_hints_browsertest.cc b/chrome/browser/previews/resource_loading_hints/resource_loading_hints_browsertest.cc
index 8d67c53..303312b 100644
--- a/chrome/browser/previews/resource_loading_hints/resource_loading_hints_browsertest.cc
+++ b/chrome/browser/previews/resource_loading_hints/resource_loading_hints_browsertest.cc
@@ -10,7 +10,7 @@
#include "base/command_line.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
@@ -49,7 +49,7 @@
const std::string& histogram_name,
size_t count) {
while (true) {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
base::RunLoop().RunUntilIdle();
content::FetchHistogramsFromChildProcesses();
diff --git a/chrome/browser/profiles/profile_browsertest.cc b/chrome/browser/profiles/profile_browsertest.cc
index 9035338..f9837b36 100644
--- a/chrome/browser/profiles/profile_browsertest.cc
+++ b/chrome/browser/profiles/profile_browsertest.cc
@@ -24,7 +24,7 @@
#include "base/sequenced_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_restrictions.h"
@@ -218,7 +218,7 @@
// This prevents HistoryBackend from accessing its databases after the
// directory that contains them has been deleted.
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
} // namespace
diff --git a/chrome/browser/resource_coordinator/leveldb_site_characteristics_database.cc b/chrome/browser/resource_coordinator/leveldb_site_characteristics_database.cc
index 3b21f82e..62fdc98 100644
--- a/chrome/browser/resource_coordinator/leveldb_site_characteristics_database.cc
+++ b/chrome/browser/resource_coordinator/leveldb_site_characteristics_database.cc
@@ -111,7 +111,7 @@
"database_metadata";
// Helper class used to run all the blocking operations posted by
-// LocalSiteCharacteristicDatabase on a TaskScheduler sequence with the
+// LocalSiteCharacteristicDatabase on a ThreadPool sequence with the
// |MayBlock()| trait.
//
// Instances of this class should only be destructed once all the posted tasks
diff --git a/chrome/browser/safe_browsing/download_protection/download_protection_service_unittest.cc b/chrome/browser/safe_browsing/download_protection/download_protection_service_unittest.cc
index 8c0730d..794a93c 100644
--- a/chrome/browser/safe_browsing/download_protection/download_protection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/download_protection/download_protection_service_unittest.cc
@@ -26,7 +26,7 @@
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/bind_test_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
@@ -338,7 +338,7 @@
// Flushes any pending tasks in the message loops of all threads.
void FlushThreadMessageLoops() {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
FlushMessageLoop(BrowserThread::IO);
RunLoop().RunUntilIdle();
}
diff --git a/chrome/browser/search/instant_service_unittest.cc b/chrome/browser/search/instant_service_unittest.cc
index e7dcd1f9..441588a0 100644
--- a/chrome/browser/search/instant_service_unittest.cc
+++ b/chrome/browser/search/instant_service_unittest.cc
@@ -361,7 +361,7 @@
base::FilePath path(profile_path.AppendASCII(
chrome::kChromeSearchLocalNtpBackgroundFilename));
base::WriteFile(path, "background_image", 16);
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
instant_service_->SelectLocalBackgroundImage(path);
thread_bundle()->RunUntilIdle();
@@ -386,7 +386,7 @@
base::FilePath path(profile_path.AppendASCII(
chrome::kChromeSearchLocalNtpBackgroundFilename));
base::WriteFile(path, "background_image", 16);
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
instant_service_->SelectLocalBackgroundImage(path);
thread_bundle()->RunUntilIdle();
@@ -521,7 +521,7 @@
base::FilePath path(profile_path.AppendASCII(
chrome::kChromeSearchLocalNtpBackgroundFilename));
base::WriteFile(path, "background_image", 16);
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
instant_service_->SelectLocalBackgroundImage(path);
thread_bundle()->RunUntilIdle();
diff --git a/chrome/browser/sync/profile_sync_service_factory_unittest.cc b/chrome/browser/sync/profile_sync_service_factory_unittest.cc
index b0d48be..4964a6a 100644
--- a/chrome/browser/sync/profile_sync_service_factory_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_factory_unittest.cc
@@ -10,7 +10,7 @@
#include "base/command_line.h"
#include "base/feature_list.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
#include "chrome/common/buildflags.h"
#include "chrome/test/base/testing_profile.h"
@@ -34,7 +34,7 @@
}
void TearDown() override {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
protected:
diff --git a/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc b/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc
index 61863563..88dfdbf 100644
--- a/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc
+++ b/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc
@@ -15,7 +15,7 @@
#include "base/sequenced_task_runner.h"
#include "base/stl_util.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/sync_file_system/drive_backend/callback_helper.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h"
@@ -149,7 +149,7 @@
local_sync_service_.reset();
remote_sync_service_.reset();
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
RevokeSyncableFileSystem();
}
diff --git a/chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc b/chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc
index 5ed7b6b..3097334 100644
--- a/chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc
+++ b/chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc
@@ -145,7 +145,7 @@
file_system_->TearDown();
RevokeSyncableFileSystem();
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
content::RunAllPendingInMessageLoop(BrowserThread::IO);
}
diff --git a/chrome/browser/sync_file_system/sync_file_system_service_unittest.cc b/chrome/browser/sync_file_system/sync_file_system_service_unittest.cc
index 50307c6..8235e0c7 100644
--- a/chrome/browser/sync_file_system/sync_file_system_service_unittest.cc
+++ b/chrome/browser/sync_file_system/sync_file_system_service_unittest.cc
@@ -168,7 +168,7 @@
sync_service_->Shutdown();
file_system_->TearDown();
RevokeSyncableFileSystem();
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
void InitializeApp() {
diff --git a/chrome/browser/ui/libgtkui/select_file_dialog_impl_gtk_unittest.cc b/chrome/browser/ui/libgtkui/select_file_dialog_impl_gtk_unittest.cc
index ddd01834..853ea80 100644
--- a/chrome/browser/ui/libgtkui/select_file_dialog_impl_gtk_unittest.cc
+++ b/chrome/browser/ui/libgtkui/select_file_dialog_impl_gtk_unittest.cc
@@ -4,7 +4,7 @@
#include "chrome/browser/ui/libgtkui/select_file_dialog_impl_gtk.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/libgtkui/gtk_ui.h"
#include "chrome/test/base/scoped_testing_local_state.h"
@@ -108,7 +108,7 @@
EXPECT_FALSE(file_picker.canCreateFolder());
EXPECT_STREQ("Select Folder", file_picker.getTitle());
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
RunLoop().RunUntilIdle();
}
@@ -123,7 +123,7 @@
EXPECT_FALSE(file_picker.canCreateFolder());
EXPECT_STREQ("Select Folder to Upload", file_picker.getTitle());
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
RunLoop().RunUntilIdle();
}
@@ -138,7 +138,7 @@
EXPECT_TRUE(file_picker.canCreateFolder());
EXPECT_STREQ("Select Folder", file_picker.getTitle());
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
RunLoop().RunUntilIdle();
}
diff --git a/chrome/browser/ui/media_router/media_router_file_dialog_unittest.cc b/chrome/browser/ui/media_router/media_router_file_dialog_unittest.cc
index 0be7802..a992988 100644
--- a/chrome/browser/ui/media_router/media_router_file_dialog_unittest.cc
+++ b/chrome/browser/ui/media_router/media_router_file_dialog_unittest.cc
@@ -8,7 +8,7 @@
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "chrome/common/media_router/issue.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -29,7 +29,7 @@
// Clears out async tasks
void FlushTasks() {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
base::RunLoop().RunUntilIdle();
}
diff --git a/chrome/browser/ui/webui/chromeos/image_source.cc b/chrome/browser/ui/webui/chromeos/image_source.cc
index 5fe26023..0c8e627 100644
--- a/chrome/browser/ui/webui/chromeos/image_source.cc
+++ b/chrome/browser/ui/webui/chromeos/image_source.cc
@@ -16,7 +16,7 @@
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/chromeos/login/users/avatar/user_image_loader.h"
#include "chrome/common/url_constants.h"
diff --git a/chrome/browser/ui/webui/chromeos/video_source.cc b/chrome/browser/ui/webui/chromeos/video_source.cc
index c269329..c42955ad 100644
--- a/chrome/browser/ui/webui/chromeos/video_source.cc
+++ b/chrome/browser/ui/webui/chromeos/video_source.cc
@@ -14,7 +14,7 @@
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/task_runner_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/common/url_constants.h"
diff --git a/chrome/browser/ui/webui/policy_ui_browsertest.cc b/chrome/browser/ui/webui/policy_ui_browsertest.cc
index 4493949..50f55fa 100644
--- a/chrome/browser/ui/webui/policy_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/policy_ui_browsertest.cc
@@ -327,7 +327,7 @@
browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_TRUE(content::ExecuteScript(contents, javascript));
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
// Open the created file.
base::ScopedAllowBlockingForTesting allow_blocking;
std::string file_contents;
diff --git a/chrome/browser/vr/testapp/vr_testapp.cc b/chrome/browser/vr/testapp/vr_testapp.cc
index ed71109e..884eb87e 100644
--- a/chrome/browser/vr/testapp/vr_testapp.cc
+++ b/chrome/browser/vr/testapp/vr_testapp.cc
@@ -10,7 +10,7 @@
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "chrome/browser/vr/base_graphics_delegate.h"
@@ -287,7 +287,7 @@
// Build UI thread message loop. This is used by platform
// implementations for event polling & running background tasks.
base::MessageLoopForUI message_loop;
- base::TaskScheduler::CreateAndStartWithDefaultParams("VrUiViewer");
+ base::ThreadPool::CreateAndStartWithDefaultParams("VrUiViewer");
ui::OzonePlatform::InitParams params;
params.single_process = true;
diff --git a/chrome/chrome_cleaner/executables/chrome_cleaner_main.cc b/chrome/chrome_cleaner/executables/chrome_cleaner_main.cc
index 178ec89..1a43f79 100644
--- a/chrome/chrome_cleaner/executables/chrome_cleaner_main.cc
+++ b/chrome/chrome_cleaner/executables/chrome_cleaner_main.cc
@@ -22,7 +22,7 @@
#include "base/run_loop.h"
#include "base/sequenced_task_runner.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/version.h"
@@ -445,7 +445,7 @@
PLOG(ERROR) << "Can't SetPriorityClass to NORMAL_PRIORITY_CLASS";
}
- base::TaskScheduler::CreateAndStartWithDefaultParams("chrome cleanup tool");
+ base::ThreadPool::CreateAndStartWithDefaultParams("chrome cleanup tool");
chrome_cleaner::SandboxType sandbox_type =
is_sandbox_target ? chrome_cleaner::SandboxProcessType()
diff --git a/chrome/chrome_cleaner/executables/chrome_reporter_main.cc b/chrome/chrome_cleaner/executables/chrome_reporter_main.cc
index 4c189e0..917d02b 100644
--- a/chrome/chrome_cleaner/executables/chrome_reporter_main.cc
+++ b/chrome/chrome_cleaner/executables/chrome_reporter_main.cc
@@ -23,7 +23,7 @@
#include "base/sequenced_task_runner.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/win/registry.h"
#include "base/win/scoped_com_initializer.h"
@@ -232,7 +232,7 @@
// Many pieces of code below need a message loop to have been instantiated
// before them.
- base::TaskScheduler::CreateAndStartWithDefaultParams("software reporter");
+ base::ThreadPool::CreateAndStartWithDefaultParams("software reporter");
base::MessageLoopForUI ui_message_loop;
shutdown_sequence.mojo_task_runner = MojoTaskRunner::Create();
diff --git a/chrome/chrome_cleaner/executables/shutdown_sequence.cc b/chrome/chrome_cleaner/executables/shutdown_sequence.cc
index 5d50ca29..c87398d 100644
--- a/chrome/chrome_cleaner/executables/shutdown_sequence.cc
+++ b/chrome/chrome_cleaner/executables/shutdown_sequence.cc
@@ -3,9 +3,7 @@
// found in the LICENSE file.
#include "chrome/chrome_cleaner/executables/shutdown_sequence.h"
-#include "base/task/task_scheduler/task_scheduler.h"
-
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
namespace chrome_cleaner {
@@ -20,12 +18,12 @@
if (!mojo_task_runner)
return;
- auto* task_scheduler = base::TaskScheduler::GetInstance();
- if (task_scheduler)
- task_scheduler->Shutdown();
+ auto* thread_pool = base::ThreadPool::GetInstance();
+ if (thread_pool)
+ thread_pool->Shutdown();
// Objects that post messages to themselves with base::Unretained must be
- // destroyed after TaskScheduler::Shutdown, otherwise some tasks might be
+ // destroyed after ThreadPool::Shutdown, otherwise some tasks might be
// still referencing recently destroyed objects.
engine_facade.reset();
diff --git a/chrome/renderer/BUILD.gn b/chrome/renderer/BUILD.gn
index d8b5d14..04dc719 100644
--- a/chrome/renderer/BUILD.gn
+++ b/chrome/renderer/BUILD.gn
@@ -148,7 +148,7 @@
"//components/spellcheck:buildflags",
"//components/startup_metric_utils/common:interfaces",
"//components/subresource_filter/content/renderer",
- "//components/task_scheduler_util",
+ "//components/thread_pool_util",
"//components/translate/content/renderer",
"//components/translate/core/common",
"//components/translate/core/language_detection",
diff --git a/chrome/renderer/DEPS b/chrome/renderer/DEPS
index 5c14740..36707ddf 100644
--- a/chrome/renderer/DEPS
+++ b/chrome/renderer/DEPS
@@ -41,7 +41,7 @@
"+components/subresource_filter/content/common",
"+components/subresource_filter/content/renderer",
"+components/subresource_filter/core/common/common_features.h",
- "+components/task_scheduler_util",
+ "+components/thread_pool_util",
"+components/translate/content/common",
"+components/translate/content/renderer",
"+components/translate/core/common",
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index bf89528..4938ded2 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -89,7 +89,7 @@
#include "components/subresource_filter/content/renderer/subresource_filter_agent.h"
#include "components/subresource_filter/content/renderer/unverified_ruleset_dealer.h"
#include "components/subresource_filter/core/common/common_features.h"
-#include "components/task_scheduler_util/variations_util.h"
+#include "components/thread_pool_util/variations_util.h"
#include "components/variations/net/variations_http_headers.h"
#include "components/variations/variations_switches.h"
#include "components/version_info/version_info.h"
@@ -1538,9 +1538,9 @@
return FlashEmbedRewrite::RewriteFlashEmbedURL(url);
}
-std::unique_ptr<base::TaskScheduler::InitParams>
-ChromeContentRendererClient::GetTaskSchedulerInitParams() {
- return task_scheduler_util::GetTaskSchedulerInitParamsForRenderer();
+std::unique_ptr<base::ThreadPool::InitParams>
+ChromeContentRendererClient::GetThreadPoolInitParams() {
+ return thread_pool_util::GetThreadPoolInitParamsForRenderer();
}
void ChromeContentRendererClient::CreateRendererService(
diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h
index d64bb63..770d49a 100644
--- a/chrome/renderer/chrome_content_renderer_client.h
+++ b/chrome/renderer/chrome_content_renderer_client.h
@@ -200,7 +200,7 @@
const std::string& header_name) override;
bool ShouldEnforceWebRTCRoutingPreferences() override;
GURL OverrideFlashEmbedWithHTML(const GURL& url) override;
- std::unique_ptr<base::TaskScheduler::InitParams> GetTaskSchedulerInitParams()
+ std::unique_ptr<base::ThreadPool::InitParams> GetThreadPoolInitParams()
override;
void CreateRendererService(
service_manager::mojom::ServiceRequest service_request) override;
diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc
index 4dc21dfb..32d9116 100644
--- a/chrome/service/service_process.cc
+++ b/chrome/service/service_process.cc
@@ -25,8 +25,8 @@
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/scheduler_worker_pool_params.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/scheduler_worker_pool_params.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "base/values.h"
@@ -154,19 +154,19 @@
quit_closure_ = std::move(quit_closure);
service_process_state_ = std::move(state);
- // Initialize TaskScheduler.
+ // Initialize ThreadPool.
constexpr int kMaxBackgroundThreads = 2;
constexpr int kMaxForegroundThreads = 6;
constexpr base::TimeDelta kSuggestedReclaimTime =
base::TimeDelta::FromSeconds(30);
- base::TaskScheduler::Create("CloudPrintServiceProcess");
- base::TaskScheduler::GetInstance()->Start(
+ base::ThreadPool::Create("CloudPrintServiceProcess");
+ base::ThreadPool::GetInstance()->Start(
{{kMaxBackgroundThreads, kSuggestedReclaimTime},
{kMaxForegroundThreads, kSuggestedReclaimTime,
base::SchedulerBackwardCompatibility::INIT_COM_STA}});
- // The NetworkChangeNotifier must be created after TaskScheduler because it
+ // The NetworkChangeNotifier must be created after ThreadPool because it
// posts tasks to it.
network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
network_connection_tracker_ =
@@ -271,8 +271,8 @@
shutdown_event_.Signal();
io_thread_.reset();
- if (base::TaskScheduler::GetInstance())
- base::TaskScheduler::GetInstance()->Shutdown();
+ if (base::ThreadPool::GetInstance())
+ base::ThreadPool::GetInstance()->Shutdown();
// The NetworkChangeNotifier must be destroyed after all other threads that
// might use it have been shut down.
diff --git a/chrome/test/chromedriver/server/chromedriver_server.cc b/chrome/test/chromedriver/server/chromedriver_server.cc
index b72bf79..f26b4ff1 100644
--- a/chrome/test/chromedriver/server/chromedriver_server.cc
+++ b/chrome/test/chromedriver/server/chromedriver_server.cc
@@ -29,7 +29,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread.h"
#include "base/threading/thread_local.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -529,11 +529,11 @@
mojo::core::Init();
- base::TaskScheduler::CreateAndStartWithDefaultParams("ChromeDriver");
+ base::ThreadPool::CreateAndStartWithDefaultParams("ChromeDriver");
RunServer(port, allow_remote, whitelisted_ips, url_base, adb_port);
// clean up
- base::TaskScheduler::GetInstance()->Shutdown();
+ base::ThreadPool::GetInstance()->Shutdown();
return 0;
}
diff --git a/chrome/updater/updater.cc b/chrome/updater/updater.cc
index d39c320..63d6b8a 100644
--- a/chrome/updater/updater.cc
+++ b/chrome/updater/updater.cc
@@ -21,8 +21,8 @@
#include "base/run_loop.h"
#include "base/stl_util.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/initialization_util.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/initialization_util.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/task_runner.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_restrictions.h"
@@ -50,21 +50,21 @@
0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70,
0x54, 0xf9, 0x56, 0xd3, 0xe7, 0x88, 0xba, 0x8c};
-void TaskSchedulerStart() {
- base::TaskScheduler::Create("Updater");
- const auto task_scheduler_init_params =
- std::make_unique<base::TaskScheduler::InitParams>(
+void ThreadPoolStart() {
+ base::ThreadPool::Create("Updater");
+ const auto thread_pool_init_params =
+ std::make_unique<base::ThreadPool::InitParams>(
base::SchedulerWorkerPoolParams(
base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.1, 0),
base::TimeDelta::FromSeconds(30)),
base::SchedulerWorkerPoolParams(
base::RecommendedMaxNumberOfThreadsInPool(8, 32, 0.3, 0),
base::TimeDelta::FromSeconds(30)));
- base::TaskScheduler::GetInstance()->Start(*task_scheduler_init_params);
+ base::ThreadPool::GetInstance()->Start(*thread_pool_init_params);
}
-void TaskSchedulerStop() {
- base::TaskScheduler::GetInstance()->Shutdown();
+void ThreadPoolStop() {
+ base::ThreadPool::GetInstance()->Shutdown();
}
void QuitLoop(base::OnceClosure quit_closure) {
@@ -117,11 +117,11 @@
}
StartCrashReporter(UPDATER_VERSION_STRING);
- TaskSchedulerStart();
+ ThreadPoolStart();
}
void TerminateUpdaterMain() {
- TaskSchedulerStop();
+ ThreadPoolStop();
}
} // namespace
diff --git a/chromecast/BUILD.gn b/chromecast/BUILD.gn
index f2d1f96..d44fba3 100644
--- a/chromecast/BUILD.gn
+++ b/chromecast/BUILD.gn
@@ -215,7 +215,7 @@
"ProcessUtilTest.*",
"StackContainer.BufferAlignment",
"SystemMetrics2Test.GetSystemMemoryInfo",
- "OneTraitsExecutionModePair/TaskSchedulerImplTest.PostTasksViaTaskRunner/*",
+ "OneTraitsExecutionModePair/ThreadPoolImplTest.PostTasksViaTaskRunner/*",
"TaskSchedulerWorkerTest.WorkerDetaches",
]
}
diff --git a/chromeos/components/nearby/count_down_latch_impl_unittest.cc b/chromeos/components/nearby/count_down_latch_impl_unittest.cc
index a706a6d..827e429 100644
--- a/chromeos/components/nearby/count_down_latch_impl_unittest.cc
+++ b/chromeos/components/nearby/count_down_latch_impl_unittest.cc
@@ -10,7 +10,7 @@
#include "base/stl_util.h"
#include "base/synchronization/lock.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_task_environment.h"
#include "base/test/test_timeouts.h"
#include "base/threading/platform_thread.h"
@@ -31,7 +31,7 @@
}
void WaitForAllPostedTasksToFinish() {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
// Returns a unique ID for the posted AwaitTask(). This ID can be used in
diff --git a/components/BUILD.gn b/components/BUILD.gn
index ac5701c..7b92dd0 100644
--- a/components/BUILD.gn
+++ b/components/BUILD.gn
@@ -157,8 +157,8 @@
"//components/sync_bookmarks:unit_tests",
"//components/sync_preferences:unit_tests",
"//components/sync_sessions:unit_tests",
- "//components/task_scheduler_util:unit_tests",
"//components/test:run_all_unittests",
+ "//components/thread_pool_util:unit_tests",
"//components/translate/core/browser:unit_tests",
"//components/translate/core/common:unit_tests",
"//components/translate/core/language_detection:unit_tests",
diff --git a/components/arc/session/arc_session_impl.cc b/components/arc/session/arc_session_impl.cc
index 849952ad..266ab13 100644
--- a/components/arc/session/arc_session_impl.cc
+++ b/components/arc/session/arc_session_impl.cc
@@ -628,7 +628,7 @@
return;
case State::CONNECTING_MOJO:
- // Mojo connection is being waited on TaskScheduler's thread.
+ // Mojo connection is being waited on ThreadPool's thread.
// Request to cancel it. Following stopping procedure will run
// in its callback.
accept_cancel_pipe_.reset();
@@ -673,7 +673,7 @@
container_instance_id_.clear();
// In case that crash happens during before the Mojo channel is connected,
- // unlock the TaskScheduler's thread.
+ // unlock the ThreadPool's thread.
accept_cancel_pipe_.reset();
// TODO(hidehiko): In new D-Bus signal, more detailed reason why ARC
diff --git a/components/arc/session/arc_session_impl.h b/components/arc/session/arc_session_impl.h
index 0e980d6..6c19395d 100644
--- a/components/arc/session/arc_session_impl.h
+++ b/components/arc/session/arc_session_impl.h
@@ -77,7 +77,7 @@
// SessionManager. Its completion will be notified via ArcInstanceStopped.
// Otherwise, it just turns into STOPPED state.
// CONNECTING_MOJO:
- // The main task runs on TaskScheduler's thread, but it is a blocking call.
+ // The main task runs on ThreadPool's thread, but it is a blocking call.
// So, Stop() sends a request to cancel the blocking by closing the pipe
// whose read side is also polled. Then, in its callback, similar to
// STARTING_{MINI,FULL}_INSTANCE, a request to stop the ARC instance is
diff --git a/components/autofill/core/browser/webdata/web_data_service_unittest.cc b/components/autofill/core/browser/webdata/web_data_service_unittest.cc
index 5c2ff85c..b7503bc 100644
--- a/components/autofill/core/browser/webdata/web_data_service_unittest.cc
+++ b/components/autofill/core/browser/webdata/web_data_service_unittest.cc
@@ -17,7 +17,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_task_environment.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
@@ -153,7 +153,7 @@
&AutofillWebDataService::AddObserver;
wds_->GetDBTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(add_observer_func, wds_, &observer_));
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
void TearDown() override {
diff --git a/components/cronet/android/cronet_integrated_mode_state.h b/components/cronet/android/cronet_integrated_mode_state.h
index 7d65dc0..ed62222 100644
--- a/components/cronet/android/cronet_integrated_mode_state.h
+++ b/components/cronet/android/cronet_integrated_mode_state.h
@@ -5,7 +5,7 @@
#ifndef COMPONENTS_CRONET_ANDROID_CRONET_INTEGRATED_MODE_STATE_H_
#define COMPONENTS_CRONET_ANDROID_CRONET_INTEGRATED_MODE_STATE_H_
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
namespace cronet {
diff --git a/components/cronet/android/cronet_library_loader.cc b/components/cronet/android/cronet_library_loader.cc
index 44be5fd..80132d2 100644
--- a/components/cronet/android/cronet_library_loader.cc
+++ b/components/cronet/android/cronet_library_loader.cc
@@ -21,7 +21,7 @@
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
#include "components/cronet/android/buildflags.h"
#include "components/cronet/cronet_global_state.h"
@@ -71,8 +71,8 @@
base::FeatureList::InitializeInstance(std::string(), std::string());
#endif
- if (!base::TaskScheduler::GetInstance())
- base::TaskScheduler::CreateAndStartWithDefaultParams("Cronet");
+ if (!base::ThreadPool::GetInstance())
+ base::ThreadPool::CreateAndStartWithDefaultParams("Cronet");
url::Initialize();
}
@@ -100,8 +100,8 @@
}
void CronetOnUnLoad(JavaVM* jvm, void* reserved) {
- if (base::TaskScheduler::GetInstance())
- base::TaskScheduler::GetInstance()->Shutdown();
+ if (base::ThreadPool::GetInstance())
+ base::ThreadPool::GetInstance()->Shutdown();
base::android::LibraryLoaderExitHook();
}
diff --git a/components/cronet/cronet_global_state_stubs.cc b/components/cronet/cronet_global_state_stubs.cc
index ef1428e..04d2ccc7 100644
--- a/components/cronet/cronet_global_state_stubs.cc
+++ b/components/cronet/cronet_global_state_stubs.cc
@@ -7,7 +7,7 @@
#include "base/at_exit.h"
#include "base/feature_list.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "net/proxy_resolution/proxy_config_service.h"
#include "net/proxy_resolution/proxy_resolution_service.h"
#include "url/url_util.h"
@@ -31,11 +31,11 @@
url::Initialize();
- // Note that in component builds this TaskScheduler will be shared with the
+ // Note that in component builds this ThreadPool will be shared with the
// calling process, if it also depends on //base. In particular this means
// that the Cronet test binaries must avoid initializing or shutting-down the
- // TaskScheduler themselves.
- base::TaskScheduler::CreateAndStartWithDefaultParams("cronet");
+ // ThreadPool themselves.
+ base::ThreadPool::CreateAndStartWithDefaultParams("cronet");
return base::CreateSingleThreadTaskRunnerWithTraits({});
}
diff --git a/components/cronet/ios/cronet_environment.mm b/components/cronet/ios/cronet_environment.mm
index d3a97e4..478b15b 100644
--- a/components/cronet/ios/cronet_environment.mm
+++ b/components/cronet/ios/cronet_environment.mm
@@ -279,7 +279,7 @@
// TODO(lilyhoughton) this can only be run once, so right now leaking it.
// Should be be called when the _last_ CronetEnvironment is destroyed.
- // base::TaskScheduler* ts = base::TaskScheduler::GetInstance();
+ // base::ThreadPool* ts = base::ThreadPool::GetInstance();
// if (ts)
// ts->Shutdown();
diff --git a/components/cronet/ios/cronet_global_state_ios.mm b/components/cronet/ios/cronet_global_state_ios.mm
index dafa3c4..46d5116 100644
--- a/components/cronet/ios/cronet_global_state_ios.mm
+++ b/components/cronet/ios/cronet_global_state_ios.mm
@@ -29,7 +29,7 @@
ios_global_state::CreateParams create_params;
create_params.install_at_exit_manager = true;
ios_global_state::Create(create_params);
- ios_global_state::StartTaskScheduler(/*init_params=*/nullptr);
+ ios_global_state::StartThreadPool(/*init_params=*/nullptr);
url::Initialize();
diff --git a/components/cronet/run_all_unittests.cc b/components/cronet/run_all_unittests.cc
index 4bae27b..1e7f6bd4 100644
--- a/components/cronet/run_all_unittests.cc
+++ b/components/cronet/run_all_unittests.cc
@@ -11,7 +11,7 @@
#if defined(CRONET_TESTS_IMPLEMENTATION)
// cronet_tests[_android] link the Cronet implementation into the test
// suite statically in many configurations, causing globals initialized by
- // the library (e.g. TaskScheduler) to be visible to the TestSuite.
+ // the library (e.g. ThreadPool) to be visible to the TestSuite.
test_suite.DisableCheckForLeakedGlobals();
#endif
return base::LaunchUnitTests(
diff --git a/components/data_reduction_proxy/content/common/data_reduction_proxy_url_loader_throttle_unittest.cc b/components/data_reduction_proxy/content/common/data_reduction_proxy_url_loader_throttle_unittest.cc
index fcbf3359..01a9e38 100644
--- a/components/data_reduction_proxy/content/common/data_reduction_proxy_url_loader_throttle_unittest.cc
+++ b/components/data_reduction_proxy/content/common/data_reduction_proxy_url_loader_throttle_unittest.cc
@@ -5,7 +5,7 @@
#include "components/data_reduction_proxy/content/common/data_reduction_proxy_url_loader_throttle.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_task_environment.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_server.h"
diff --git a/components/exo/seat_unittest.cc b/components/exo/seat_unittest.cc
index 41b5f91..050e759 100644
--- a/components/exo/seat_unittest.cc
+++ b/components/exo/seat_unittest.cc
@@ -7,7 +7,7 @@
#include "base/files/file_util.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "components/exo/data_source.h"
#include "components/exo/data_source_delegate.h"
#include "components/exo/seat_observer.h"
@@ -67,7 +67,7 @@
};
void RunReadingTask() {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
base::RunLoop().RunUntilIdle();
}
diff --git a/components/leveldb_proto/internal/proto_database_impl_unittest.cc b/components/leveldb_proto/internal/proto_database_impl_unittest.cc
index 68d35b6..fe2caa4 100644
--- a/components/leveldb_proto/internal/proto_database_impl_unittest.cc
+++ b/components/leveldb_proto/internal/proto_database_impl_unittest.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_task_environment.h"
#include "base/threading/thread.h"
@@ -648,7 +648,7 @@
Enums::InitStatus::kOK);
// Kill the DB impl so it doesn't have a lock on the DB anymore.
unique_db_impl.reset();
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
auto db_provider_withshared = this->CreateProviderWithSharedDB();
auto shared_db_impl = this->CreateDBImpl(
diff --git a/components/net_log/chrome_net_log.cc b/components/net_log/chrome_net_log.cc
index 890e657..661e1bd 100644
--- a/components/net_log/chrome_net_log.cc
+++ b/components/net_log/chrome_net_log.cc
@@ -83,7 +83,7 @@
return constants_dict;
}
-void ChromeNetLog::ShutDownBeforeTaskScheduler() {
+void ChromeNetLog::ShutDownBeforeThreadPool() {
// TODO(eroman): Stop in-progress net_export_file_writer_ or delete its files?
ClearFileNetLogObserver();
diff --git a/components/net_log/chrome_net_log.h b/components/net_log/chrome_net_log.h
index 80f3bd68e..82cbd8f 100644
--- a/components/net_log/chrome_net_log.h
+++ b/components/net_log/chrome_net_log.h
@@ -59,16 +59,16 @@
// Notify the ChromeNetLog that things are shutting-down.
//
- // If ChromeNetLog does not outlive the TaskScheduler, there is no need to
+ // If ChromeNetLog does not outlive the ThreadPool, there is no need to
// call this.
//
- // However, if it can outlive the TaskScheduler, this should be called
- // before the TaskScheduler is shutdown. This allows for any file writers
+ // However, if it can outlive the ThreadPool, this should be called
+ // before the ThreadPool is shutdown. This allows for any file writers
// using BLOCK_SHUTDOWN to finish posting their writes.
//
// Not calling this is not a fatal error, however may result in an incomplete
// NetLog file being written to disk.
- void ShutDownBeforeTaskScheduler();
+ void ShutDownBeforeThreadPool();
private:
// Deletes file_net_log_observer_.
diff --git a/components/prefs/json_pref_store.h b/components/prefs/json_pref_store.h
index 0598b22..1d4faa3 100644
--- a/components/prefs/json_pref_store.h
+++ b/components/prefs/json_pref_store.h
@@ -58,9 +58,9 @@
// JsonPrefStore tasks, keep the default value.
// The initial read is done synchronously, the TaskPriority is thus only used
// for flushes to disks and BACKGROUND is therefore appropriate. Priority of
- // remaining BACKGROUND+BLOCK_SHUTDOWN tasks is bumped by the TaskScheduler on
+ // remaining BACKGROUND+BLOCK_SHUTDOWN tasks is bumped by the ThreadPool on
// shutdown. However, some shutdown use cases happen without
- // TaskScheduler::Shutdown() (e.g. ChromeRestartRequest::Start() and
+ // ThreadPool::Shutdown() (e.g. ChromeRestartRequest::Start() and
// BrowserProcessImpl::EndSession()) and we must thus unfortunately make this
// USER_VISIBLE until we solve https://crbug.com/747495 to allow bumping
// priority of a sequence on demand.
diff --git a/components/storage_monitor/storage_monitor_linux_unittest.cc b/components/storage_monitor/storage_monitor_linux_unittest.cc
index 0f05e6e8..0887fd9 100644
--- a/components/storage_monitor/storage_monitor_linux_unittest.cc
+++ b/components/storage_monitor/storage_monitor_linux_unittest.cc
@@ -21,7 +21,7 @@
#include "base/run_loop.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_task_environment.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/storage_monitor/mock_removable_storage_observer.h"
@@ -137,8 +137,8 @@
StorageMonitorLinux::UpdateMtab(new_mtab);
// The UpdateMtab call performs the actual mounting by posting tasks
- // to the task scheduler. This also needs to be flushed.
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ // to the thread pool. This also needs to be flushed.
+ base::ThreadPool::GetInstance()->FlushForTesting();
// Once the storage monitor picks up the changes to the fake mtab file,
// exit the RunLoop that should be blocking the main test thread.
diff --git a/components/task_scheduler_util/OWNERS b/components/task_scheduler_util/OWNERS
deleted file mode 100644
index 495a17c..0000000
--- a/components/task_scheduler_util/OWNERS
+++ /dev/null
@@ -1 +0,0 @@
-file://base/task/task_scheduler/OWNERS
diff --git a/components/task_scheduler_util/variations_util.h b/components/task_scheduler_util/variations_util.h
deleted file mode 100644
index eb8328a..0000000
--- a/components/task_scheduler_util/variations_util.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_TASK_SCHEDULER_UTIL_VARIATIONS_UTIL_H_
-#define COMPONENTS_TASK_SCHEDULER_UTIL_VARIATIONS_UTIL_H_
-
-#include <memory>
-
-#include "base/feature_list.h"
-#include "base/strings/string_piece.h"
-#include "base/task/task_scheduler/task_scheduler.h"
-
-namespace task_scheduler_util {
-
-extern const base::Feature kBrowserSchedulerInitParams;
-extern const base::Feature kRendererSchedulerInitParams;
-
-// Builds a TaskScheduler::InitParams from variations params that are prefixed
-// for |feature|. Returns nullptr on failure.
-//
-// TODO(fdoray): Move this to the anonymous namespace in the .cc file.
-// https://crbug.com/810049
-std::unique_ptr<base::TaskScheduler::InitParams> GetTaskSchedulerInitParams(
- const base::Feature& feature);
-
-// Builds a TaskScheduler::InitParams to use in the browser process from
-// variation params in the BrowserScheduler field trial.
-std::unique_ptr<base::TaskScheduler::InitParams>
-GetTaskSchedulerInitParamsForBrowser();
-
-// Builds a TaskScheduler::InitParams to use in renderer processes from
-// variation params in the BrowserScheduler field trial.
-std::unique_ptr<base::TaskScheduler::InitParams>
-GetTaskSchedulerInitParamsForRenderer();
-
-} // namespace task_scheduler_util
-
-#endif // COMPONENTS_TASK_SCHEDULER_UTIL_VARIATIONS_UTIL_H_
diff --git a/components/task_scheduler_util/BUILD.gn b/components/thread_pool_util/BUILD.gn
similarity index 86%
rename from components/task_scheduler_util/BUILD.gn
rename to components/thread_pool_util/BUILD.gn
index a7c02de..aa15acb 100644
--- a/components/task_scheduler_util/BUILD.gn
+++ b/components/thread_pool_util/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-static_library("task_scheduler_util") {
+static_library("thread_pool_util") {
sources = [
"variations_util.cc",
"variations_util.h",
@@ -19,7 +19,7 @@
"variations_util_unittest.cc",
]
deps = [
- ":task_scheduler_util",
+ ":thread_pool_util",
"//base",
"//components/variations:test_support",
"//testing/gtest",
diff --git a/components/task_scheduler_util/DEPS b/components/thread_pool_util/DEPS
similarity index 100%
rename from components/task_scheduler_util/DEPS
rename to components/thread_pool_util/DEPS
diff --git a/components/thread_pool_util/OWNERS b/components/thread_pool_util/OWNERS
new file mode 100644
index 0000000..a003810
--- /dev/null
+++ b/components/thread_pool_util/OWNERS
@@ -0,0 +1 @@
+file://base/task/thread_pool/OWNERS
diff --git a/components/task_scheduler_util/variations_util.cc b/components/thread_pool_util/variations_util.cc
similarity index 86%
rename from components/task_scheduler_util/variations_util.cc
rename to components/thread_pool_util/variations_util.cc
index d7b3e7a..bc4d699 100644
--- a/components/task_scheduler_util/variations_util.cc
+++ b/components/thread_pool_util/variations_util.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/task_scheduler_util/variations_util.h"
+#include "components/thread_pool_util/variations_util.h"
#include <map>
#include <string>
@@ -13,10 +13,10 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
-#include "base/task/task_scheduler/initialization_util.h"
+#include "base/task/thread_pool/initialization_util.h"
#include "base/time/time.h"
-namespace task_scheduler_util {
+namespace thread_pool_util {
namespace {
@@ -90,7 +90,7 @@
const base::Feature kRendererSchedulerInitParams = {
"RendererSchedulerInitParams", base::FEATURE_DISABLED_BY_DEFAULT};
-std::unique_ptr<base::TaskScheduler::InitParams> GetTaskSchedulerInitParams(
+std::unique_ptr<base::ThreadPool::InitParams> GetThreadPoolInitParams(
const base::Feature& feature) {
std::map<std::string, std::string> variation_params;
if (!base::GetFieldTrialParamsByFeature(feature, &variation_params))
@@ -104,22 +104,22 @@
if (!background_worker_pool_params || !foreground_worker_pool_params)
return nullptr;
- return std::make_unique<base::TaskScheduler::InitParams>(
+ return std::make_unique<base::ThreadPool::InitParams>(
*background_worker_pool_params, *foreground_worker_pool_params);
}
-std::unique_ptr<base::TaskScheduler::InitParams>
-GetTaskSchedulerInitParamsForBrowser() {
+std::unique_ptr<base::ThreadPool::InitParams>
+GetThreadPoolInitParamsForBrowser() {
// Variations params for the browser processes are associated with the feature
// |kBrowserSchedulerInitParams|.
- return GetTaskSchedulerInitParams(kBrowserSchedulerInitParams);
+ return GetThreadPoolInitParams(kBrowserSchedulerInitParams);
}
-std::unique_ptr<base::TaskScheduler::InitParams>
-GetTaskSchedulerInitParamsForRenderer() {
+std::unique_ptr<base::ThreadPool::InitParams>
+GetThreadPoolInitParamsForRenderer() {
// Variations params for the renderer processes are associated with the
// feature |kRendererSchedulerInitParams|.
- return GetTaskSchedulerInitParams(kRendererSchedulerInitParams);
+ return GetThreadPoolInitParams(kRendererSchedulerInitParams);
}
-} // namespace task_scheduler_util
+} // namespace thread_pool_util
diff --git a/components/thread_pool_util/variations_util.h b/components/thread_pool_util/variations_util.h
new file mode 100644
index 0000000..588ed6f
--- /dev/null
+++ b/components/thread_pool_util/variations_util.h
@@ -0,0 +1,39 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_THREAD_POOL_UTIL_VARIATIONS_UTIL_H_
+#define COMPONENTS_THREAD_POOL_UTIL_VARIATIONS_UTIL_H_
+
+#include <memory>
+
+#include "base/feature_list.h"
+#include "base/strings/string_piece.h"
+#include "base/task/thread_pool/thread_pool.h"
+
+namespace thread_pool_util {
+
+extern const base::Feature kBrowserSchedulerInitParams;
+extern const base::Feature kRendererSchedulerInitParams;
+
+// Builds a ThreadPool::InitParams from variations params that are prefixed
+// for |feature|. Returns nullptr on failure.
+//
+// TODO(fdoray): Move this to the anonymous namespace in the .cc file.
+// https://crbug.com/810049
+std::unique_ptr<base::ThreadPool::InitParams> GetThreadPoolInitParams(
+ const base::Feature& feature);
+
+// Builds a ThreadPool::InitParams to use in the browser process from
+// variation params in the BrowserScheduler field trial.
+std::unique_ptr<base::ThreadPool::InitParams>
+GetThreadPoolInitParamsForBrowser();
+
+// Builds a ThreadPool::InitParams to use in renderer processes from
+// variation params in the BrowserScheduler field trial.
+std::unique_ptr<base::ThreadPool::InitParams>
+GetThreadPoolInitParamsForRenderer();
+
+} // namespace thread_pool_util
+
+#endif // COMPONENTS_THREAD_POOL_UTIL_VARIATIONS_UTIL_H_
diff --git a/components/task_scheduler_util/variations_util_unittest.cc b/components/thread_pool_util/variations_util_unittest.cc
similarity index 67%
rename from components/task_scheduler_util/variations_util_unittest.cc
rename to components/thread_pool_util/variations_util_unittest.cc
index d5aaffb..13997483 100644
--- a/components/task_scheduler_util/variations_util_unittest.cc
+++ b/components/thread_pool_util/variations_util_unittest.cc
@@ -2,25 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/task_scheduler_util/variations_util.h"
+#include "components/thread_pool_util/variations_util.h"
#include <map>
#include <string>
#include "base/macros.h"
#include "base/metrics/field_trial.h"
-#include "base/task/task_scheduler/scheduler_worker_params.h"
-#include "base/task/task_scheduler/scheduler_worker_pool_params.h"
+#include "base/task/thread_pool/scheduler_worker_params.h"
+#include "base/task/thread_pool/scheduler_worker_pool_params.h"
#include "components/variations/variations_params_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace task_scheduler_util {
+namespace thread_pool_util {
namespace {
-class TaskSchedulerUtilVariationsUtilTest : public testing::Test {
+class ThreadPoolUtilVariationsUtilTest : public testing::Test {
protected:
- TaskSchedulerUtilVariationsUtilTest() = default;
+ ThreadPoolUtilVariationsUtilTest() = default;
void SetVariationParams(
const std::map<std::string, std::string>& variation_params) {
@@ -33,18 +33,18 @@
private:
variations::testing::VariationParamsManager variation_params_manager_;
- DISALLOW_COPY_AND_ASSIGN(TaskSchedulerUtilVariationsUtilTest);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPoolUtilVariationsUtilTest);
};
} // namespace
-TEST_F(TaskSchedulerUtilVariationsUtilTest, OrderingParams5) {
+TEST_F(ThreadPoolUtilVariationsUtilTest, OrderingParams5) {
std::map<std::string, std::string> variation_params;
variation_params["Background"] = "1;1;1;0;42";
variation_params["Foreground"] = "4;4;1;0;62";
SetVariationParams(variation_params);
- auto init_params = GetTaskSchedulerInitParams(kRendererSchedulerInitParams);
+ auto init_params = GetThreadPoolInitParams(kRendererSchedulerInitParams);
ASSERT_TRUE(init_params);
EXPECT_EQ(1, init_params->background_worker_pool_params.max_tasks());
@@ -64,54 +64,54 @@
init_params->foreground_worker_pool_params.backward_compatibility());
}
-TEST_F(TaskSchedulerUtilVariationsUtilTest, NoData) {
- EXPECT_FALSE(GetTaskSchedulerInitParams(kRendererSchedulerInitParams));
+TEST_F(ThreadPoolUtilVariationsUtilTest, NoData) {
+ EXPECT_FALSE(GetThreadPoolInitParams(kRendererSchedulerInitParams));
}
-TEST_F(TaskSchedulerUtilVariationsUtilTest, IncompleteParameters) {
+TEST_F(ThreadPoolUtilVariationsUtilTest, IncompleteParameters) {
std::map<std::string, std::string> variation_params;
variation_params["Background"] = "1;1;1;0";
variation_params["Foreground"] = "4;4;1;0";
SetVariationParams(variation_params);
- EXPECT_FALSE(GetTaskSchedulerInitParams(kRendererSchedulerInitParams));
+ EXPECT_FALSE(GetThreadPoolInitParams(kRendererSchedulerInitParams));
}
-TEST_F(TaskSchedulerUtilVariationsUtilTest, InvalidParametersFormat) {
+TEST_F(ThreadPoolUtilVariationsUtilTest, InvalidParametersFormat) {
std::map<std::string, std::string> variation_params;
variation_params["Background"] = "a;b;c;d;e";
variation_params["Foreground"] = "a;b;c;d;e";
SetVariationParams(variation_params);
- EXPECT_FALSE(GetTaskSchedulerInitParams(kRendererSchedulerInitParams));
+ EXPECT_FALSE(GetThreadPoolInitParams(kRendererSchedulerInitParams));
}
-TEST_F(TaskSchedulerUtilVariationsUtilTest, ZeroMaxThreads) {
+TEST_F(ThreadPoolUtilVariationsUtilTest, ZeroMaxThreads) {
// The Background pool has a maximum number of threads equal to zero, which is
// invalid.
std::map<std::string, std::string> variation_params;
variation_params["Background"] = "0;0;0;0;0";
variation_params["Foreground"] = "4;4;1;0;62";
SetVariationParams(variation_params);
- EXPECT_FALSE(GetTaskSchedulerInitParams(kRendererSchedulerInitParams));
+ EXPECT_FALSE(GetThreadPoolInitParams(kRendererSchedulerInitParams));
}
-TEST_F(TaskSchedulerUtilVariationsUtilTest, NegativeMaxThreads) {
+TEST_F(ThreadPoolUtilVariationsUtilTest, NegativeMaxThreads) {
// The Background pool has a negative maximum number of threads, which is
// invalid.
std::map<std::string, std::string> variation_params;
variation_params["Background"] = "-5;-5;0;0;0";
variation_params["Foreground"] = "4;4;1;0;62";
SetVariationParams(variation_params);
- EXPECT_FALSE(GetTaskSchedulerInitParams(kRendererSchedulerInitParams));
+ EXPECT_FALSE(GetThreadPoolInitParams(kRendererSchedulerInitParams));
}
-TEST_F(TaskSchedulerUtilVariationsUtilTest, NegativeSuggestedReclaimTime) {
+TEST_F(ThreadPoolUtilVariationsUtilTest, NegativeSuggestedReclaimTime) {
// The Background pool has a negative suggested reclaim time, which is
// invalid.
std::map<std::string, std::string> variation_params;
variation_params["Background"] = "1;1;1;0;-5";
variation_params["Foreground"] = "4;4;1;0;62";
SetVariationParams(variation_params);
- EXPECT_FALSE(GetTaskSchedulerInitParams(kRendererSchedulerInitParams));
+ EXPECT_FALSE(GetThreadPoolInitParams(kRendererSchedulerInitParams));
}
-} // namespace task_scheduler_util
+} // namespace thread_pool_util
diff --git a/components/viz/demo/demo_main.cc b/components/viz/demo/demo_main.cc
index 9bf7fe9..3f80ad3 100644
--- a/components/viz/demo/demo_main.cc
+++ b/components/viz/demo/demo_main.cc
@@ -8,7 +8,7 @@
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread.h"
#include "build/build_config.h"
#include "components/viz/demo/host/demo_host.h"
@@ -41,7 +41,7 @@
InitBase(int argc, char** argv) {
base::CommandLine::Init(argc, argv);
base::i18n::InitializeICU();
- base::TaskScheduler::CreateAndStartWithDefaultParams("demo");
+ base::ThreadPool::CreateAndStartWithDefaultParams("demo");
}
~InitBase() = default;
diff --git a/components/webcrypto/webcrypto_impl.cc b/components/webcrypto/webcrypto_impl.cc
index 67ad546..63456db2 100644
--- a/components/webcrypto/webcrypto_impl.cc
+++ b/components/webcrypto/webcrypto_impl.cc
@@ -85,7 +85,7 @@
// TODO(gab): the pool is currently using a single non-joinable thread to
// mimic the old behavior of using a CONTINUE_ON_SHUTDOWN SequencedTaskRunner
// on a single-threaded SequencedWorkerPool, but we'd like to consider using
- // the TaskScheduler here and allowing multiple threads (SEQUENCED or even
+ // the ThreadPool here and allowing multiple threads (SEQUENCED or even
// PARALLEL ExecutionMode: http://crbug.com/623700).
base::Thread worker_thread_;
diff --git a/content/OWNERS b/content/OWNERS
index 2af88af..906c460 100644
--- a/content/OWNERS
+++ b/content/OWNERS
@@ -16,7 +16,7 @@
# structural changes, please get a review from a reviewer in this file.
per-file BUILD.gn=*
-# For threading (BrowserThread, BrowserMainLoop, TaskScheduler, etc.)
+# For threading (BrowserThread, BrowserMainLoop, ThreadPool, etc.)
per-file *browser_main_loop*=gab@chromium.org
per-file *browser_thread*=gab@chromium.org
diff --git a/content/app/content_main_runner_impl.cc b/content/app/content_main_runner_impl.cc
index 010ecd6..4dc87d82 100644
--- a/content/app/content_main_runner_impl.cc
+++ b/content/app/content_main_runner_impl.cc
@@ -895,10 +895,10 @@
delegate_->PostFieldTrialInitialization();
}
- if (GetContentClient()->browser()->ShouldCreateTaskScheduler()) {
- // Create and start the TaskScheduler early to allow upcoming code to use
+ if (GetContentClient()->browser()->ShouldCreateThreadPool()) {
+ // Create and start the ThreadPool early to allow upcoming code to use
// the post_task.h API.
- base::TaskScheduler::Create("Browser");
+ base::ThreadPool::Create("Browser");
}
delegate_->PreCreateMainMessageLoop();
@@ -919,9 +919,9 @@
delegate_->PostEarlyInitialization(main_params.ui_task != nullptr);
- if (GetContentClient()->browser()->ShouldCreateTaskScheduler()) {
- // The FeatureList needs to create before starting the TaskScheduler.
- StartBrowserTaskScheduler();
+ if (GetContentClient()->browser()->ShouldCreateThreadPool()) {
+ // The FeatureList needs to create before starting the ThreadPool.
+ StartBrowserThreadPool();
}
BrowserTaskExecutor::PostFeatureListSetup();
diff --git a/content/browser/after_startup_task_utils.h b/content/browser/after_startup_task_utils.h
index 7debbad..6df9748 100644
--- a/content/browser/after_startup_task_utils.h
+++ b/content/browser/after_startup_task_utils.h
@@ -13,7 +13,7 @@
// ContentBrowserClient::SetBrowserStartupIsCompleteForTesting() as that can
// only be called from the content implementation and including content/test in
// the content implementation is a whole other can of worms. TODO(gab): Clean
-// this up when AfterStartupTasks go away in favor of TaskScheduler.
+// this up when AfterStartupTasks go away in favor of ThreadPool.
void CONTENT_EXPORT SetBrowserStartupIsCompleteForTesting();
} // namespace content
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index ff63c8a..a0b100c 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -39,7 +39,7 @@
#include "base/synchronization/waitable_event.h"
#include "base/system/system_monitor.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/initialization_util.h"
+#include "base/task/thread_pool/initialization_util.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -99,7 +99,7 @@
#include "content/browser/webui/url_data_manager.h"
#include "content/common/content_switches_internal.h"
#include "content/common/service_manager/service_manager_connection_impl.h"
-#include "content/common/task_scheduler.h"
+#include "content/common/thread_pool_util.h"
#include "content/public/browser/browser_main_parts.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
@@ -539,7 +539,7 @@
BrowserMainLoop::BrowserMainLoop(
const MainFunctionParams& parameters,
- std::unique_ptr<base::TaskScheduler::ScopedExecutionFence>
+ std::unique_ptr<base::ThreadPool::ScopedExecutionFence>
scoped_execution_fence)
: parameters_(parameters),
parsed_command_line_(parameters.command_line),
@@ -548,11 +548,11 @@
scoped_execution_fence_(std::move(scoped_execution_fence)) {
DCHECK(!g_current_browser_main_loop);
DCHECK(scoped_execution_fence_)
- << "TaskScheduler must be halted before kicking off content.";
+ << "ThreadPool must be halted before kicking off content.";
g_current_browser_main_loop = this;
- if (GetContentClient()->browser()->ShouldCreateTaskScheduler()) {
- DCHECK(base::TaskScheduler::GetInstance());
+ if (GetContentClient()->browser()->ShouldCreateThreadPool()) {
+ DCHECK(base::ThreadPool::GetInstance());
}
}
@@ -950,7 +950,7 @@
int BrowserMainLoop::CreateThreads() {
TRACE_EVENT0("startup,rail", "BrowserMainLoop::CreateThreads");
- // Release the TaskScheduler's threads.
+ // Release the ThreadPool's threads.
scoped_execution_fence_.reset();
// The |io_thread| can have optionally been injected into Init(), but if not,
@@ -1031,7 +1031,7 @@
// Also allow waiting to join threads.
// TODO(https://crbug.com/800808): Ideally this (and the above SetIOAllowed()
// would be scoped allowances). That would be one of the first step to ensure
- // no persistent work is being done after TaskScheduler::Shutdown() in order
+ // no persistent work is being done after ThreadPool::Shutdown() in order
// to move towards atomic shutdown.
base::ThreadRestrictions::SetWaitAllowed(true);
base::PostTaskWithTraits(
@@ -1119,8 +1119,8 @@
}
{
- TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:TaskScheduler");
- base::TaskScheduler::GetInstance()->Shutdown();
+ TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:ThreadPool");
+ base::ThreadPool::GetInstance()->Shutdown();
}
// Must happen after the IO thread is shutdown since this may be accessed from
diff --git a/content/browser/browser_main_loop.h b/content/browser/browser_main_loop.h
index d7939ebb..1fae724 100644
--- a/content/browser/browser_main_loop.h
+++ b/content/browser/browser_main_loop.h
@@ -11,7 +11,7 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
#include "content/browser/browser_process_sub_thread.h"
#include "content/public/browser/browser_main_runner.h"
@@ -129,11 +129,11 @@
static media::AudioManager* GetAudioManager();
- // The TaskScheduler instance must exist but not to be started when building
+ // The ThreadPool instance must exist but not to be started when building
// BrowserMainLoop.
explicit BrowserMainLoop(
const MainFunctionParams& parameters,
- std::unique_ptr<base::TaskScheduler::ScopedExecutionFence> fence);
+ std::unique_ptr<base::ThreadPool::ScopedExecutionFence> fence);
virtual ~BrowserMainLoop();
void Init();
@@ -294,10 +294,10 @@
// BrowserMainLoop::CreateThreads() as things initialized before it require an
// initialize-once happens-before relationship with all eventual content tasks
// running on other threads. This ScopedExecutionFence ensures that no tasks
- // posted to TaskScheduler gets to run before CreateThreads(); satisfying this
- // requirement even though the TaskScheduler is created and started before
+ // posted to ThreadPool gets to run before CreateThreads(); satisfying this
+ // requirement even though the ThreadPool is created and started before
// content is entered.
- std::unique_ptr<base::TaskScheduler::ScopedExecutionFence>
+ std::unique_ptr<base::ThreadPool::ScopedExecutionFence>
scoped_execution_fence_;
// Members initialized in |MainMessageLoopStart()| ---------------------------
diff --git a/content/browser/browser_main_loop_unittest.cc b/content/browser/browser_main_loop_unittest.cc
index 9de8c76..66b7e9c 100644
--- a/content/browser/browser_main_loop_unittest.cc
+++ b/content/browser/browser_main_loop_unittest.cc
@@ -7,7 +7,7 @@
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/system/sys_info.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_command_line.h"
#include "content/browser/browser_thread_impl.h"
#include "content/browser/scheduler/browser_task_executor.h"
@@ -26,18 +26,18 @@
base::test::ScopedCommandLine scoped_command_line;
scoped_command_line.GetProcessCommandLine()->AppendSwitch(
switches::kSingleProcess);
- base::TaskScheduler::Create("Browser");
- StartBrowserTaskScheduler();
+ base::ThreadPool::Create("Browser");
+ StartBrowserThreadPool();
BrowserTaskExecutor::Create();
MainFunctionParams main_function_params(
*scoped_command_line.GetProcessCommandLine());
BrowserMainLoop browser_main_loop(
main_function_params,
- std::make_unique<base::TaskScheduler::ScopedExecutionFence>());
+ std::make_unique<base::ThreadPool::ScopedExecutionFence>());
browser_main_loop.MainMessageLoopStart();
browser_main_loop.Init();
browser_main_loop.CreateThreads();
- EXPECT_GE(base::TaskScheduler::GetInstance()
+ EXPECT_GE(base::ThreadPool::GetInstance()
->GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
{base::TaskPriority::USER_VISIBLE}),
base::SysInfo::NumberOfProcessors() - 1);
@@ -48,8 +48,8 @@
BrowserThreadImpl::ResetGlobalsForTesting(
static_cast<BrowserThread::ID>(id));
}
- base::TaskScheduler::GetInstance()->JoinForTesting();
- base::TaskScheduler::SetInstance(nullptr);
+ base::ThreadPool::GetInstance()->JoinForTesting();
+ base::ThreadPool::SetInstance(nullptr);
}
} // namespace content
diff --git a/content/browser/browser_main_runner_impl.cc b/content/browser/browser_main_runner_impl.cc
index fcb137d..28e6d58 100644
--- a/content/browser/browser_main_runner_impl.cc
+++ b/content/browser/browser_main_runner_impl.cc
@@ -57,7 +57,7 @@
: initialization_started_(false),
is_shutdown_(false),
scoped_execution_fence_(
- std::make_unique<base::TaskScheduler::ScopedExecutionFence>()) {}
+ std::make_unique<base::ThreadPool::ScopedExecutionFence>()) {}
BrowserMainRunnerImpl::~BrowserMainRunnerImpl() {
if (initialization_started_ && !is_shutdown_)
diff --git a/content/browser/browser_main_runner_impl.h b/content/browser/browser_main_runner_impl.h
index 77c2861..a4f400a 100644
--- a/content/browser/browser_main_runner_impl.h
+++ b/content/browser/browser_main_runner_impl.h
@@ -8,7 +8,7 @@
#include <memory>
#include "base/macros.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
#include "content/public/browser/browser_main_runner.h"
@@ -45,10 +45,10 @@
// True if the runner has been shut down.
bool is_shutdown_;
- // Prevents execution of TaskScheduler tasks from the moment content is
+ // Prevents execution of ThreadPool tasks from the moment content is
// entered. Handed off to |main_loop_| later so it can decide when to release
// worker threads again.
- std::unique_ptr<base::TaskScheduler::ScopedExecutionFence>
+ std::unique_ptr<base::ThreadPool::ScopedExecutionFence>
scoped_execution_fence_;
std::unique_ptr<NotificationServiceImpl> notification_service_;
diff --git a/content/browser/browser_thread_browsertest.cc b/content/browser/browser_thread_browsertest.cc
index 6be9acf..34f5eb0 100644
--- a/content/browser/browser_thread_browsertest.cc
+++ b/content/browser/browser_thread_browsertest.cc
@@ -15,7 +15,7 @@
class BrowserThreadPostTaskBeforeInitBrowserTest : public ContentBrowserTest {
protected:
void SetUp() override {
- // This should fail because the TaskScheduler + TaskExecutor weren't created
+ // This should fail because the ThreadPool + TaskExecutor weren't created
// yet.
EXPECT_DCHECK_DEATH(base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::DoNothing()));
diff --git a/content/browser/fileapi/file_system_operation_runner_unittest.cc b/content/browser/fileapi/file_system_operation_runner_unittest.cc
index 32cd010..5f22097 100644
--- a/content/browser/fileapi/file_system_operation_runner_unittest.cc
+++ b/content/browser/fileapi/file_system_operation_runner_unittest.cc
@@ -10,8 +10,8 @@
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_task_environment.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -235,7 +235,7 @@
operation_runner()->Shutdown();
// Wait until the task posted on the blocking thread is done.
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
// This should finish without thread assertion failure on debug build.
}
diff --git a/content/browser/net/quota_policy_cookie_store_unittest.cc b/content/browser/net/quota_policy_cookie_store_unittest.cc
index e5189b1..faa8fce1 100644
--- a/content/browser/net/quota_policy_cookie_store_unittest.cc
+++ b/content/browser/net/quota_policy_cookie_store_unittest.cc
@@ -11,7 +11,7 @@
#include "base/sequenced_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/time/time.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "net/cookies/cookie_util.h"
@@ -97,8 +97,8 @@
void DestroyStore() {
store_ = nullptr;
- // Ensure that |store_|'s destructor has run by flushing TaskScheduler.
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ // Ensure that |store_|'s destructor has run by flushing ThreadPool.
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
void SetUp() override {
diff --git a/content/browser/renderer_host/pepper/pepper_truetype_font_host.cc b/content/browser/renderer_host/pepper/pepper_truetype_font_host.cc
index 4e4b030..42a03e77 100644
--- a/content/browser/renderer_host/pepper/pepper_truetype_font_host.cc
+++ b/content/browser/renderer_host/pepper/pepper_truetype_font_host.cc
@@ -29,7 +29,7 @@
initialize_completed_(false),
weak_factory_(this) {
font_ = PepperTrueTypeFont::Create();
- // Initialize the font on a TaskScheduler thread. This must complete before
+ // Initialize the font on a ThreadPool thread. This must complete before
// using |font_|.
task_runner_ = base::CreateSequencedTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT});
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index 8e869f1..2a59445 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -439,7 +439,7 @@
#endif
CHECK(delegate_);
CHECK_NE(MSG_ROUTING_NONE, routing_id_);
- DCHECK(base::TaskScheduler::GetInstance())
+ DCHECK(base::ThreadPool::GetInstance())
<< "Ref. Prerequisite section of post_task.h";
std::pair<RoutingIDWidgetMap::iterator, bool> result =
diff --git a/content/browser/renderer_host/text_input_client_mac_unittest.mm b/content/browser/renderer_host/text_input_client_mac_unittest.mm
index 8b752c7..057f8de 100644
--- a/content/browser/renderer_host/text_input_client_mac_unittest.mm
+++ b/content/browser/renderer_host/text_input_client_mac_unittest.mm
@@ -100,7 +100,7 @@
private:
friend class ScopedTestingThread;
- // TaskScheduler is used by RenderWidgetHostImpl constructor.
+ // ThreadPool is used by RenderWidgetHostImpl constructor.
TestBrowserThreadBundle thread_bundle_;
TestBrowserContext browser_context_;
diff --git a/content/browser/scheduler/browser_task_executor_unittest.cc b/content/browser/scheduler/browser_task_executor_unittest.cc
index 33f90d6..d76a957e 100644
--- a/content/browser/scheduler/browser_task_executor_unittest.cc
+++ b/content/browser/scheduler/browser_task_executor_unittest.cc
@@ -10,7 +10,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_task_environment.h"
#include "base/threading/thread_task_runner_handle.h"
diff --git a/content/browser/scheduler/browser_ui_thread_scheduler_unittest.cc b/content/browser/scheduler/browser_ui_thread_scheduler_unittest.cc
index c5c54a2a..80fa886 100644
--- a/content/browser/scheduler/browser_ui_thread_scheduler_unittest.cc
+++ b/content/browser/scheduler/browser_ui_thread_scheduler_unittest.cc
@@ -11,7 +11,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/mock_callback.h"
#include "content/public/browser/browser_task_traits.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/content/browser/startup_helper.cc b/content/browser/startup_helper.cc
index 9d979d5..191db21e 100644
--- a/content/browser/startup_helper.cc
+++ b/content/browser/startup_helper.cc
@@ -7,10 +7,10 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/system/sys_info.h"
-#include "base/task/task_scheduler/initialization_util.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/initialization_util.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
-#include "content/common/task_scheduler.h"
+#include "content/common/thread_pool_util.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_switches.h"
@@ -18,11 +18,10 @@
namespace {
-std::unique_ptr<base::TaskScheduler::InitParams>
-GetDefaultTaskSchedulerInitParams() {
+std::unique_ptr<base::ThreadPool::InitParams> GetDefaultThreadPoolInitParams() {
#if defined(OS_ANDROID)
// Mobile config, for iOS see ios/web/app/web_main_loop.cc.
- return std::make_unique<base::TaskScheduler::InitParams>(
+ return std::make_unique<base::ThreadPool::InitParams>(
base::SchedulerWorkerPoolParams(
base::RecommendedMaxNumberOfThreadsInPool(4, 8, 0.2, 0),
base::TimeDelta::FromSeconds(30)),
@@ -31,7 +30,7 @@
base::TimeDelta::FromSeconds(30)));
#else
// Desktop config.
- return std::make_unique<base::TaskScheduler::InitParams>(
+ return std::make_unique<base::ThreadPool::InitParams>(
base::SchedulerWorkerPoolParams(
base::RecommendedMaxNumberOfThreadsInPool(6, 8, 0.2, 0),
base::TimeDelta::FromSeconds(30)),
@@ -40,7 +39,7 @@
base::TimeDelta::FromSeconds(30))
#if defined(OS_WIN)
,
- base::TaskScheduler::InitParams::SharedWorkerPoolEnvironment::COM_MTA
+ base::ThreadPool::InitParams::SharedWorkerPoolEnvironment::COM_MTA
#endif // defined(OS_WIN)
);
#endif
@@ -70,12 +69,12 @@
return field_trial_list;
}
-void StartBrowserTaskScheduler() {
- auto task_scheduler_init_params =
- GetContentClient()->browser()->GetTaskSchedulerInitParams();
- if (!task_scheduler_init_params)
- task_scheduler_init_params = GetDefaultTaskSchedulerInitParams();
- DCHECK(task_scheduler_init_params);
+void StartBrowserThreadPool() {
+ auto thread_pool_init_params =
+ GetContentClient()->browser()->GetThreadPoolInitParams();
+ if (!thread_pool_init_params)
+ thread_pool_init_params = GetDefaultThreadPoolInitParams();
+ DCHECK(thread_pool_init_params);
// If a renderer lives in the browser process, adjust the number of
// threads in the foreground pool.
@@ -83,16 +82,16 @@
switches::kSingleProcess)) {
const base::SchedulerWorkerPoolParams&
current_foreground_worker_pool_params(
- task_scheduler_init_params->foreground_worker_pool_params);
- task_scheduler_init_params->foreground_worker_pool_params =
+ thread_pool_init_params->foreground_worker_pool_params);
+ thread_pool_init_params->foreground_worker_pool_params =
base::SchedulerWorkerPoolParams(
- std::max(GetMinThreadsInRendererTaskSchedulerForegroundPool(),
+ std::max(GetMinForegroundThreadsInRendererThreadPool(),
current_foreground_worker_pool_params.max_tasks()),
current_foreground_worker_pool_params.suggested_reclaim_time(),
current_foreground_worker_pool_params.backward_compatibility());
}
- base::TaskScheduler::GetInstance()->Start(*task_scheduler_init_params.get());
+ base::ThreadPool::GetInstance()->Start(*thread_pool_init_params.get());
}
} // namespace content
diff --git a/content/browser/startup_helper.h b/content/browser/startup_helper.h
index 9259f9c..447e4c4 100644
--- a/content/browser/startup_helper.h
+++ b/content/browser/startup_helper.h
@@ -15,8 +15,8 @@
std::unique_ptr<base::FieldTrialList> CONTENT_EXPORT
SetUpFieldTrialsAndFeatureList();
-// Starts the task scheduler.
-void CONTENT_EXPORT StartBrowserTaskScheduler();
+// Starts the ThreadPool.
+void CONTENT_EXPORT StartBrowserThreadPool();
} // namespace content
diff --git a/content/child/child_process.cc b/content/child/child_process.cc
index 4313421..9313e99 100644
--- a/content/child/child_process.cc
+++ b/content/child/child_process.cc
@@ -11,7 +11,7 @@
#include "base/message_loop/message_loop.h"
#include "base/process/process_handle.h"
#include "base/single_thread_task_runner.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread.h"
#include "base/threading/thread_local.h"
#include "build/build_config.h"
@@ -26,8 +26,8 @@
ChildProcess::ChildProcess(
base::ThreadPriority io_thread_priority,
- const std::string& task_scheduler_name,
- std::unique_ptr<base::TaskScheduler::InitParams> task_scheduler_init_params)
+ const std::string& thread_pool_name,
+ std::unique_ptr<base::ThreadPool::InitParams> thread_pool_init_params)
: ref_count_(0),
shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED),
@@ -35,20 +35,19 @@
DCHECK(!g_lazy_child_process_tls.Pointer()->Get());
g_lazy_child_process_tls.Pointer()->Set(this);
- // Initialize TaskScheduler if not already done. A TaskScheduler may already
+ // Initialize ThreadPool if not already done. A ThreadPool may already
// exist when ChildProcess is instantiated in the browser process or in a
// test process.
- if (!base::TaskScheduler::GetInstance()) {
- if (task_scheduler_init_params) {
- base::TaskScheduler::Create(task_scheduler_name);
- base::TaskScheduler::GetInstance()->Start(
- *task_scheduler_init_params.get());
+ if (!base::ThreadPool::GetInstance()) {
+ if (thread_pool_init_params) {
+ base::ThreadPool::Create(thread_pool_name);
+ base::ThreadPool::GetInstance()->Start(*thread_pool_init_params.get());
} else {
- base::TaskScheduler::CreateAndStartWithDefaultParams(task_scheduler_name);
+ base::ThreadPool::CreateAndStartWithDefaultParams(thread_pool_name);
}
- DCHECK(base::TaskScheduler::GetInstance());
- initialized_task_scheduler_ = true;
+ DCHECK(base::ThreadPool::GetInstance());
+ initialized_thread_pool_ = true;
}
// We can't recover from failing to start the IO thread.
@@ -85,9 +84,9 @@
g_lazy_child_process_tls.Pointer()->Set(nullptr);
io_thread_.Stop();
- if (initialized_task_scheduler_) {
- DCHECK(base::TaskScheduler::GetInstance());
- base::TaskScheduler::GetInstance()->Shutdown();
+ if (initialized_thread_pool_) {
+ DCHECK(base::ThreadPool::GetInstance());
+ base::ThreadPool::GetInstance()->Shutdown();
}
}
diff --git a/content/child/child_process.h b/content/child/child_process.h
index ff74b61..71c9e34 100644
--- a/content/child/child_process.h
+++ b/content/child/child_process.h
@@ -10,7 +10,7 @@
#include "base/macros.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread.h"
#include "content/common/content_export.h"
@@ -37,14 +37,14 @@
// Child processes should have an object that derives from this class.
// Normally you would immediately call set_main_thread after construction.
// |io_thread_priority| is the priority of the IO thread.
- // |task_scheduler_name| and |task_scheduler_init_params| are used to
- // initialize TaskScheduler. Default params are used if
- // |task_scheduler_init_params| is nullptr.
+ // |thread_pool_name| and |thread_pool_init_params| are used to
+ // initialize ThreadPool. Default params are used if
+ // |thread_pool_init_params| is nullptr.
ChildProcess(
base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL,
- const std::string& task_scheduler_name = "ContentChild",
- std::unique_ptr<base::TaskScheduler::InitParams>
- task_scheduler_init_params = nullptr);
+ const std::string& thread_pool_name = "ContentChild",
+ std::unique_ptr<base::ThreadPool::InitParams> thread_pool_init_params =
+ nullptr);
virtual ~ChildProcess();
// May be NULL if the main thread hasn't been set explicitly.
@@ -97,8 +97,8 @@
// io_thread_.
std::unique_ptr<ChildThreadImpl> main_thread_;
- // Whether this ChildProcess initialized TaskScheduler.
- bool initialized_task_scheduler_ = false;
+ // Whether this ChildProcess initialized ThreadPool.
+ bool initialized_thread_pool_ = false;
DISALLOW_COPY_AND_ASSIGN(ChildProcess);
};
diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn
index 8ec3d83..080d08c 100644
--- a/content/common/BUILD.gn
+++ b/content/common/BUILD.gn
@@ -236,11 +236,11 @@
"swapped_out_messages.h",
"tab_switch_time_recorder.cc",
"tab_switch_time_recorder.h",
- "task_scheduler.cc",
- "task_scheduler.h",
"text_input_client_messages.h",
"text_input_state.cc",
"text_input_state.h",
+ "thread_pool_util.cc",
+ "thread_pool_util.h",
"throttling_url_loader.cc",
"throttling_url_loader.h",
"unique_name_helper.cc",
diff --git a/content/common/task_scheduler.h b/content/common/task_scheduler.h
deleted file mode 100644
index caacee36..0000000
--- a/content/common/task_scheduler.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_COMMON_TASK_SCHEDULER_
-#define CONTENT_COMMON_TASK_SCHEDULER_
-
-#include "content/common/content_export.h"
-
-namespace content {
-
-// Returns the minimum number of threads that the TaskScheduler foreground pool
-// must have in a process that runs a renderer.
-int GetMinThreadsInRendererTaskSchedulerForegroundPool();
-
-} // namespace content
-
-#endif // CONTENT_COMMON_TASK_SCHEDULER_
diff --git a/content/common/task_scheduler.cc b/content/common/thread_pool_util.cc
similarity index 78%
rename from content/common/task_scheduler.cc
rename to content/common/thread_pool_util.cc
index 193b2df..83e62f5 100644
--- a/content/common/task_scheduler.cc
+++ b/content/common/thread_pool_util.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/common/task_scheduler.h"
+#include "content/common/thread_pool_util.h"
#include <algorithm>
@@ -10,7 +10,7 @@
namespace content {
-int GetMinThreadsInRendererTaskSchedulerForegroundPool() {
+int GetMinForegroundThreadsInRendererThreadPool() {
// Assume a busy main thread.
return std::max(1, base::SysInfo::NumberOfProcessors() - 1);
}
diff --git a/content/common/thread_pool_util.h b/content/common/thread_pool_util.h
new file mode 100644
index 0000000..36ebf5a
--- /dev/null
+++ b/content/common/thread_pool_util.h
@@ -0,0 +1,18 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_THREAD_POOL_UTIL_H_
+#define CONTENT_COMMON_THREAD_POOL_UTIL_H_
+
+#include "content/common/content_export.h"
+
+namespace content {
+
+// Returns the minimum number of foreground threads that the ThreadPool
+// must have in a process that runs a renderer.
+int GetMinForegroundThreadsInRendererThreadPool();
+
+} // namespace content
+
+#endif // CONTENT_COMMON_THREAD_POOL_UTIL_H_
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/scheduler/NativePostTaskTest.java b/content/public/android/javatests/src/org/chromium/content/browser/scheduler/NativePostTaskTest.java
index 297f755..86b654b 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/scheduler/NativePostTaskTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/scheduler/NativePostTaskTest.java
@@ -20,7 +20,7 @@
import org.chromium.base.task.TaskTraits;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.task.SchedulerTestHelpers;
-import org.chromium.base.test.task.TaskSchedulerTestHelpers;
+import org.chromium.base.test.task.ThreadPoolTestHelpers;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.content.app.ContentMain;
import org.chromium.content_public.browser.test.NativeLibraryTestRule;
@@ -42,7 +42,7 @@
@After
public void tearDown() {
- TaskSchedulerTestHelpers.disableTaskSchedulerExecutionForTesting();
+ ThreadPoolTestHelpers.disableThreadPoolExecutionForTesting();
}
@Test
@@ -257,6 +257,6 @@
private void startNativeScheduler() throws Exception {
mNativeLibraryTestRule.loadNativeLibraryNoBrowserProcess();
ContentMain.start(/* startServiceManagerOnly */ true);
- TaskSchedulerTestHelpers.enableTaskSchedulerExecutionForTesting();
+ ThreadPoolTestHelpers.enableThreadPoolExecutionForTesting();
}
}
diff --git a/content/public/app/content_main_delegate.h b/content/public/app/content_main_delegate.h
index f836a17f..f498906 100644
--- a/content/public/app/content_main_delegate.h
+++ b/content/public/app/content_main_delegate.h
@@ -123,7 +123,7 @@
virtual bool ShouldCreateFeatureList();
// Allows the embedder to perform its own initialization after content
- // performed its own and already brought up MessageLoop, TaskScheduler, field
+ // performed its own and already brought up MessageLoop, ThreadPool, field
// trials and FeatureList (by default).
// |is_running_tests| indicates whether it is running in tests.
virtual void PostEarlyInitialization(bool is_running_tests) {}
diff --git a/content/public/browser/browser_thread.h b/content/public/browser/browser_thread.h
index 8a83217e..247c7405 100644
--- a/content/public/browser/browser_thread.h
+++ b/content/public/browser/browser_thread.h
@@ -54,11 +54,11 @@
UI,
// This is the thread that processes non-blocking IO, i.e. IPC and network.
- // Blocking I/O should happen in TaskScheduler.
+ // Blocking I/O should happen in ThreadPool.
IO,
// NOTE: do not add new threads here. Instead you should just use
- // base::Create*TaskRunnerWithTraits to run tasks on the TaskScheduler.
+ // base::Create*TaskRunnerWithTraits to run tasks on the ThreadPool.
// This identifier does not represent a thread. Instead it counts the
// number of well-known threads. Insert new well-known threads before this
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc
index 13cad74..7a48231 100644
--- a/content/public/browser/content_browser_client.cc
+++ b/content/public/browser/content_browser_client.cc
@@ -732,8 +732,8 @@
return nullptr;
}
-std::unique_ptr<base::TaskScheduler::InitParams>
-ContentBrowserClient::GetTaskSchedulerInitParams() {
+std::unique_ptr<base::ThreadPool::InitParams>
+ContentBrowserClient::GetThreadPoolInitParams() {
return nullptr;
}
@@ -856,7 +856,7 @@
return false;
}
-bool ContentBrowserClient::ShouldCreateTaskScheduler() {
+bool ContentBrowserClient::ShouldCreateThreadPool() {
return true;
}
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index fc58b2d..7173014 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -18,7 +18,7 @@
#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/optional.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
@@ -1174,10 +1174,10 @@
// Returns the RapporService from the browser process.
virtual ::rappor::RapporService* GetRapporService();
- // Provides parameters for initializing the global task scheduler. Default
+ // Provides parameters for initializing the global thread pool. Default
// params are used if this returns nullptr.
- virtual std::unique_ptr<base::TaskScheduler::InitParams>
- GetTaskSchedulerInitParams();
+ virtual std::unique_ptr<base::ThreadPool::InitParams>
+ GetThreadPoolInitParams();
// Allows the embedder to register one or more URLLoaderThrottles for a
// navigation request.
@@ -1373,13 +1373,13 @@
int /* render_process_id */,
int /* render_frame_id */)> callback);
- // Returns whether a base::TaskScheduler should be created when
+ // Returns whether a base::ThreadPool should be created when
// BrowserMainLoop starts.
- // If false, a task scheduler has been created by the embedder, and
+ // If false, a thread pool has been created by the embedder, and
// BrowserMainLoop should skip creating a second one.
- // Note: the embedder should *not* start the TaskScheduler for
+ // Note: the embedder should *not* start the ThreadPool for
// BrowserMainLoop, BrowserMainLoop itself is responsible for that.
- virtual bool ShouldCreateTaskScheduler();
+ virtual bool ShouldCreateThreadPool();
// Returns an AuthenticatorRequestClientDelegate subclass instance to provide
// embedder-specific configuration for a single Web Authentication API request
diff --git a/content/public/renderer/content_renderer_client.cc b/content/public/renderer/content_renderer_client.cc
index e917d74..0a6af92 100644
--- a/content/public/renderer/content_renderer_client.cc
+++ b/content/public/renderer/content_renderer_client.cc
@@ -236,8 +236,8 @@
return GURL();
}
-std::unique_ptr<base::TaskScheduler::InitParams>
-ContentRendererClient::GetTaskSchedulerInitParams() {
+std::unique_ptr<base::ThreadPool::InitParams>
+ContentRendererClient::GetThreadPoolInitParams() {
return nullptr;
}
diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h
index a7413c4..fad5f104 100644
--- a/content/public/renderer/content_renderer_client.h
+++ b/content/public/renderer/content_renderer_client.h
@@ -17,7 +17,7 @@
#include "base/memory/ref_counted.h"
#include "base/optional.h"
#include "base/strings/string16.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
#include "content/public/common/content_client.h"
#include "content/public/renderer/url_loader_throttle_provider.h"
@@ -387,10 +387,10 @@
// An empty URL is returned if the URL is not overriden.
virtual GURL OverrideFlashEmbedWithHTML(const GURL& url);
- // Provides parameters for initializing the global task scheduler. Default
+ // Provides parameters for initializing the global thread pool. Default
// params are used if this returns nullptr.
- virtual std::unique_ptr<base::TaskScheduler::InitParams>
- GetTaskSchedulerInitParams();
+ virtual std::unique_ptr<base::ThreadPool::InitParams>
+ GetThreadPoolInitParams();
// Whether the renderer allows idle media players to be automatically
// suspended after a period of inactivity.
diff --git a/content/public/test/browser_test_base.cc b/content/public/test/browser_test_base.cc
index 81efafa..7ee6ba1f 100644
--- a/content/public/test/browser_test_base.cc
+++ b/content/public/test/browser_test_base.cc
@@ -339,10 +339,10 @@
MainFunctionParams params(*command_line);
params.ui_task = ui_task.release();
params.created_main_parts_closure = created_main_parts_closure.release();
- base::TaskScheduler::Create("Browser");
+ base::ThreadPool::Create("Browser");
DCHECK(!field_trial_list_);
field_trial_list_ = SetUpFieldTrialsAndFeatureList();
- StartBrowserTaskScheduler();
+ StartBrowserThreadPool();
BrowserTaskExecutor::Create();
BrowserTaskExecutor::PostFeatureListSetup();
// TODO(phajdan.jr): Check return code, http://crbug.com/374738 .
diff --git a/content/public/test/browsing_data_remover_test_util.cc b/content/public/test/browsing_data_remover_test_util.cc
index 2ea2ab6..3fde4e2 100644
--- a/content/public/test/browsing_data_remover_test_util.cc
+++ b/content/public/test/browsing_data_remover_test_util.cc
@@ -5,7 +5,7 @@
#include "content/public/test/browsing_data_remover_test_util.h"
#include "base/bind.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
namespace content {
@@ -21,7 +21,7 @@
~BrowsingDataRemoverCompletionObserver() {}
void BrowsingDataRemoverCompletionObserver::BlockUntilCompletion() {
- base::TaskScheduler::GetInstance()->FlushAsyncForTesting(base::BindOnce(
+ base::ThreadPool::GetInstance()->FlushAsyncForTesting(base::BindOnce(
&BrowsingDataRemoverCompletionObserver::FlushForTestingComplete,
base::Unretained(this)));
run_loop_.Run();
@@ -79,7 +79,7 @@
}
void BrowsingDataRemoverCompletionInhibitor::BlockUntilNearCompletion() {
- base::TaskScheduler::GetInstance()->FlushAsyncForTesting(base::BindOnce(
+ base::ThreadPool::GetInstance()->FlushAsyncForTesting(base::BindOnce(
&BrowsingDataRemoverCompletionInhibitor::FlushForTestingComplete,
base::Unretained(this)));
run_loop_->Run();
diff --git a/content/public/test/test_browser_context.cc b/content/public/test/test_browser_context.cc
index 3eb2489..d81a75d 100644
--- a/content/public/test/test_browser_context.cc
+++ b/content/public/test/test_browser_context.cc
@@ -9,7 +9,7 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/single_thread_task_runner.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/null_task_runner.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/permission_controller_delegate.h"
@@ -72,12 +72,12 @@
NotifyWillBeDestroyed(this);
ShutdownStoragePartitions();
- // disk_cache::SimpleBackendImpl performs all disk IO on the TaskScheduler
+ // disk_cache::SimpleBackendImpl performs all disk IO on the ThreadPool
// threads. The cache is initialized in the directory owned by
// |browser_context_dir_| and so ScopedTempDir destructor may race with cache
// IO (see https://crbug.com/910029 for example). Let all pending IO
// operations finish before destroying |browser_context_dir_|.
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
base::FilePath TestBrowserContext::TakePath() {
diff --git a/content/public/test/test_browser_thread_bundle.cc b/content/public/test/test_browser_thread_bundle.cc
index f9e7ea4..352d8ee 100644
--- a/content/public/test/test_browser_thread_bundle.cc
+++ b/content/public/test/test_browser_thread_bundle.cc
@@ -32,7 +32,7 @@
TestBrowserThreadBundle::~TestBrowserThreadBundle() {
// This is required to ensure we run all remaining MessageLoop and
- // TaskScheduler tasks in an atomic step. This is a bit different than
+ // ThreadPool tasks in an atomic step. This is a bit different than
// production where the main thread is not flushed after it's done running
// but this approach is preferred in unit tests as running more tasks can
// merely uncover more issues (e.g. if a bad tasks is posted but never
diff --git a/content/public/test/test_browser_thread_bundle.h b/content/public/test/test_browser_thread_bundle.h
index 16e50f0..ad553ac 100644
--- a/content/public/test/test_browser_thread_bundle.h
+++ b/content/public/test/test_browser_thread_bundle.h
@@ -13,7 +13,7 @@
// By default, BrowserThread::UI/IO are backed by a single shared MessageLoop on
// the main thread. If a test truly needs BrowserThread::IO tasks to run on a
// separate thread, it can pass the REAL_IO_THREAD option to the constructor.
-// TaskScheduler tasks always run on dedicated threads.
+// ThreadPool tasks always run on dedicated threads.
//
// To synchronously run tasks from the shared MessageLoop:
//
@@ -21,8 +21,8 @@
// base::RunLoop::RunUntilIdle();
//
// ... until there are no undelayed tasks in the shared MessageLoop, in
-// TaskScheduler (excluding tasks not posted from the shared MessageLoop's
-// thread or TaskScheduler):
+// ThreadPool (excluding tasks not posted from the shared MessageLoop's
+// thread or ThreadPool):
// content::RunAllTasksUntilIdle();
//
// ... until a condition is met:
@@ -32,19 +32,19 @@
// // run_loop.QuitClosure() must be kept somewhere accessible by that task).
// run_loop.Run();
//
-// To wait until there are no pending undelayed tasks in TaskScheduler, without
+// To wait until there are no pending undelayed tasks in ThreadPool, without
// running tasks from the shared MessageLoop:
-// base::TaskScheduler::GetInstance()->FlushForTesting();
+// base::ThreadPool::GetInstance()->FlushForTesting();
//
// The destructor of TestBrowserThreadBundle runs remaining UI/IO tasks and
-// remaining task scheduler tasks.
+// remaining thread pool tasks.
//
// If a test needs to pump IO messages on the main thread, it should use the
// IO_MAINLOOP option. Most of the time, IO_MAINLOOP avoids needing to use a
// REAL_IO_THREAD.
//
// For some tests it is important to emulate real browser startup. During real
-// browser startup, the main MessageLoop and the TaskScheduler are created
+// browser startup, the main MessageLoop and the ThreadPool are created
// before browser threads. Passing DONT_CREATE_BROWSER_THREADS to constructor
// will delay creating browser threads until the test explicitly calls
// CreateBrowserThreads().
@@ -54,7 +54,7 @@
//
// TestBrowserThreadBundle may be instantiated in a scope where there is already
// a base::test::ScopedTaskEnvironment. In that case, it will use the
-// MessageLoop and the TaskScheduler provided by this
+// MessageLoop and the ThreadPool provided by this
// base::test::ScopedTaskEnvironment instead of creating its own. The ability to
// have a base::test::ScopedTaskEnvironment and a TestBrowserThreadBundle in the
// same scope is useful when a fixture that inherits from a fixture that
@@ -137,10 +137,10 @@
UseRealIOThread(
base::trait_helpers::GetOptionalEnum<Options>(args...))) {}
- // Runs all tasks posted to TaskScheduler and main thread until idle.
+ // Runs all tasks posted to ThreadPool and main thread until idle.
// Note: At the moment, this will not process BrowserThread::IO if this
// TestBrowserThreadBundle is using a REAL_IO_THREAD.
- // TODO(robliao): fix this by making TaskScheduler aware of all MessageLoops.
+ // TODO(robliao): fix this by making ThreadPool aware of all MessageLoops.
//
// Note that this is not the cleanest way to run until idle as it will return
// early if it depends on an async condition that isn't guaranteed to have
diff --git a/content/public/test/test_browser_thread_bundle_unittest.cc b/content/public/test/test_browser_thread_bundle_unittest.cc
index 61f8857..5310d9df 100644
--- a/content/public/test/test_browser_thread_bundle_unittest.cc
+++ b/content/public/test/test_browser_thread_bundle_unittest.cc
@@ -21,14 +21,14 @@
namespace {
// TestBrowserThreadBundleTest.RunUntilIdle will run kNumTasks tasks that will
-// hop back-and-forth between TaskScheduler and UI thread kNumHops times.
+// hop back-and-forth between ThreadPool and UI thread kNumHops times.
// Note: These values are arbitrary.
constexpr int kNumHops = 13;
constexpr int kNumTasks = 8;
void PostTaskToUIThread(int iteration, base::subtle::Atomic32* tasks_run);
-void PostToTaskScheduler(int iteration, base::subtle::Atomic32* tasks_run) {
+void PostToThreadPool(int iteration, base::subtle::Atomic32* tasks_run) {
// All iterations but the first come from a task that was posted.
if (iteration > 0)
base::subtle::NoBarrier_AtomicIncrement(tasks_run, 1);
@@ -50,7 +50,7 @@
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
- base::BindOnce(&PostToTaskScheduler, iteration + 1, tasks_run));
+ base::BindOnce(&PostToThreadPool, iteration + 1, tasks_run));
}
} // namespace
@@ -60,11 +60,11 @@
base::subtle::Atomic32 tasks_run = 0;
- // Post half the tasks on TaskScheduler and the other half on the UI thread
+ // Post half the tasks on ThreadPool and the other half on the UI thread
// so they cross and the last hops aren't all on the same task runner.
for (int i = 0; i < kNumTasks; ++i) {
if (i % 2) {
- PostToTaskScheduler(0, &tasks_run);
+ PostToThreadPool(0, &tasks_run);
} else {
PostTaskToUIThread(0, &tasks_run);
}
diff --git a/content/public/test/test_utils.cc b/content/public/test/test_utils.cc
index 7842985..2abdf31 100644
--- a/content/public/test/test_utils.cc
+++ b/content/public/test/test_utils.cc
@@ -18,7 +18,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/task/sequence_manager/sequence_manager.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "build/build_config.h"
@@ -149,7 +149,7 @@
base::MessageLoopCurrent::Get()->AddTaskObserver(&task_observer);
base::RunLoop run_loop;
- base::TaskScheduler::GetInstance()->FlushAsyncForTesting(
+ base::ThreadPool::GetInstance()->FlushAsyncForTesting(
run_loop.QuitWhenIdleClosure());
run_loop.Run();
diff --git a/content/public/test/test_utils.h b/content/public/test/test_utils.h
index 60bb9e6..5301c4b 100644
--- a/content/public/test/test_utils.h
+++ b/content/public/test/test_utils.h
@@ -72,7 +72,7 @@
// rather than flushing entire threads.
void RunAllPendingInMessageLoop(BrowserThread::ID thread_id);
-// Runs all tasks on the current thread and TaskScheduler threads until idle.
+// Runs all tasks on the current thread and ThreadPool threads until idle.
// Note: Prefer TestBrowserThreadBundle::RunUntilIdle() in unit tests.
void RunAllTasksUntilIdle();
diff --git a/content/public/test/unittest_test_suite.cc b/content/public/test/unittest_test_suite.cc
index 788e922..422145c 100644
--- a/content/public/test/unittest_test_suite.cc
+++ b/content/public/test/unittest_test_suite.cc
@@ -48,9 +48,9 @@
new_command_line.AppendSwitchNative(iter.first, iter.second);
*base::CommandLine::ForCurrentProcess() = new_command_line;
- // The TaskScheduler created by the test launcher is never destroyed.
+ // The ThreadPool created by the test launcher is never destroyed.
// Similarly, the FeatureList created here is never destroyed so it
- // can safely be accessed by the TaskScheduler.
+ // can safely be accessed by the ThreadPool.
std::unique_ptr<base::FeatureList> feature_list =
std::make_unique<base::FeatureList>();
feature_list->InitializeFromCommandLine(enabled, disabled);
diff --git a/content/renderer/compositor/layer_tree_view.cc b/content/renderer/compositor/layer_tree_view.cc
index a356f1f..6fc42f7 100644
--- a/content/renderer/compositor/layer_tree_view.cc
+++ b/content/renderer/compositor/layer_tree_view.cc
@@ -16,8 +16,8 @@
#include "base/metrics/histogram_macros.h"
#include "base/single_thread_task_runner.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/time/time.h"
#include "base/values.h"
#include "cc/animation/animation_host.h"
@@ -81,7 +81,7 @@
params.main_task_runner = main_thread_;
params.mutator_host = animation_host_.get();
params.ukm_recorder_factory = std::move(ukm_recorder_factory);
- if (base::TaskScheduler::GetInstance()) {
+ if (base::ThreadPool::GetInstance()) {
// The image worker thread needs to allow waiting since it makes discardable
// shared memory allocations which need to make synchronous calls to the
// IO thread.
diff --git a/content/renderer/media/stream/media_stream_video_renderer_sink_unittest.cc b/content/renderer/media/stream/media_stream_video_renderer_sink_unittest.cc
index dd552e8..c5805d6 100644
--- a/content/renderer/media/stream/media_stream_video_renderer_sink_unittest.cc
+++ b/content/renderer/media/stream/media_stream_video_renderer_sink_unittest.cc
@@ -105,7 +105,7 @@
protected:
// A ChildProcess is needed to fool the Tracks and Sources into believing they
// are on the right threads. A ScopedTaskEnvironment must be instantiated
- // before ChildProcess to prevent it from leaking a TaskScheduler.
+ // before ChildProcess to prevent it from leaking a ThreadPool.
base::test::ScopedTaskEnvironment scoped_task_environment_;
const std::unique_ptr<ChildProcess> child_process_;
diff --git a/content/renderer/media/stream/media_stream_video_track_unittest.cc b/content/renderer/media/stream/media_stream_video_track_unittest.cc
index e457c65c..f84970a 100644
--- a/content/renderer/media/stream/media_stream_video_track_unittest.cc
+++ b/content/renderer/media/stream/media_stream_video_track_unittest.cc
@@ -137,7 +137,7 @@
private:
// The ScopedTaskEnvironment prevents the ChildProcess from leaking a
- // TaskScheduler.
+ // ThreadPool.
const base::test::ScopedTaskEnvironment scoped_task_environment_;
const ChildProcess child_process_;
blink::WebMediaStreamSource blink_source_;
diff --git a/content/renderer/media/stream/user_media_client_impl_unittest.cc b/content/renderer/media/stream/user_media_client_impl_unittest.cc
index b91aac6..4a027c0 100644
--- a/content/renderer/media/stream/user_media_client_impl_unittest.cc
+++ b/content/renderer/media/stream/user_media_client_impl_unittest.cc
@@ -627,7 +627,7 @@
protected:
// The ScopedTaskEnvironment prevents the ChildProcess from leaking a
- // TaskScheduler.
+ // ThreadPool.
base::test::ScopedTaskEnvironment scoped_task_environment_;
ChildProcess child_process_;
MediaStreamDeviceObserver* msd_observer_ =
diff --git a/content/renderer/media/webrtc/media_stream_video_webrtc_sink_unittest.cc b/content/renderer/media/webrtc/media_stream_video_webrtc_sink_unittest.cc
index fccb236..e523d75 100644
--- a/content/renderer/media/webrtc/media_stream_video_webrtc_sink_unittest.cc
+++ b/content/renderer/media/webrtc/media_stream_video_webrtc_sink_unittest.cc
@@ -52,7 +52,7 @@
MockMediaStreamRegistry registry_;
// A ChildProcess is needed to fool the Tracks and Sources into believing they
// are on the right threads. A ScopedTaskEnvironment must be instantiated
- // before ChildProcess to prevent it from leaking a TaskScheduler.
+ // before ChildProcess to prevent it from leaking a ThreadPool.
base::test::ScopedTaskEnvironment scoped_task_environment_;
const ChildProcess child_process_;
};
diff --git a/content/renderer/media/webrtc/rtc_peer_connection_handler_unittest.cc b/content/renderer/media/webrtc/rtc_peer_connection_handler_unittest.cc
index 0330405..9497849 100644
--- a/content/renderer/media/webrtc/rtc_peer_connection_handler_unittest.cc
+++ b/content/renderer/media/webrtc/rtc_peer_connection_handler_unittest.cc
@@ -566,7 +566,7 @@
public:
// The ScopedTaskEnvironment prevents the ChildProcess from leaking a
- // TaskScheduler.
+ // ThreadPool.
base::test::ScopedTaskEnvironment scoped_task_environment_;
ChildProcess child_process_;
std::unique_ptr<MockWebRTCPeerConnectionHandlerClient> mock_client_;
diff --git a/content/renderer/media/webrtc/rtc_rtp_receiver_unittest.cc b/content/renderer/media/webrtc/rtc_rtp_receiver_unittest.cc
index c75292c..9824192 100644
--- a/content/renderer/media/webrtc/rtc_rtp_receiver_unittest.cc
+++ b/content/renderer/media/webrtc/rtc_rtp_receiver_unittest.cc
@@ -99,7 +99,7 @@
}
// Code under test expects to be run in a process with an initialized
- // ChildProcess, which requires TaskScheduler, and a main-thread MessageLoop,
+ // ChildProcess, which requires ThreadPool, and a main-thread MessageLoop,
// which the ScopedTaskEnvironment also provides.
base::test::ScopedTaskEnvironment task_environment_;
ChildProcess child_process_;
diff --git a/content/renderer/media/webrtc/rtc_rtp_sender_unittest.cc b/content/renderer/media/webrtc/rtc_rtp_sender_unittest.cc
index 9e487756..6bc1068 100644
--- a/content/renderer/media/webrtc/rtc_rtp_sender_unittest.cc
+++ b/content/renderer/media/webrtc/rtc_rtp_sender_unittest.cc
@@ -140,7 +140,7 @@
}
// Code under test expects to be run in a process with an initialized
- // ChildProcess, which requires TaskScheduler, and a main-thread MessageLoop,
+ // ChildProcess, which requires ThreadPool, and a main-thread MessageLoop,
// which the ScopedTaskEnvironment also provides.
base::test::ScopedTaskEnvironment task_environment_;
ChildProcess child_process_;
diff --git a/content/renderer/media/webrtc/webrtc_media_stream_track_adapter_map_unittest.cc b/content/renderer/media/webrtc/webrtc_media_stream_track_adapter_map_unittest.cc
index 6c8f85f..7991921 100644
--- a/content/renderer/media/webrtc/webrtc_media_stream_track_adapter_map_unittest.cc
+++ b/content/renderer/media/webrtc/webrtc_media_stream_track_adapter_map_unittest.cc
@@ -108,7 +108,7 @@
protected:
// The ScopedTaskEnvironment prevents the ChildProcess from leaking a
- // TaskScheduler.
+ // ThreadPool.
base::test::ScopedTaskEnvironment scoped_task_environment_;
ChildProcess child_process_;
diff --git a/content/renderer/media/webrtc/webrtc_media_stream_track_adapter_unittest.cc b/content/renderer/media/webrtc/webrtc_media_stream_track_adapter_unittest.cc
index 1fdb8ebeb..f5fdf11 100644
--- a/content/renderer/media/webrtc/webrtc_media_stream_track_adapter_unittest.cc
+++ b/content/renderer/media/webrtc/webrtc_media_stream_track_adapter_unittest.cc
@@ -114,7 +114,7 @@
protected:
// The ScopedTaskEnvironment prevents the ChildProcess from leaking a
- // TaskScheduler.
+ // ThreadPool.
base::test::ScopedTaskEnvironment scoped_task_environment_;
ChildProcess child_process_;
diff --git a/content/renderer/media/webrtc/webrtc_set_description_observer_unittest.cc b/content/renderer/media/webrtc/webrtc_set_description_observer_unittest.cc
index 51859eb..9034235 100644
--- a/content/renderer/media/webrtc/webrtc_set_description_observer_unittest.cc
+++ b/content/renderer/media/webrtc/webrtc_set_description_observer_unittest.cc
@@ -362,7 +362,7 @@
protected:
// The ScopedTaskEnvironment prevents the ChildProcess from leaking a
- // TaskScheduler.
+ // ThreadPool.
base::test::ScopedTaskEnvironment scoped_task_environment_;
ChildProcess child_process_;
diff --git a/content/renderer/media_capture_from_element/canvas_capture_handler_unittest.cc b/content/renderer/media_capture_from_element/canvas_capture_handler_unittest.cc
index 949fe1de..0952402 100644
--- a/content/renderer/media_capture_from_element/canvas_capture_handler_unittest.cc
+++ b/content/renderer/media_capture_from_element/canvas_capture_handler_unittest.cc
@@ -134,7 +134,7 @@
// A ChildProcess is needed to fool the Tracks and Sources believing they are
// on the right threads. A ScopedTaskEnvironment must be instantiated before
- // ChildProcess to prevent it from leaking a TaskScheduler.
+ // ChildProcess to prevent it from leaking a ThreadPool.
base::test::ScopedTaskEnvironment scoped_task_environment_;
ChildProcess child_process_;
diff --git a/content/renderer/media_recorder/video_track_recorder_unittest.cc b/content/renderer/media_recorder/video_track_recorder_unittest.cc
index 6194edb..ac3320c 100644
--- a/content/renderer/media_recorder/video_track_recorder_unittest.cc
+++ b/content/renderer/media_recorder/video_track_recorder_unittest.cc
@@ -148,7 +148,7 @@
// A ChildProcess is needed to fool the Tracks and Sources into believing they
// are on the right threads. A ScopedTaskEnvironment must be instantiated
- // before ChildProcess to prevent it from leaking a TaskScheduler.
+ // before ChildProcess to prevent it from leaking a ThreadPool.
base::test::ScopedTaskEnvironment scoped_task_environment_;
const ChildProcess child_process_;
diff --git a/content/renderer/render_process.cc b/content/renderer/render_process.cc
index a79a5a2..81e49e2e 100644
--- a/content/renderer/render_process.cc
+++ b/content/renderer/render_process.cc
@@ -9,10 +9,10 @@
namespace content {
RenderProcess::RenderProcess(
- const std::string& task_scheduler_name,
- std::unique_ptr<base::TaskScheduler::InitParams> task_scheduler_init_params)
+ const std::string& thread_pool_name,
+ std::unique_ptr<base::ThreadPool::InitParams> thread_pool_init_params)
: ChildProcess(base::ThreadPriority::NORMAL,
- task_scheduler_name,
- std::move(task_scheduler_init_params)) {}
+ thread_pool_name,
+ std::move(thread_pool_init_params)) {}
} // namespace content
diff --git a/content/renderer/render_process.h b/content/renderer/render_process.h
index 74081953..d5efd0ff 100644
--- a/content/renderer/render_process.h
+++ b/content/renderer/render_process.h
@@ -10,7 +10,7 @@
#include <vector>
#include "base/macros.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "content/child/child_process.h"
namespace content {
@@ -25,9 +25,9 @@
class RenderProcess : public ChildProcess {
public:
RenderProcess() = default;
- RenderProcess(const std::string& task_scheduler_name,
- std::unique_ptr<base::TaskScheduler::InitParams>
- task_scheduler_init_params);
+ RenderProcess(
+ const std::string& thread_pool_name,
+ std::unique_ptr<base::ThreadPool::InitParams> thread_pool_init_params);
~RenderProcess() override {}
// Keep track of the cumulative set of enabled bindings for this process,
diff --git a/content/renderer/render_process_impl.cc b/content/renderer/render_process_impl.cc
index f71fc7c..8a0fea0 100644
--- a/content/renderer/render_process_impl.cc
+++ b/content/renderer/render_process_impl.cc
@@ -26,9 +26,9 @@
#include "base/feature_list.h"
#include "base/memory/ptr_util.h"
#include "base/system/sys_info.h"
-#include "base/task/task_scheduler/initialization_util.h"
+#include "base/task/thread_pool/initialization_util.h"
#include "base/time/time.h"
-#include "content/common/task_scheduler.h"
+#include "content/common/thread_pool_util.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_features.h"
@@ -62,19 +62,17 @@
}
}
-std::unique_ptr<base::TaskScheduler::InitParams>
-GetDefaultTaskSchedulerInitParams() {
+std::unique_ptr<base::ThreadPool::InitParams> GetDefaultThreadPoolInitParams() {
constexpr int kMaxNumThreadsInBackgroundPool = 2;
constexpr int kMaxNumThreadsInForegroundPoolLowerBound = 3;
constexpr auto kSuggestedReclaimTime = base::TimeDelta::FromSeconds(30);
- return std::make_unique<base::TaskScheduler::InitParams>(
+ return std::make_unique<base::ThreadPool::InitParams>(
base::SchedulerWorkerPoolParams(kMaxNumThreadsInBackgroundPool,
kSuggestedReclaimTime),
base::SchedulerWorkerPoolParams(
- std::max(
- kMaxNumThreadsInForegroundPoolLowerBound,
- content::GetMinThreadsInRendererTaskSchedulerForegroundPool()),
+ std::max(kMaxNumThreadsInForegroundPoolLowerBound,
+ content::GetMinForegroundThreadsInRendererThreadPool()),
kSuggestedReclaimTime));
}
@@ -91,8 +89,8 @@
namespace content {
RenderProcessImpl::RenderProcessImpl(
- std::unique_ptr<base::TaskScheduler::InitParams> task_scheduler_init_params)
- : RenderProcess("Renderer", std::move(task_scheduler_init_params)),
+ std::unique_ptr<base::ThreadPool::InitParams> thread_pool_init_params)
+ : RenderProcess("Renderer", std::move(thread_pool_init_params)),
enabled_bindings_(0) {
#if defined(DCHECK_IS_CONFIGURABLE)
// Some official builds ship with DCHECKs compiled in. Failing DCHECKs then
@@ -232,13 +230,13 @@
}
std::unique_ptr<RenderProcess> RenderProcessImpl::Create() {
- auto task_scheduler_init_params =
- content::GetContentClient()->renderer()->GetTaskSchedulerInitParams();
- if (!task_scheduler_init_params)
- task_scheduler_init_params = GetDefaultTaskSchedulerInitParams();
+ auto thread_pool_init_params =
+ content::GetContentClient()->renderer()->GetThreadPoolInitParams();
+ if (!thread_pool_init_params)
+ thread_pool_init_params = GetDefaultThreadPoolInitParams();
return base::WrapUnique(
- new RenderProcessImpl(std::move(task_scheduler_init_params)));
+ new RenderProcessImpl(std::move(thread_pool_init_params)));
}
void RenderProcessImpl::AddBindings(int bindings) {
diff --git a/content/renderer/render_process_impl.h b/content/renderer/render_process_impl.h
index a81dcb1..f38863a 100644
--- a/content/renderer/render_process_impl.h
+++ b/content/renderer/render_process_impl.h
@@ -9,7 +9,7 @@
#include <vector>
#include "base/macros.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "content/renderer/render_process.h"
namespace content {
@@ -41,8 +41,8 @@
void ReleaseProcess() override;
private:
- RenderProcessImpl(std::unique_ptr<base::TaskScheduler::InitParams>
- task_scheduler_init_params);
+ RenderProcessImpl(
+ std::unique_ptr<base::ThreadPool::InitParams> thread_pool_init_params);
// Bitwise-ORed set of extra bindings that have been enabled anywhere in this
// process. See BindingsPolicy for details.
diff --git a/content/renderer/render_thread_impl_browsertest.cc b/content/renderer/render_thread_impl_browsertest.cc
index 7a3a0eea..5eb40c8 100644
--- a/content/renderer/render_thread_impl_browsertest.cc
+++ b/content/renderer/render_thread_impl_browsertest.cc
@@ -22,7 +22,7 @@
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/app/mojo/mojo_init.h"
diff --git a/content/test/test_blink_web_unit_test_support.cc b/content/test/test_blink_web_unit_test_support.cc
index 22a1a27..8adb44a 100644
--- a/content/test/test_blink_web_unit_test_support.cc
+++ b/content/test/test_blink_web_unit_test_support.cc
@@ -13,7 +13,7 @@
#include "base/path_service.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/null_task_runner.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -169,7 +169,7 @@
blink::scheduler::WebThreadScheduler::CreateMainThreadScheduler(
base::MessageLoop::CreateMessagePumpForType(
base::MessageLoop::TYPE_DEFAULT));
- base::TaskScheduler::CreateAndStartWithDefaultParams("BlinkTestSupport");
+ base::ThreadPool::CreateAndStartWithDefaultParams("BlinkTestSupport");
}
// Initialize mojo firstly to enable Blink initialization to use it.
diff --git a/docs/threading_and_tasks.md b/docs/threading_and_tasks.md
index 3dd0c0e..41847b7 100644
--- a/docs/threading_and_tasks.md
+++ b/docs/threading_and_tasks.md
@@ -118,7 +118,7 @@
## Posting a Parallel Task
-### Direct Posting to the Task Scheduler
+### Direct Posting to the Thread Pool
A task that can run on any thread and doesn’t have ordering or mutual exclusion
requirements with other tasks should be posted using one of the
@@ -403,7 +403,7 @@
## Annotating Tasks with TaskTraits
[`TaskTraits`](https://cs.chromium.org/chromium/src/base/task/task_traits.h)
-encapsulate information about a task that helps the task scheduler make better
+encapsulate information about a task that helps the thread pool make better
scheduling decisions.
All `PostTask*()` functions in
@@ -413,7 +413,8 @@
that:
- Don’t block (ref. MayBlock and WithBaseSyncPrimitives).
- Prefer inheriting the current priority to specifying their own.
-- Can either block shutdown or be skipped on shutdown (task scheduler is free to choose a fitting default).
+- Can either block shutdown or be skipped on shutdown (thread pool is free to
+ choose a fitting default).
Tasks that don’t match this description must be posted with explicit TaskTraits.
[`base/task/task_traits.h`](https://cs.chromium.org/chromium/src/base/task/task_traits.h)
@@ -431,7 +432,7 @@
// block shutdown or be skipped on shutdown.
base::PostTask(FROM_HERE, base::BindOnce(...));
-// This task has the highest priority. The task scheduler will try to
+// This task has the highest priority. The thread pool will try to
// run it before USER_VISIBLE and BEST_EFFORT tasks.
base::PostTaskWithTraits(
FROM_HERE, {base::TaskPriority::USER_BLOCKING},
@@ -635,14 +636,14 @@
run_loop.Run();
// D and run_loop.QuitClosure() have been executed. E is still in the queue.
- // Tasks posted to task scheduler run asynchronously as they are posted.
+ // Tasks posted to thread pool run asynchronously as they are posted.
base::PostTaskWithTraits(FROM_HERE, base::TaskTraits(), base::BindOnce(&F));
auto task_runner =
base::CreateSequencedTaskRunnerWithTraits(base::TaskTraits());
task_runner->PostTask(FROM_HERE, base::BindOnce(&G));
- // To block until all tasks posted to task scheduler are done running:
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ // To block until all tasks posted to thread pool are done running:
+ base::ThreadPool::GetInstance()->FlushForTesting();
// F and G have been executed.
base::PostTaskWithTraitsAndReplyWithResult(
@@ -657,33 +658,33 @@
}
```
-## Using TaskScheduler in a New Process
+## Using ThreadPool in a New Process
-TaskScheduler needs to be initialized in a process before the functions in
+ThreadPool needs to be initialized in a process before the functions in
[`base/task/post_task.h`](https://cs.chromium.org/chromium/src/base/task/post_task.h)
-can be used. Initialization of TaskScheduler in the Chrome browser process and
+can be used. Initialization of ThreadPool in the Chrome browser process and
child processes (renderer, GPU, utility) has already been taken care of. To use
-TaskScheduler in another process, initialize TaskScheduler early in the main
+ThreadPool in another process, initialize ThreadPool early in the main
function:
```cpp
-// This initializes and starts TaskScheduler with default params.
-base::TaskScheduler::CreateAndStartWithDefaultParams(“process_name”);
+// This initializes and starts ThreadPool with default params.
+base::ThreadPool::CreateAndStartWithDefaultParams(“process_name”);
// The base/task/post_task.h API can now be used. Tasks will be // scheduled as
// they are posted.
-// This initializes TaskScheduler.
-base::TaskScheduler::Create(“process_name”);
+// This initializes ThreadPool.
+base::ThreadPool::Create(“process_name”);
// The base/task/post_task.h API can now be used. No threads // will be created
// and no tasks will be scheduled until after Start() is called.
-base::TaskScheduler::GetInstance()->Start(params);
-// TaskScheduler can now create threads and schedule tasks.
+base::ThreadPool::GetInstance()->Start(params);
+// ThreadPool can now create threads and schedule tasks.
```
-And shutdown TaskScheduler late in the main function:
+And shutdown ThreadPool late in the main function:
```cpp
-base::TaskScheduler::GetInstance()->Shutdown();
+base::ThreadPool::GetInstance()->Shutdown();
// Tasks posted with TaskShutdownBehavior::BLOCK_SHUTDOWN and
// tasks posted with TaskShutdownBehavior::SKIP_ON_SHUTDOWN that
// have started to run before the Shutdown() call have now completed their
diff --git a/fuchsia/http/http_service_main.cc b/fuchsia/http/http_service_main.cc
index 967572a..256812c 100644
--- a/fuchsia/http/http_service_main.cc
+++ b/fuchsia/http/http_service_main.cc
@@ -9,12 +9,12 @@
#include "base/fuchsia/service_directory.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "fuchsia/http/http_service_impl.h"
int main(int argc, char** argv) {
// Instantiate various global structures.
- base::TaskScheduler::CreateAndStartWithDefaultParams("HTTP Service");
+ base::ThreadPool::CreateAndStartWithDefaultParams("HTTP Service");
base::CommandLine::Init(argc, argv);
base::MessageLoopForIO loop;
base::AtExitManager exit_manager;
diff --git a/gin/shell/gin_main.cc b/gin/shell/gin_main.cc
index 5243c46..884b902 100644
--- a/gin/shell/gin_main.cc
+++ b/gin/shell/gin_main.cc
@@ -14,7 +14,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "gin/array_buffer.h"
#include "gin/modules/console.h"
@@ -75,7 +75,7 @@
#endif
base::MessageLoop message_loop;
- base::TaskScheduler::CreateAndStartWithDefaultParams("gin");
+ base::ThreadPool::CreateAndStartWithDefaultParams("gin");
// Initialize the base::FeatureList since IsolateHolder can depend on it.
base::FeatureList::SetInstance(base::WrapUnique(new base::FeatureList));
@@ -109,10 +109,10 @@
base::RunLoop().RunUntilIdle();
}
- // gin::IsolateHolder waits for tasks running in TaskScheduler in its
- // destructor and thus must be destroyed before TaskScheduler starts skipping
+ // gin::IsolateHolder waits for tasks running in ThreadPool in its
+ // destructor and thus must be destroyed before ThreadPool starts skipping
// CONTINUE_ON_SHUTDOWN tasks.
- base::TaskScheduler::GetInstance()->Shutdown();
+ base::ThreadPool::GetInstance()->Shutdown();
return 0;
}
diff --git a/gin/v8_platform.cc b/gin/v8_platform.cc
index cdf89444..53263bf 100644
--- a/gin/v8_platform.cc
+++ b/gin/v8_platform.cc
@@ -17,8 +17,8 @@
#include "base/rand_util.h"
#include "base/system/sys_info.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
#include "base/task/task_traits.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "gin/per_isolate_data.h"
@@ -371,11 +371,11 @@
// V8Platform assumes the scheduler uses the same set of workers for default
// and user blocking tasks.
const int num_foreground_workers =
- base::TaskScheduler::GetInstance()
+ base::ThreadPool::GetInstance()
->GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
kDefaultTaskTraits);
DCHECK_EQ(num_foreground_workers,
- base::TaskScheduler::GetInstance()
+ base::ThreadPool::GetInstance()
->GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
kBlockingTaskTraits));
return std::max(1, num_foreground_workers);
diff --git a/google_apis/gcm/tools/mcs_probe.cc b/google_apis/gcm/tools/mcs_probe.cc
index 1bb01373..f1f75b1 100644
--- a/google_apis/gcm/tools/mcs_probe.cc
+++ b/google_apis/gcm/tools/mcs_probe.cc
@@ -25,7 +25,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/default_clock.h"
@@ -444,7 +444,7 @@
mojo::core::Init();
base::MessageLoopForIO message_loop;
- base::TaskScheduler::CreateAndStartWithDefaultParams("MCSProbe");
+ base::ThreadPool::CreateAndStartWithDefaultParams("MCSProbe");
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
@@ -455,7 +455,7 @@
base::RunLoop run_loop;
run_loop.Run();
- base::TaskScheduler::GetInstance()->Shutdown();
+ base::ThreadPool::GetInstance()->Shutdown();
return 0;
}
diff --git a/gpu/vulkan/demo/main.cc b/gpu/vulkan/demo/main.cc
index 6595bed2..5abc4f6 100644
--- a/gpu/vulkan/demo/main.cc
+++ b/gpu/vulkan/demo/main.cc
@@ -8,7 +8,7 @@
#include "base/command_line.h"
#include "base/debug/stack_trace.h"
#include "base/message_loop/message_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/trace_event/trace_event.h"
#include "components/tracing/common/trace_to_console.h"
#include "components/tracing/common/tracing_switches.h"
@@ -36,7 +36,7 @@
// Build UI thread message loop. This is used by platform
// implementations for event polling & running background tasks.
base::MessageLoopForUI message_loop;
- base::TaskScheduler::CreateAndStartWithDefaultParams("VulkanDemo");
+ base::ThreadPool::CreateAndStartWithDefaultParams("VulkanDemo");
gpu::VulkanDemo vulkan_demo;
vulkan_demo.Initialize();
diff --git a/ios/chrome/app/DEPS b/ios/chrome/app/DEPS
index d94d5b90..b6395fae 100644
--- a/ios/chrome/app/DEPS
+++ b/ios/chrome/app/DEPS
@@ -19,7 +19,7 @@
"+components/search_engines",
"+components/suggestions",
"+components/sync/driver",
- "+components/task_scheduler_util",
+ "+components/thread_pool_util",
"+components/ukm/ios",
"+components/unified_consent",
"+components/url_formatter",
diff --git a/ios/chrome/app/startup/BUILD.gn b/ios/chrome/app/startup/BUILD.gn
index 67cd14fc..1cc6af39 100644
--- a/ios/chrome/app/startup/BUILD.gn
+++ b/ios/chrome/app/startup/BUILD.gn
@@ -24,7 +24,7 @@
deps = [
"//base",
"//components/crash/core/common",
- "//components/task_scheduler_util",
+ "//components/thread_pool_util",
"//ios/chrome/browser:chrome_paths",
"//ios/web/public/app",
"//skia",
diff --git a/ios/chrome/app/startup/ios_chrome_main.mm b/ios/chrome/app/startup/ios_chrome_main.mm
index 2096eaf..4a1ce3b 100644
--- a/ios/chrome/app/startup/ios_chrome_main.mm
+++ b/ios/chrome/app/startup/ios_chrome_main.mm
@@ -13,7 +13,7 @@
#include "base/strings/string_piece.h"
#include "base/strings/sys_string_conversions.h"
#include "base/time/time.h"
-#include "components/task_scheduler_util/variations_util.h"
+#include "components/thread_pool_util/variations_util.h"
#include "ios/web/public/app/web_main_runner.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
@@ -46,8 +46,8 @@
}
main_params.argv = argv;
- main_params.get_task_scheduler_init_params_callback = base::BindOnce(
- &task_scheduler_util::GetTaskSchedulerInitParamsForBrowser);
+ main_params.get_thread_pool_init_params_callback =
+ base::BindOnce(&thread_pool_util::GetThreadPoolInitParamsForBrowser);
// Chrome registers an AtExitManager in main in order to initialize breakpad
// early, so prevent a second registration by WebMainRunner.
main_params.register_exit_manager = false;
diff --git a/ios/chrome/browser/DEPS b/ios/chrome/browser/DEPS
index 8fd99a3..d4cc9a6 100644
--- a/ios/chrome/browser/DEPS
+++ b/ios/chrome/browser/DEPS
@@ -85,16 +85,16 @@
"+components/suggestions",
"+components/sync",
"+components/sync_bookmarks",
- "+components/sync_sessions",
"+components/sync_preferences",
- "+components/task_scheduler_util",
+ "+components/sync_sessions",
+ "+components/thread_pool_util",
"+components/translate",
"+components/ui_metrics",
"+components/ukm",
"+components/undo",
"+components/unified_consent",
- "+components/update_client",
"+components/unified_consent",
+ "+components/update_client",
"+components/upload_list",
"+components/url_formatter",
"+components/variations",
diff --git a/ios/chrome/browser/autofill/autofill_controller_unittest.mm b/ios/chrome/browser/autofill/autofill_controller_unittest.mm
index 5dffe182..f97a7c75 100644
--- a/ios/chrome/browser/autofill/autofill_controller_unittest.mm
+++ b/ios/chrome/browser/autofill/autofill_controller_unittest.mm
@@ -12,7 +12,7 @@
#include "base/mac/foundation_util.h"
#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#import "base/test/ios/wait_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "components/autofill/core/browser/autofill_manager.h"
@@ -527,7 +527,7 @@
CreateAutofillEntry(base::ASCIIToUTF16("overwritten"))};
web_data_service->GetFormValuesForElementName(
base::UTF8ToUTF16("greeting"), base::string16(), limit, &consumer);
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
WaitForBackgroundTasks();
// No value should be returned before anything is loaded via form submission.
ASSERT_EQ(0U, consumer.result_.size());
@@ -537,7 +537,7 @@
base::UTF8ToUTF16("greeting"), base::string16(), limit, &consumer);
return consumer.result_.size();
});
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
WaitForBackgroundTasks();
// One result should be returned, matching the filled value.
ASSERT_EQ(1U, consumer.result_.size());
diff --git a/ios/chrome/browser/autofill/form_structure_browsertest.mm b/ios/chrome/browser/autofill/form_structure_browsertest.mm
index 266bde9..c0ce614 100644
--- a/ios/chrome/browser/autofill/form_structure_browsertest.mm
+++ b/ios/chrome/browser/autofill/form_structure_browsertest.mm
@@ -11,7 +11,7 @@
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#import "base/test/ios/wait_util.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/core/browser/autofill_manager.h"
@@ -172,7 +172,7 @@
void FormStructureBrowserTest::GenerateResults(const std::string& input,
std::string* output) {
ASSERT_TRUE(LoadHtmlWithoutSubresources(input));
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
web::WebFrame* frame = web::GetMainWebFrame(web_state());
AutofillManager* autofill_manager =
AutofillDriverIOS::FromWebStateAndWebFrame(web_state(), frame)
diff --git a/ios/chrome/browser/ios_chrome_main_parts.mm b/ios/chrome/browser/ios_chrome_main_parts.mm
index 6bf92d2c..1d5c33b 100644
--- a/ios/chrome/browser/ios_chrome_main_parts.mm
+++ b/ios/chrome/browser/ios_chrome_main_parts.mm
@@ -97,7 +97,7 @@
// The initial read is done synchronously, the TaskPriority is thus only used
// for flushes to disks and BACKGROUND is therefore appropriate. Priority of
- // remaining BACKGROUND+BLOCK_SHUTDOWN tasks is bumped by the TaskScheduler on
+ // remaining BACKGROUND+BLOCK_SHUTDOWN tasks is bumped by the ThreadPool on
// shutdown.
scoped_refptr<base::SequencedTaskRunner> local_state_task_runner =
base::CreateSequencedTaskRunnerWithTraits(
diff --git a/ios/chrome/browser/snapshots/snapshot_cache_unittest.mm b/ios/chrome/browser/snapshots/snapshot_cache_unittest.mm
index f23be4dc..1b524f5 100644
--- a/ios/chrome/browser/snapshots/snapshot_cache_unittest.mm
+++ b/ios/chrome/browser/snapshots/snapshot_cache_unittest.mm
@@ -13,7 +13,7 @@
#include "base/mac/scoped_cftyperef.h"
#include "base/run_loop.h"
#include "base/strings/sys_string_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/time/time.h"
#import "ios/chrome/browser/snapshots/snapshot_cache_internal.h"
#import "ios/chrome/browser/snapshots/snapshot_cache_observer.h"
@@ -105,7 +105,7 @@
// Flushes all the runloops internally used by the snapshot cache.
void FlushRunLoops() {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
base::RunLoop().RunUntilIdle();
}
diff --git a/ios/chrome/browser/sync/profile_sync_service_factory_unittest.cc b/ios/chrome/browser/sync/profile_sync_service_factory_unittest.cc
index 63fb1ae..25e811b51 100644
--- a/ios/chrome/browser/sync/profile_sync_service_factory_unittest.cc
+++ b/ios/chrome/browser/sync/profile_sync_service_factory_unittest.cc
@@ -10,7 +10,7 @@
#include "base/command_line.h"
#include "base/feature_list.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "components/browser_sync/browser_sync_switches.h"
#include "components/sync/base/model_type.h"
#include "components/sync/base/pref_names.h"
@@ -37,7 +37,7 @@
}
void TearDown() override {
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
protected:
diff --git a/ios/web/app/web_main_loop.h b/ios/web/app/web_main_loop.h
index 14ce06e..9099da6 100644
--- a/ios/web/app/web_main_loop.h
+++ b/ios/web/app/web_main_loop.h
@@ -10,7 +10,7 @@
#include "base/callback_helpers.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "ios/web/public/app/task_scheduler_init_params_callback.h"
+#include "ios/web/public/app/thread_pool_init_params_callback.h"
namespace base {
class PowerMonitor;
@@ -37,8 +37,8 @@
// Creates and starts running the tasks needed to complete startup. The
// |init_params_callback| may be null or supply InitParams to be used to start
- // the global TaskScheduler instead of using the defaults.
- void CreateStartupTasks(TaskSchedulerInitParamsCallback init_params_callback);
+ // the global ThreadPool instead of using the defaults.
+ void CreateStartupTasks(ThreadPoolInitParamsCallback init_params_callback);
// Performs the shutdown sequence, starting with PostMainMessageLoopRun
// through stopping threads to PostDestroyThreads.
@@ -53,9 +53,9 @@
int PreCreateThreads();
// Creates all secondary threads. The |init_params_callback| may be null or
- // supply InitParams to be used to start the global TaskScheduler instead of
+ // supply InitParams to be used to start the global ThreadPool instead of
// using the defaults.
- int CreateThreads(TaskSchedulerInitParamsCallback init_params_callback);
+ int CreateThreads(ThreadPoolInitParamsCallback init_params_callback);
// Called right after the web threads have been started.
int WebThreadsStarted();
diff --git a/ios/web/app/web_main_loop.mm b/ios/web/app/web_main_loop.mm
index 89eb975..fb63d6b8 100644
--- a/ios/web/app/web_main_loop.mm
+++ b/ios/web/app/web_main_loop.mm
@@ -18,8 +18,8 @@
#include "base/power_monitor/power_monitor_device_source.h"
#include "base/process/process_metrics.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/scheduler_worker_pool_params.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/scheduler_worker_pool_params.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_restrictions.h"
#import "ios/web/net/cookie_notification_bridge.h"
#include "ios/web/public/app/web_main_parts.h"
@@ -92,7 +92,7 @@
}
void WebMainLoop::CreateStartupTasks(
- TaskSchedulerInitParamsCallback init_params_callback) {
+ ThreadPoolInitParamsCallback init_params_callback) {
int result = 0;
result = PreCreateThreads();
if (result > 0)
@@ -120,12 +120,12 @@
}
int WebMainLoop::CreateThreads(
- TaskSchedulerInitParamsCallback init_params_callback) {
- std::unique_ptr<base::TaskScheduler::InitParams> init_params;
+ ThreadPoolInitParamsCallback init_params_callback) {
+ std::unique_ptr<base::ThreadPool::InitParams> init_params;
if (!init_params_callback.is_null()) {
init_params = std::move(init_params_callback).Run();
}
- ios_global_state::StartTaskScheduler(init_params.get());
+ ios_global_state::StartThreadPool(init_params.get());
base::Thread::Options io_message_loop_options;
io_message_loop_options.message_loop_type = base::MessageLoop::TYPE_IO;
@@ -170,7 +170,7 @@
// Also allow waiting to join threads.
// TODO(crbug.com/800808): Ideally this (and the above SetIOAllowed()
// would be scoped allowances). That would be one of the first step to ensure
- // no persistent work is being done after TaskScheduler::Shutdown() in order
+ // no persistent work is being done after ThreadPool::Shutdown() in order
// to move towards atomic shutdown.
base::ThreadRestrictions::SetWaitAllowed(true);
base::PostTaskWithTraits(
@@ -190,13 +190,13 @@
// is the main thread).
static_assert(WebThread::ID_COUNT == 2, "Unhandled WebThread");
- // Shutdown TaskScheduler after the other threads. Other threads such as the
+ // Shutdown ThreadPool after the other threads. Other threads such as the
// I/O thread may need to schedule work like closing files or flushing data
- // during shutdown, so TaskScheduler needs to be available. There may also be
+ // during shutdown, so ThreadPool needs to be available. There may also be
// slow operations pending that will block shutdown, so closing it here (which
// will block until required operations are complete) gives more head start
// for those operations to finish.
- base::TaskScheduler::GetInstance()->Shutdown();
+ base::ThreadPool::GetInstance()->Shutdown();
URLDataManagerIOS::DeleteDataSources();
diff --git a/ios/web/app/web_main_runner.mm b/ios/web/app/web_main_runner.mm
index fdd4f557..0a0efa7f 100644
--- a/ios/web/app/web_main_runner.mm
+++ b/ios/web/app/web_main_runner.mm
@@ -74,7 +74,7 @@
main_loop_->EarlyInitialization();
main_loop_->MainMessageLoopStart();
main_loop_->CreateStartupTasks(
- std::move(params.get_task_scheduler_init_params_callback));
+ std::move(params.get_thread_pool_init_params_callback));
int result_code = main_loop_->GetResultCode();
if (result_code > 0)
return result_code;
diff --git a/ios/web/public/app/BUILD.gn b/ios/web/public/app/BUILD.gn
index 059e3f6..ea886b3 100644
--- a/ios/web/public/app/BUILD.gn
+++ b/ios/web/public/app/BUILD.gn
@@ -4,7 +4,7 @@
source_set("app") {
sources = [
- "task_scheduler_init_params_callback.h",
+ "thread_pool_init_params_callback.h",
"web_main.h",
"web_main_delegate.h",
"web_main_parts.h",
diff --git a/ios/web/public/app/task_scheduler_init_params_callback.h b/ios/web/public/app/task_scheduler_init_params_callback.h
deleted file mode 100644
index 237a9de..0000000
--- a/ios/web/public/app/task_scheduler_init_params_callback.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef IOS_WEB_PUBLIC_GLOBAL_STATE_TASK_SCHEDULER_INIT_PARAMS_CALLBACK_H_
-#define IOS_WEB_PUBLIC_GLOBAL_STATE_TASK_SCHEDULER_INIT_PARAMS_CALLBACK_H_
-
-#include "base/callback_forward.h"
-#include "base/task/task_scheduler/task_scheduler.h"
-
-namespace web {
-
-// Callback which returns a pointer to InitParams for base::TaskScheduler.
-typedef base::OnceCallback<std::unique_ptr<base::TaskScheduler::InitParams>()>
- TaskSchedulerInitParamsCallback;
-
-} // namespace web
-
-#endif // IOS_WEB_PUBLIC_GLOBAL_STATE_TASK_SCHEDULER_INIT_PARAMS_CALLBACK_H_
diff --git a/ios/web/public/app/thread_pool_init_params_callback.h b/ios/web/public/app/thread_pool_init_params_callback.h
new file mode 100644
index 0000000..5657bc2a
--- /dev/null
+++ b/ios/web/public/app/thread_pool_init_params_callback.h
@@ -0,0 +1,19 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_WEB_PUBLIC_APP_THREAD_POOL_INIT_PARAMS_CALLBACK_H_
+#define IOS_WEB_PUBLIC_APP_THREAD_POOL_INIT_PARAMS_CALLBACK_H_
+
+#include "base/callback_forward.h"
+#include "base/task/thread_pool/thread_pool.h"
+
+namespace web {
+
+// Callback which returns a pointer to InitParams for base::ThreadPool.
+typedef base::OnceCallback<std::unique_ptr<base::ThreadPool::InitParams>()>
+ ThreadPoolInitParamsCallback;
+
+} // namespace web
+
+#endif // IOS_WEB_PUBLIC_APP_THREAD_POOL_INIT_PARAMS_CALLBACK_H_
diff --git a/ios/web/public/app/web_main.h b/ios/web/public/app/web_main.h
index 2b5db8b9..4d1acb00 100644
--- a/ios/web/public/app/web_main.h
+++ b/ios/web/public/app/web_main.h
@@ -8,7 +8,7 @@
#include <memory>
#include "base/macros.h"
-#include "ios/web/public/app/task_scheduler_init_params_callback.h"
+#include "ios/web/public/app/thread_pool_init_params_callback.h"
#include "ios/web/public/app/web_main_delegate.h"
namespace web {
@@ -27,7 +27,7 @@
WebMainDelegate* delegate;
bool register_exit_manager;
- TaskSchedulerInitParamsCallback get_task_scheduler_init_params_callback;
+ ThreadPoolInitParamsCallback get_thread_pool_init_params_callback;
int argc;
const char** argv;
diff --git a/ios/web/public/global_state/ios_global_state.h b/ios/web/public/global_state/ios_global_state.h
index 71d06cc..d7b1f45 100644
--- a/ios/web/public/global_state/ios_global_state.h
+++ b/ios/web/public/global_state/ios_global_state.h
@@ -5,7 +5,7 @@
#ifndef IOS_WEB_PUBLIC_GLOBAL_STATE_IOS_GLOBAL_STATE_H_
#define IOS_WEB_PUBLIC_GLOBAL_STATE_IOS_GLOBAL_STATE_H_
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
namespace base {
class MessageLoop;
@@ -54,11 +54,11 @@
// It is safe to call this method multiple time.
void DestroyNetworkChangeNotifier();
-// Starts a global base::TaskScheduler. This method must be called to start
+// Starts a global base::ThreadPool. This method must be called to start
// the Task Scheduler that is created in |Create|. If |init_params| is null,
// default InitParams will be used. It is safe to call this method more than
-// once, the task scheduler will only be started once.
-void StartTaskScheduler(base::TaskScheduler::InitParams* init_params);
+// once, the thread pool will only be started once.
+void StartThreadPool(base::ThreadPool::InitParams* init_params);
// Destroys the AtExitManager if one was created in |Create|. It is safe to call
// this method even if |install_at_exit_manager| was false in the CreateParams
diff --git a/ios/web/public/global_state/ios_global_state.mm b/ios/web/public/global_state/ios_global_state.mm
index 2228c72..13fcb44d15 100644
--- a/ios/web/public/global_state/ios_global_state.mm
+++ b/ios/web/public/global_state/ios_global_state.mm
@@ -9,7 +9,7 @@
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
-#include "base/task/task_scheduler/initialization_util.h"
+#include "base/task/thread_pool/initialization_util.h"
#include "net/base/network_change_notifier.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
@@ -22,7 +22,7 @@
base::MessageLoopForUI* g_message_loop = nullptr;
net::NetworkChangeNotifier* g_network_change_notifer = nullptr;
-base::TaskScheduler::InitParams GetDefaultTaskSchedulerInitParams() {
+base::ThreadPool::InitParams GetDefaultThreadPoolInitParams() {
constexpr int kMinBackgroundThreads = 4;
constexpr int kMaxBackgroundThreads = 16;
constexpr double kCoreMultiplierBackgroundThreads = 0.2;
@@ -35,7 +35,7 @@
constexpr int kOffsetForegroundThreads = 0;
constexpr int kReclaimTimeForeground = 30;
- return base::TaskScheduler::InitParams(
+ return base::ThreadPool::InitParams(
base::SchedulerWorkerPoolParams(
base::RecommendedMaxNumberOfThreadsInPool(
kMinBackgroundThreads, kMaxBackgroundThreads,
@@ -60,7 +60,7 @@
}
base::CommandLine::Init(create_params.argc, create_params.argv);
- base::TaskScheduler::Create("Browser");
+ base::ThreadPool::Create("Browser");
});
}
@@ -93,11 +93,11 @@
g_network_change_notifer = nullptr;
}
-void StartTaskScheduler(base::TaskScheduler::InitParams* params) {
+void StartThreadPool(base::ThreadPool::InitParams* params) {
static dispatch_once_t once_token;
dispatch_once(&once_token, ^{
- auto init_params = params ? *params : GetDefaultTaskSchedulerInitParams();
- base::TaskScheduler::GetInstance()->Start(init_params);
+ auto init_params = params ? *params : GetDefaultThreadPoolInitParams();
+ base::ThreadPool::GetInstance()->Start(init_params);
});
}
diff --git a/ios/web/public/test/test_web_thread_bundle.h b/ios/web/public/test/test_web_thread_bundle.h
index cc69d3ad..1dc8ab7 100644
--- a/ios/web/public/test/test_web_thread_bundle.h
+++ b/ios/web/public/test/test_web_thread_bundle.h
@@ -8,7 +8,7 @@
#include "base/test/scoped_task_environment.h"
// TestWebThreadBundle is a convenience class for creating a set of
-// TestWebThreads and a task scheduler in unit tests. For most tests, it is
+// TestWebThreads and a thread pool in unit tests. For most tests, it is
// sufficient to just instantiate the TestWebThreadBundle as a member variable.
// It is a good idea to put the TestWebThreadBundle as the first member variable
// in test classes, so it is destroyed last, and the test threads always exist
@@ -22,7 +22,7 @@
// To synchronously run tasks posted to TestWebThreads that use the shared
// MessageLoop, call RunLoop::Run/RunUntilIdle() on the thread where the
// TestWebThreadBundle lives. The destructor of TestWebThreadBundle runs
-// remaining TestWebThreads tasks and remaining BLOCK_SHUTDOWN task scheduler
+// remaining TestWebThreads tasks and remaining BLOCK_SHUTDOWN thread pool
// tasks.
//
// Some tests using the IO thread expect a MessageLoopForIO. Passing
diff --git a/ios/web/public/web_client.h b/ios/web/public/web_client.h
index a78f934..e2bb787 100644
--- a/ios/web/public/web_client.h
+++ b/ios/web/public/web_client.h
@@ -14,7 +14,7 @@
#include "base/optional.h"
#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/values.h"
#include "ios/web/public/user_agent.h"
#include "mojo/public/cpp/system/message_pipe.h"
diff --git a/ios/web/public/web_thread.h b/ios/web/public/web_thread.h
index 811520d..cb056049 100644
--- a/ios/web/public/web_thread.h
+++ b/ios/web/public/web_thread.h
@@ -53,11 +53,11 @@
UI,
// This is the thread that processes non-blocking IO, i.e. IPC and network.
- // Blocking IO should happen in TaskScheduler.
+ // Blocking IO should happen in ThreadPool.
IO,
// NOTE: do not add new threads here. Instead you should just use
- // base::Create*TaskRunnerWithTraits to run tasks on the TaskScheduler.
+ // base::Create*TaskRunnerWithTraits to run tasks on the ThreadPool.
// This identifier does not represent a thread. Instead it counts the
// number of well-known threads. Insert new well-known threads before this
diff --git a/ios/web/test/test_web_thread_bundle.cc b/ios/web/test/test_web_thread_bundle.cc
index 06413e72e..ea75c8d 100644
--- a/ios/web/test/test_web_thread_bundle.cc
+++ b/ios/web/test/test_web_thread_bundle.cc
@@ -29,7 +29,7 @@
ui_thread_->Stop();
base::RunLoop().RunUntilIdle();
- // This is required to ensure that all remaining MessageLoop and TaskScheduler
+ // This is required to ensure that all remaining MessageLoop and ThreadPool
// tasks run in an atomic step. This is a bit different than production where
// the main thread is not flushed after it's done running but this approach is
// preferred in unit tests as running more tasks can merely uncover more
diff --git a/media/filters/ffmpeg_demuxer.h b/media/filters/ffmpeg_demuxer.h
index 0ffabab..e67c3c4 100644
--- a/media/filters/ffmpeg_demuxer.h
+++ b/media/filters/ffmpeg_demuxer.h
@@ -341,7 +341,7 @@
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
// Task runner on which all blocking FFmpeg operations are executed; retrieved
- // from base::TaskScheduler.
+ // from base::ThreadPool.
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
PipelineStatusCB init_cb_;
@@ -416,4 +416,4 @@
} // namespace media
-#endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_
\ No newline at end of file
+#endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_
diff --git a/mojo/public/tools/fuzzers/mojo_fuzzer_message_dump.cc b/mojo/public/tools/fuzzers/mojo_fuzzer_message_dump.cc
index 3cc657cf..f5c68e04 100644
--- a/mojo/public/tools/fuzzers/mojo_fuzzer_message_dump.cc
+++ b/mojo/public/tools/fuzzers/mojo_fuzzer_message_dump.cc
@@ -11,17 +11,17 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/public/tools/fuzzers/fuzz.mojom.h"
#include "mojo/public/tools/fuzzers/fuzz_impl.h"
/* Environment for the executable. Initializes the mojo EDK and sets up a
- * TaskScheduler, because Mojo messages must be sent and processed from
+ * ThreadPool, because Mojo messages must be sent and processed from
* TaskRunners. */
struct Environment {
Environment() : message_loop() {
- base::TaskScheduler::CreateAndStartWithDefaultParams(
+ base::ThreadPool::CreateAndStartWithDefaultParams(
"MojoFuzzerMessageDumpProcess");
mojo::core::Init();
}
diff --git a/mojo/public/tools/fuzzers/mojo_parse_message_fuzzer.cc b/mojo/public/tools/fuzzers/mojo_parse_message_fuzzer.cc
index 28ff521..27285a5 100644
--- a/mojo/public/tools/fuzzers/mojo_parse_message_fuzzer.cc
+++ b/mojo/public/tools/fuzzers/mojo_parse_message_fuzzer.cc
@@ -5,7 +5,7 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/tools/fuzzers/fuzz_impl.h"
@@ -33,11 +33,11 @@
}
/* Environment for the fuzzer. Initializes the mojo EDK and sets up a
- * TaskScheduler, because Mojo messages must be sent and processed from
+ * ThreadPool, because Mojo messages must be sent and processed from
* TaskRunners. */
struct Environment {
Environment() : message_loop(base::MessageLoop::TYPE_UI) {
- base::TaskScheduler::CreateAndStartWithDefaultParams(
+ base::ThreadPool::CreateAndStartWithDefaultParams(
"MojoParseMessageFuzzerProcess");
mojo::core::Init();
}
diff --git a/mojo/public/tools/fuzzers/mojo_parse_message_proto_fuzzer.cc b/mojo/public/tools/fuzzers/mojo_parse_message_proto_fuzzer.cc
index d6b5e96..e4688bb 100644
--- a/mojo/public/tools/fuzzers/mojo_parse_message_proto_fuzzer.cc
+++ b/mojo/public/tools/fuzzers/mojo_parse_message_proto_fuzzer.cc
@@ -8,7 +8,7 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/tools/fuzzers/fuzz_impl.h"
@@ -44,11 +44,11 @@
}
// Environment for the fuzzer. Initializes the mojo EDK and sets up a
-// TaskScheduler, because Mojo messages must be sent and processed from
+// ThreadPool, because Mojo messages must be sent and processed from
// TaskRunners.
struct Environment {
Environment() : message_loop(base::MessageLoop::TYPE_UI) {
- base::TaskScheduler::CreateAndStartWithDefaultParams(
+ base::ThreadPool::CreateAndStartWithDefaultParams(
"MojoParseMessageFuzzerProcess");
mojo::core::Init();
}
diff --git a/net/base/upload_file_element_reader.h b/net/base/upload_file_element_reader.h
index 6c9f553..190bbc4 100644
--- a/net/base/upload_file_element_reader.h
+++ b/net/base/upload_file_element_reader.h
@@ -37,7 +37,7 @@
// only used as the return value for path().
// |task_runner| is used to perform file operations. It must not be NULL.
//
- // TODO(mmenke): Remove |task_runner| argument, and use the TaskScheduler
+ // TODO(mmenke): Remove |task_runner| argument, and use the ThreadPool
// instead.
UploadFileElementReader(base::TaskRunner* task_runner,
base::File file,
diff --git a/net/cert/multi_threaded_cert_verifier.cc b/net/cert/multi_threaded_cert_verifier.cc
index a58f89e3..e63bcdd 100644
--- a/net/cert/multi_threaded_cert_verifier.cc
+++ b/net/cert/multi_threaded_cert_verifier.cc
@@ -60,7 +60,7 @@
// fundamentally doing the same verification. CertVerifierJob is similarly
// thread-unsafe and lives on the origin thread.
//
-// To do the actual work, CertVerifierJob posts a task to TaskScheduler
+// To do the actual work, CertVerifierJob posts a task to ThreadPool
// (PostTaskAndReply), and on completion notifies all requests attached to it.
//
// Cancellation:
@@ -235,7 +235,7 @@
const CertVerifier::RequestParams& key() const { return key_; }
- // Posts a task to TaskScheduler to do the verification. Once the verification
+ // Posts a task to ThreadPool to do the verification. Once the verification
// has completed, it will call OnJobCompleted() on the origin thread.
void Start(const scoped_refptr<CertVerifyProc>& verify_proc,
const CertVerifier::Config& config,
diff --git a/net/disk_cache/blockfile/file_posix.cc b/net/disk_cache/blockfile/file_posix.cc
index 3272bca..08793e8 100644
--- a/net/disk_cache/blockfile/file_posix.cc
+++ b/net/disk_cache/blockfile/file_posix.cc
@@ -13,7 +13,7 @@
#include "base/logging.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "net/base/net_errors.h"
#include "net/disk_cache/disk_cache.h"
@@ -136,7 +136,7 @@
// We are running unit tests so we should wait for all callbacks.
// This waits for callbacks running on worker threads.
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
// This waits for the "Reply" tasks running on the current MessageLoop.
base::RunLoop().RunUntilIdle();
}
diff --git a/net/disk_cache/disk_cache.cc b/net/disk_cache/disk_cache.cc
index b9fe811..0bd05b59 100644
--- a/net/disk_cache/disk_cache.cc
+++ b/net/disk_cache/disk_cache.cc
@@ -9,7 +9,7 @@
#include "base/macros.h"
#include "base/metrics/field_trial.h"
#include "base/single_thread_task_runner.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
#include "net/base/cache_type.h"
#include "net/base/net_errors.h"
@@ -305,7 +305,7 @@
void FlushCacheThreadForTesting() {
// For simple backend.
SimpleBackendImpl::FlushWorkerPoolForTesting();
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
// Block backend.
BackendImpl::FlushForTesting();
diff --git a/net/disk_cache/simple/simple_backend_impl.cc b/net/disk_cache/simple/simple_backend_impl.cc
index 231728b..468fb1a9 100644
--- a/net/disk_cache/simple/simple_backend_impl.cc
+++ b/net/disk_cache/simple/simple_backend_impl.cc
@@ -26,7 +26,7 @@
#include "base/single_thread_task_runner.h"
#include "base/system/sys_info.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/task_runner_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
@@ -964,7 +964,7 @@
// static
void SimpleBackendImpl::FlushWorkerPoolForTesting() {
// TODO(morlovich): Remove this, move everything over to disk_cache:: use.
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
uint32_t SimpleBackendImpl::GetNewEntryPriority(
diff --git a/net/dns/address_sorter_win.cc b/net/dns/address_sorter_win.cc
index 18f0abf..6067754 100644
--- a/net/dns/address_sorter_win.cc
+++ b/net/dns/address_sorter_win.cc
@@ -88,7 +88,7 @@
~Job() {}
- // Executed asynchronously in TaskScheduler.
+ // Executed asynchronously in ThreadPool.
void Run() {
SOCKET sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
if (sock == INVALID_SOCKET)
diff --git a/net/dns/dns_config_service_win.cc b/net/dns/dns_config_service_win.cc
index 12bbb2ee..ebb5044 100644
--- a/net/dns/dns_config_service_win.cc
+++ b/net/dns/dns_config_service_win.cc
@@ -639,7 +639,7 @@
DISALLOW_COPY_AND_ASSIGN(Watcher);
};
-// Reads config from registry and IpHelper. All work performed in TaskScheduler.
+// Reads config from registry and IpHelper. All work performed in ThreadPool.
class DnsConfigServiceWin::ConfigReader : public SerialWorker {
public:
explicit ConfigReader(DnsConfigServiceWin* service)
@@ -684,7 +684,7 @@
};
// Reads hosts from HOSTS file and fills in localhost and local computer name if
-// necessary. All work performed in TaskScheduler.
+// necessary. All work performed in ThreadPool.
class DnsConfigServiceWin::HostsReader : public SerialWorker {
public:
explicit HostsReader(DnsConfigServiceWin* service)
diff --git a/net/dns/host_resolver_manager.cc b/net/dns/host_resolver_manager.cc
index fbbaa025..1918587 100644
--- a/net/dns/host_resolver_manager.cc
+++ b/net/dns/host_resolver_manager.cc
@@ -676,7 +676,7 @@
//------------------------------------------------------------------------------
-// Calls HostResolverProc in TaskScheduler. Performs retries if necessary.
+// Calls HostResolverProc in ThreadPool. Performs retries if necessary.
//
// In non-test code, the HostResolverProc is always SystemHostResolverProc,
// which calls a platform API that implements host resolution.
@@ -780,7 +780,7 @@
}
}
- // WARNING: This code runs in TaskScheduler with CONTINUE_ON_SHUTDOWN. The
+ // WARNING: This code runs in ThreadPool with CONTINUE_ON_SHUTDOWN. The
// shutdown code cannot wait for it to finish, so this code must be very
// careful about using other objects (like MessageLoops, Singletons, etc).
// During shutdown these objects may no longer exist.
@@ -1708,7 +1708,7 @@
// TODO(szym): Since DnsTransaction does not consume threads, we can increase
// the limits on |dispatcher_|. But in order to keep the number of
- // TaskScheduler threads low, we will need to use an "inner"
+ // ThreadPool threads low, we will need to use an "inner"
// PrioritizedDispatcher with tighter limits.
void StartProcTask() {
DCHECK(!is_running());
diff --git a/net/dns/host_resolver_manager.h b/net/dns/host_resolver_manager.h
index e87c15f5..fc6d3747 100644
--- a/net/dns/host_resolver_manager.h
+++ b/net/dns/host_resolver_manager.h
@@ -96,7 +96,7 @@
};
// Creates a HostResolver as specified by |options|. Blocking tasks are run in
- // TaskScheduler.
+ // ThreadPool.
//
// If Options.enable_caching is true, a cache is created using
// HostCache::CreateDefaultCache(). Otherwise no cache is used.
@@ -417,7 +417,7 @@
bool allow_fallback_to_proctask_;
// Task runner used for DNS lookups using the system resolver. Normally a
- // TaskScheduler task runner, but can be overridden for tests.
+ // ThreadPool task runner, but can be overridden for tests.
scoped_refptr<base::TaskRunner> proc_task_runner_;
// Current resolver mode, useful for breaking down histogram data.
diff --git a/net/dns/serial_worker.h b/net/dns/serial_worker.h
index 01b0058..b647b69 100644
--- a/net/dns/serial_worker.h
+++ b/net/dns/serial_worker.h
@@ -17,8 +17,8 @@
namespace net {
-// SerialWorker executes a job on TaskScheduler serially -- **once at a time**.
-// On |WorkNow|, a call to |DoWork| is scheduled on TaskScheduler. Once it
+// SerialWorker executes a job on ThreadPool serially -- **once at a time**.
+// On |WorkNow|, a call to |DoWork| is scheduled on ThreadPool. Once it
// completes, |OnWorkFinished| is called on the origin thread. If |WorkNow| is
// called (1 or more times) while |DoWork| is already under way, |DoWork| will
// be called once: after current |DoWork| completes, before a call to
@@ -38,7 +38,7 @@
public:
SerialWorker();
- // Unless already scheduled, post |DoWork| to TaskScheduler.
+ // Unless already scheduled, post |DoWork| to ThreadPool.
// Made virtual to allow mocking.
virtual void WorkNow();
@@ -53,7 +53,7 @@
// protected to allow sub-classing, but prevent deleting
virtual ~SerialWorker();
- // Executed on TaskScheduler, at most once at a time.
+ // Executed on ThreadPool, at most once at a time.
virtual void DoWork() = 0;
// Executed on origin thread after |DoRead| completes.
@@ -67,7 +67,7 @@
enum State {
CANCELLED = -1,
IDLE = 0,
- WORKING, // |DoWorkJob| posted to TaskScheduler, until |OnWorkJobFinished|
+ WORKING, // |DoWorkJob| posted to ThreadPool, until |OnWorkJobFinished|
PENDING, // |WorkNow| while WORKING, must re-do work
};
diff --git a/net/dns/serial_worker_unittest.cc b/net/dns/serial_worker_unittest.cc
index a9562f9c..b2a8512 100644
--- a/net/dns/serial_worker_unittest.cc
+++ b/net/dns/serial_worker_unittest.cc
@@ -53,7 +53,7 @@
scoped_allow_base_sync_primitives;
work_allowed_.Wait();
}
- // Calling from TaskScheduler, but protected by work_allowed_/work_called_.
+ // Calling from ThreadPool, but protected by work_allowed_/work_called_.
output_value_ = input_value_;
{ // This lock might be destroyed after work_called_ is signalled.
diff --git a/net/docs/host-resolver.md b/net/docs/host-resolver.md
index 1169f0e..a151c63 100644
--- a/net/docs/host-resolver.md
+++ b/net/docs/host-resolver.md
@@ -38,7 +38,7 @@
### Task
The entry point for the system resolver is HostResolverImpl::ProcTask. The task
-runs almost entirely on TaskScheduler. Its main implementation is in
+runs almost entirely on ThreadPool. Its main implementation is in
SystemHostResolverProc. Other implementations of HostResolverProc can be swapped
in for testing.
@@ -50,7 +50,7 @@
### Attempt
Attempts in the system resolver are not a separate class. They're implemented as
-separate tasks posted to TaskScheduler.
+separate tasks posted to ThreadPool.
Data collected at this layer:
* "DNS.AttemptFirstSuccess"
diff --git a/net/extras/sqlite/sqlite_persistent_cookie_store_perftest.cc b/net/extras/sqlite/sqlite_persistent_cookie_store_perftest.cc
index 14074cf..91d3b0e 100644
--- a/net/extras/sqlite/sqlite_persistent_cookie_store_perftest.cc
+++ b/net/extras/sqlite/sqlite_persistent_cookie_store_perftest.cc
@@ -101,7 +101,7 @@
// to write its data to disk.
store_ = nullptr;
- // Flush TaskScheduler tasks, causing pending commits to run.
+ // Flush ThreadPool tasks, causing pending commits to run.
scoped_task_environment_.RunUntilIdle();
store_ = new SQLitePersistentCookieStore(
diff --git a/net/log/file_net_log_observer_unittest.cc b/net/log/file_net_log_observer_unittest.cc
index 19de9bd..399143d 100644
--- a/net/log/file_net_log_observer_unittest.cc
+++ b/net/log/file_net_log_observer_unittest.cc
@@ -17,7 +17,7 @@
#include "base/json/json_writer.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread.h"
#include "base/values.h"
#include "net/base/test_completion_callback.h"
@@ -280,7 +280,7 @@
// The log files are written by a sequenced task runner. Drain all the
// scheduled tasks to ensure that the file writing ones have run before
// checking if they exist.
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
return base::PathExists(log_path_);
}
@@ -378,7 +378,7 @@
ASSERT_TRUE(LogFileExists());
// Should also have the scratch dir, if bounded. (Can be checked since
- // LogFileExists flushed the task scheduler).
+ // LogFileExists flushed the thread pool).
if (IsBounded()) {
ASSERT_TRUE(base::PathExists(scratch_dir_.GetPath()));
}
@@ -923,7 +923,7 @@
scratch_dir.GetPath(), std::move(file), kLargeFileSize, nullptr);
logger_->StartObserving(&net_log_, NetLogCaptureMode::Default());
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
EXPECT_TRUE(base::PathExists(log_path_));
EXPECT_TRUE(
base::PathExists(scratch_dir.GetPath().AppendASCII("constants.json")));
diff --git a/net/proxy_resolution/multi_threaded_proxy_resolver.cc b/net/proxy_resolution/multi_threaded_proxy_resolver.cc
index a73dba3..479c9c53 100644
--- a/net/proxy_resolution/multi_threaded_proxy_resolver.cc
+++ b/net/proxy_resolution/multi_threaded_proxy_resolver.cc
@@ -376,7 +376,7 @@
DCHECK(coordinator_);
{
- // TODO(http://crbug.com/69710): Use TaskScheduler instead of creating a
+ // TODO(http://crbug.com/69710): Use ThreadPool instead of creating a
// base::Thread.
MultiThreadedProxyResolverScopedAllowJoinOnIO allow_thread_join;
diff --git a/net/proxy_resolution/proxy_config_service_linux_unittest.cc b/net/proxy_resolution/proxy_config_service_linux_unittest.cc
index 160c579..513e5d8 100644
--- a/net/proxy_resolution/proxy_config_service_linux_unittest.cc
+++ b/net/proxy_resolution/proxy_config_service_linux_unittest.cc
@@ -23,7 +23,7 @@
#include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "net/proxy_resolution/proxy_config.h"
@@ -1885,7 +1885,7 @@
// Initialization posts a task to start watching kioslaverc file. Ensure that
// registration has happened before modifying it or the file change won't be
// observed.
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
WriteFile(kioslaverc_,
"[Proxy Settings]\nProxyType=2\n"
diff --git a/net/quic/platform/impl/quic_system_event_loop_impl.h b/net/quic/platform/impl/quic_system_event_loop_impl.h
index 8732852a..b3afcca 100644
--- a/net/quic/platform/impl/quic_system_event_loop_impl.h
+++ b/net/quic/platform/impl/quic_system_event_loop_impl.h
@@ -7,7 +7,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
inline void QuicRunSystemEventLoopIterationImpl() {
base::RunLoop().RunUntilIdle();
@@ -16,7 +16,7 @@
class QuicSystemEventLoopImpl {
public:
QuicSystemEventLoopImpl(std::string context_name) {
- base::TaskScheduler::CreateAndStartWithDefaultParams(context_name);
+ base::ThreadPool::CreateAndStartWithDefaultParams(context_name);
}
private:
diff --git a/net/test/url_request/url_request_mock_http_job.h b/net/test/url_request/url_request_mock_http_job.h
index a8515f9..e0c4ce8 100644
--- a/net/test/url_request/url_request_mock_http_job.h
+++ b/net/test/url_request/url_request_mock_http_job.h
@@ -28,7 +28,7 @@
class URLRequestMockHTTPJob : public URLRequestFileJob {
public:
- // Note that all file I/O is done using TaskScheduler.
+ // Note that all file I/O is done using ThreadPool.
URLRequestMockHTTPJob(URLRequest* request,
NetworkDelegate* network_delegate,
const base::FilePath& file_path);
diff --git a/net/tools/cachetool/cachetool.cc b/net/tools/cachetool/cachetool.cc
index 7200838..d8b4e9a 100644
--- a/net/tools/cachetool/cachetool.cc
+++ b/net/tools/cachetool/cachetool.cc
@@ -18,7 +18,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "net/base/io_buffer.h"
#include "net/base/test_completion_callback.h"
#include "net/disk_cache/disk_cache.h"
@@ -678,7 +678,7 @@
return 1;
}
- base::TaskScheduler::CreateAndStartWithDefaultParams("cachetool");
+ base::ThreadPool::CreateAndStartWithDefaultParams("cachetool");
base::FilePath cache_path(args[0]);
std::string cache_backend_type(args[1]);
diff --git a/net/tools/cert_verify_tool/cert_verify_tool.cc b/net/tools/cert_verify_tool/cert_verify_tool.cc
index 57c200c..99fadb9 100644
--- a/net/tools/cert_verify_tool/cert_verify_tool.cc
+++ b/net/tools/cert_verify_tool/cert_verify_tool.cc
@@ -12,7 +12,7 @@
#include "base/message_loop/message_loop.h"
#include "base/strings/string_split.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "build/build_config.h"
@@ -253,9 +253,9 @@
std::cerr << "ERROR in CommandLine::Init\n";
return 1;
}
- base::TaskScheduler::CreateAndStartWithDefaultParams("cert_verify_tool");
+ base::ThreadPool::CreateAndStartWithDefaultParams("cert_verify_tool");
base::ScopedClosureRunner cleanup(
- base::BindOnce([] { base::TaskScheduler::GetInstance()->Shutdown(); }));
+ base::BindOnce([] { base::ThreadPool::GetInstance()->Shutdown(); }));
base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
diff --git a/net/tools/disk_cache_memory_test/disk_cache_memory_test.cc b/net/tools/disk_cache_memory_test/disk_cache_memory_test.cc
index a27d939..9b91b6a3 100644
--- a/net/tools/disk_cache_memory_test/disk_cache_memory_test.cc
+++ b/net/tools/disk_cache_memory_test/disk_cache_memory_test.cc
@@ -22,7 +22,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "net/base/cache_type.h"
#include "net/base/net_errors.h"
@@ -263,8 +263,7 @@
bool Main(int argc, char** argv) {
base::AtExitManager at_exit_manager;
base::MessageLoopForIO message_loop;
- base::TaskScheduler::CreateAndStartWithDefaultParams(
- "disk_cache_memory_test");
+ base::ThreadPool::CreateAndStartWithDefaultParams("disk_cache_memory_test");
base::CommandLine::Init(argc, argv);
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
diff --git a/net/tools/net_watcher/net_watcher.cc b/net/tools/net_watcher/net_watcher.cc
index 18f28071..3a9c9c7 100644
--- a/net/tools/net_watcher/net_watcher.cc
+++ b/net/tools/net_watcher/net_watcher.cc
@@ -23,7 +23,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/string_split.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/values.h"
#include "build/build_config.h"
#include "net/base/network_change_notifier.h"
@@ -156,7 +156,7 @@
// Just make the main message loop the network loop.
base::MessageLoopForIO network_loop;
- base::TaskScheduler::CreateAndStartWithDefaultParams("NetWatcher");
+ base::ThreadPool::CreateAndStartWithDefaultParams("NetWatcher");
NetWatcher net_watcher;
diff --git a/net/tools/quic/quic_simple_client_bin.cc b/net/tools/quic/quic_simple_client_bin.cc
index 53f4fa6..2f41975 100644
--- a/net/tools/quic/quic_simple_client_bin.cc
+++ b/net/tools/quic/quic_simple_client_bin.cc
@@ -44,7 +44,7 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "net/base/net_errors.h"
#include "net/base/privacy_mode.h"
#include "net/cert/cert_verifier.h"
@@ -142,7 +142,7 @@
base::CommandLine::Init(argc, argv);
base::CommandLine* line = base::CommandLine::ForCurrentProcess();
const base::CommandLine::StringVector& urls = line->GetArgs();
- base::TaskScheduler::CreateAndStartWithDefaultParams("quic_client");
+ base::ThreadPool::CreateAndStartWithDefaultParams("quic_client");
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
diff --git a/net/tools/quic/quic_simple_server_bin.cc b/net/tools/quic/quic_simple_server_bin.cc
index 2d602cd..a379bc0 100644
--- a/net/tools/quic/quic_simple_server_bin.cc
+++ b/net/tools/quic/quic_simple_server_bin.cc
@@ -13,7 +13,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
#include "net/quic/crypto/proof_source_chromium.h"
@@ -45,7 +45,7 @@
}
int main(int argc, char* argv[]) {
- base::TaskScheduler::CreateAndStartWithDefaultParams("quic_server");
+ base::ThreadPool::CreateAndStartWithDefaultParams("quic_server");
base::AtExitManager exit_manager;
base::MessageLoopForIO message_loop;
diff --git a/net/url_request/url_fetcher_impl_unittest.cc b/net/url_request/url_fetcher_impl_unittest.cc
index 7e3b13c..ea4dad8c 100644
--- a/net/url_request/url_fetcher_impl_unittest.cc
+++ b/net/url_request/url_fetcher_impl_unittest.cc
@@ -567,7 +567,7 @@
EXPECT_EQ(kDefaultResponseBody, data);
}
-// Verifies that a URLFetcher works correctly on a TaskScheduler Sequence.
+// Verifies that a URLFetcher works correctly on a ThreadPool Sequence.
TEST_F(URLFetcherTest, SequencedTaskTest) {
auto sequenced_task_runner = base::CreateSequencedTaskRunnerWithTraits({});
diff --git a/remoting/client/chromoting_client_runtime.cc b/remoting/client/chromoting_client_runtime.cc
index f52a31e..7bb0355e 100644
--- a/remoting/client/chromoting_client_runtime.cc
+++ b/remoting/client/chromoting_client_runtime.cc
@@ -10,7 +10,7 @@
#include "base/memory/singleton.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
#include "mojo/core/embedder/embedder.h"
#include "remoting/base/chromium_url_request.h"
@@ -34,7 +34,7 @@
}
ChromotingClientRuntime::ChromotingClientRuntime() {
- base::TaskScheduler::CreateAndStartWithDefaultParams("Remoting");
+ base::ThreadPool::CreateAndStartWithDefaultParams("Remoting");
DCHECK(!base::MessageLoopCurrent::Get());
@@ -71,7 +71,7 @@
}
// Block until tasks blocking shutdown have completed their execution.
- base::TaskScheduler::GetInstance()->Shutdown();
+ base::ThreadPool::GetInstance()->Shutdown();
if (delegate_) {
delegate_->RuntimeDidShutdown();
diff --git a/remoting/client/chromoting_client_runtime.h b/remoting/client/chromoting_client_runtime.h
index 34827c7..3a0baccb3 100644
--- a/remoting/client/chromoting_client_runtime.h
+++ b/remoting/client/chromoting_client_runtime.h
@@ -101,7 +101,7 @@
// thread. We should update this class to use regular threads like the client
// plugin does.
// Longer term we should migrate most of these to background tasks except the
- // network thread to TaskScheduler, removing the need for threads.
+ // network thread to ThreadPool, removing the need for threads.
scoped_refptr<AutoThreadTaskRunner> audio_task_runner_;
scoped_refptr<AutoThreadTaskRunner> display_task_runner_;
diff --git a/remoting/client/jni/jni_runtime_delegate.cc b/remoting/client/jni/jni_runtime_delegate.cc
index f9eb45c0..cbd057a 100644
--- a/remoting/client/jni/jni_runtime_delegate.cc
+++ b/remoting/client/jni/jni_runtime_delegate.cc
@@ -15,7 +15,7 @@
#include "base/memory/singleton.h"
#include "base/stl_util.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "jni/JniInterface_jni.h"
#include "remoting/base/chromium_url_request.h"
#include "remoting/base/url_request_context_getter.h"
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index 95785118..256e235 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -23,7 +23,7 @@
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread.h"
#include "base/values.h"
@@ -225,15 +225,15 @@
// Start all the threads.
context_.Start();
- // Initialize TaskScheduler. TaskScheduler::StartWithDefaultParams() doesn't
+ // Initialize ThreadPool. ThreadPool::StartWithDefaultParams() doesn't
// work on NACL.
- base::TaskScheduler::Create("RemotingChromeApp");
+ base::ThreadPool::Create("RemotingChromeApp");
// TODO(etiennep): Change this to 2 in future CL.
constexpr int kBackgroundMaxThreads = 3;
constexpr int kForegroundMaxThreads = 3;
constexpr base::TimeDelta kSuggestedReclaimTime =
base::TimeDelta::FromSeconds(30);
- base::TaskScheduler::GetInstance()->Start(
+ base::ThreadPool::GetInstance()->Start(
{{kBackgroundMaxThreads, kSuggestedReclaimTime},
{kForegroundMaxThreads, kSuggestedReclaimTime}});
diff --git a/remoting/host/desktop_process_main.cc b/remoting/host/desktop_process_main.cc
index f96d280..0149521 100644
--- a/remoting/host/desktop_process_main.cc
+++ b/remoting/host/desktop_process_main.cc
@@ -13,7 +13,7 @@
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
#include "mojo/core/embedder/scoped_ipc_support.h"
#include "mojo/public/cpp/platform/named_platform_channel.h"
@@ -35,7 +35,7 @@
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
- base::TaskScheduler::CreateAndStartWithDefaultParams("Me2Me");
+ base::ThreadPool::CreateAndStartWithDefaultParams("Me2Me");
base::MessageLoopForUI message_loop;
base::RunLoop run_loop;
diff --git a/remoting/host/file_transfer/file_chooser_main_win.cc b/remoting/host/file_transfer/file_chooser_main_win.cc
index ce8faa1..2f0bbba1 100644
--- a/remoting/host/file_transfer/file_chooser_main_win.cc
+++ b/remoting/host/file_transfer/file_chooser_main_win.cc
@@ -15,7 +15,7 @@
#include "base/no_destructor.h"
#include "base/pickle.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/timer/timer.h"
#include "base/win/scoped_co_mem.h"
#include "base/win/scoped_com_initializer.h"
@@ -133,7 +133,7 @@
} // namespace
int FileChooserMain() {
- base::TaskScheduler::CreateAndStartWithDefaultParams("FileChooser");
+ base::ThreadPool::CreateAndStartWithDefaultParams("FileChooser");
base::win::ScopedCOMInitializer com;
diff --git a/remoting/host/it2me/it2me_native_messaging_host_main.cc b/remoting/host/it2me/it2me_native_messaging_host_main.cc
index 485d107..945e2db 100644
--- a/remoting/host/it2me/it2me_native_messaging_host_main.cc
+++ b/remoting/host/it2me/it2me_native_messaging_host_main.cc
@@ -11,7 +11,7 @@
#include "base/i18n/icu_util.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
#include "mojo/core/embedder/embedder.h"
#include "net/base/network_change_notifier.h"
@@ -102,7 +102,7 @@
mojo::core::Init();
- base::TaskScheduler::CreateAndStartWithDefaultParams("It2Me");
+ base::ThreadPool::CreateAndStartWithDefaultParams("It2Me");
remoting::LoadResources("");
@@ -232,7 +232,7 @@
run_loop.Run();
// Block until tasks blocking shutdown have completed their execution.
- base::TaskScheduler::GetInstance()->Shutdown();
+ base::ThreadPool::GetInstance()->Shutdown();
return kSuccessExitCode;
}
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index 7c4827e..386becd 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -26,7 +26,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringize_macros.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
#include "components/policy/policy_constants.h"
#include "ipc/ipc_channel.h"
@@ -1757,7 +1757,7 @@
base::GetLinuxDistro();
#endif
- base::TaskScheduler::CreateAndStartWithDefaultParams("Me2Me");
+ base::ThreadPool::CreateAndStartWithDefaultParams("Me2Me");
// Create the main message loop and start helper threads.
base::MessageLoopForUI message_loop;
@@ -1784,7 +1784,7 @@
run_loop.Run();
// Block until tasks blocking shutdown have completed their execution.
- base::TaskScheduler::GetInstance()->Shutdown();
+ base::ThreadPool::GetInstance()->Shutdown();
return exit_code;
}
diff --git a/remoting/host/setup/me2me_native_messaging_host_main.cc b/remoting/host/setup/me2me_native_messaging_host_main.cc
index a0072e7..5f8530e 100644
--- a/remoting/host/setup/me2me_native_messaging_host_main.cc
+++ b/remoting/host/setup/me2me_native_messaging_host_main.cc
@@ -16,7 +16,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread.h"
#include "build/build_config.h"
#include "mojo/core/embedder/embedder.h"
@@ -88,7 +88,7 @@
}
#endif // defined(REMOTING_ENABLE_BREAKPAD)
- base::TaskScheduler::CreateAndStartWithDefaultParams("Me2Me");
+ base::ThreadPool::CreateAndStartWithDefaultParams("Me2Me");
mojo::core::Init();
@@ -268,7 +268,7 @@
run_loop.Run();
// Block until tasks blocking shutdown have completed their execution.
- base::TaskScheduler::GetInstance()->Shutdown();
+ base::ThreadPool::GetInstance()->Shutdown();
return kSuccessExitCode;
}
diff --git a/remoting/host/setup/start_host_main.cc b/remoting/host/setup/start_host_main.cc
index ce7e25f..31181ff 100644
--- a/remoting/host/setup/start_host_main.cc
+++ b/remoting/host/setup/start_host_main.cc
@@ -14,7 +14,7 @@
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread.h"
#include "build/build_config.h"
#include "mojo/core/embedder/embedder.h"
@@ -134,7 +134,7 @@
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
logging::InitLogging(settings);
- base::TaskScheduler::CreateAndStartWithDefaultParams("RemotingHostSetup");
+ base::ThreadPool::CreateAndStartWithDefaultParams("RemotingHostSetup");
mojo::core::Init();
diff --git a/remoting/test/chromoting_test_driver.cc b/remoting/test/chromoting_test_driver.cc
index 43b8a3f9..f6e8cbd 100644
--- a/remoting/test/chromoting_test_driver.cc
+++ b/remoting/test/chromoting_test_driver.cc
@@ -9,7 +9,7 @@
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/stringprintf.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
#include "base/test/test_switches.h"
@@ -191,7 +191,7 @@
#endif
}
- base::TaskScheduler::CreateAndStartWithDefaultParams("ChromotingTestDriver");
+ base::ThreadPool::CreateAndStartWithDefaultParams("ChromotingTestDriver");
mojo::core::Init();
diff --git a/remoting/test/ftl_services_playground_main.cc b/remoting/test/ftl_services_playground_main.cc
index 009aed99..dc9c9818 100644
--- a/remoting/test/ftl_services_playground_main.cc
+++ b/remoting/test/ftl_services_playground_main.cc
@@ -6,7 +6,7 @@
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "mojo/core/embedder/embedder.h"
#include "remoting/test/ftl_services_playground.h"
@@ -22,7 +22,7 @@
return 0;
}
- base::TaskScheduler::CreateAndStartWithDefaultParams("FtlServicesPlayground");
+ base::ThreadPool::CreateAndStartWithDefaultParams("FtlServicesPlayground");
mojo::core::Init();
playground.StartAndAuthenticate();
diff --git a/remoting/test/ftl_signaling_playground_main.cc b/remoting/test/ftl_signaling_playground_main.cc
index 20c3d0b..45d3859 100644
--- a/remoting/test/ftl_signaling_playground_main.cc
+++ b/remoting/test/ftl_signaling_playground_main.cc
@@ -6,7 +6,7 @@
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "mojo/core/embedder/embedder.h"
#include "remoting/test/ftl_signaling_playground.h"
@@ -22,8 +22,7 @@
return 0;
}
- base::TaskScheduler::CreateAndStartWithDefaultParams(
- "FtlSignalingPlayground");
+ base::ThreadPool::CreateAndStartWithDefaultParams("FtlSignalingPlayground");
mojo::core::Init();
playground.StartLoop();
diff --git a/remoting/test/protocol_perftest.cc b/remoting/test/protocol_perftest.cc
index e24b27a..52e078b 100644
--- a/remoting/test/protocol_perftest.cc
+++ b/remoting/test/protocol_perftest.cc
@@ -14,7 +14,7 @@
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/task_runner_util.h"
#include "base/test/scoped_task_environment.h"
#include "base/threading/thread_task_runner_handle.h"
diff --git a/services/audio/test/fake_consumer.cc b/services/audio/test/fake_consumer.cc
index 39ab618..84ae881 100644
--- a/services/audio/test/fake_consumer.cc
+++ b/services/audio/test/fake_consumer.cc
@@ -12,7 +12,7 @@
#include "base/files/file.h"
#include "base/logging.h"
#include "base/numerics/math_constants.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_task_environment.h"
#include "media/audio/audio_debug_file_writer.h"
#include "media/base/audio_bus.h"
@@ -123,7 +123,7 @@
// Not all tests set-up a full task environment. However, AudioDebugFileWriter
// requires one. Provide a temporary one here, if necessary.
std::unique_ptr<base::test::ScopedTaskEnvironment> task_environment;
- if (!base::TaskScheduler::GetInstance()) {
+ if (!base::ThreadPool::GetInstance()) {
task_environment = std::make_unique<base::test::ScopedTaskEnvironment>();
}
diff --git a/services/network/cookie_manager_unittest.cc b/services/network/cookie_manager_unittest.cc
index e82e48f..7e299f4 100644
--- a/services/network/cookie_manager_unittest.cc
+++ b/services/network/cookie_manager_unittest.cc
@@ -13,7 +13,7 @@
#include "base/stl_util.h"
#include "base/strings/strcat.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/bind_test_util.h"
#include "base/test/scoped_task_environment.h"
#include "base/time/time.h"
diff --git a/services/network/session_cleanup_cookie_store_unittest.cc b/services/network/session_cleanup_cookie_store_unittest.cc
index 1a9fe536..fc5de35 100644
--- a/services/network/session_cleanup_cookie_store_unittest.cc
+++ b/services/network/session_cleanup_cookie_store_unittest.cc
@@ -10,7 +10,7 @@
#include "base/run_loop.h"
#include "base/sequenced_task_runner.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_task_environment.h"
#include "base/time/time.h"
#include "net/log/net_log_capture_mode.h"
@@ -75,8 +75,8 @@
void DestroyStore() {
store_ = nullptr;
- // Ensure that |store_|'s destructor has run by flushing TaskScheduler.
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ // Ensure that |store_|'s destructor has run by flushing ThreadPool.
+ base::ThreadPool::GetInstance()->FlushForTesting();
}
void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); }
diff --git a/services/service_manager/embedder/main.cc b/services/service_manager/embedder/main.cc
index 0fbc214..2f1c180 100644
--- a/services/service_manager/embedder/main.cc
+++ b/services/service_manager/embedder/main.cc
@@ -20,7 +20,7 @@
#include "base/process/process.h"
#include "base/run_loop.h"
#include "base/stl_util.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread.h"
#include "base/trace_event/trace_config.h"
#include "base/trace_event/trace_log.h"
@@ -164,7 +164,7 @@
}
#endif
- base::TaskScheduler::CreateAndStartWithDefaultParams("ServiceManagerProcess");
+ base::ThreadPool::CreateAndStartWithDefaultParams("ServiceManagerProcess");
}
int RunServiceManager(MainDelegate* delegate) {
@@ -188,7 +188,7 @@
run_loop.Run();
ipc_thread.Stop();
- base::TaskScheduler::GetInstance()->Shutdown();
+ base::ThreadPool::GetInstance()->Shutdown();
return 0;
}
diff --git a/services/service_manager/public/cpp/service_executable/main.cc b/services/service_manager/public/cpp/service_executable/main.cc
index d29d2aa..dca88ba0 100644
--- a/services/service_manager/public/cpp/service_executable/main.cc
+++ b/services/service_manager/public/cpp/service_executable/main.cc
@@ -17,7 +17,7 @@
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
#include "services/service_manager/public/cpp/service_executable/service_executable_environment.h"
#include "services/service_manager/public/cpp/service_executable/service_main.h"
@@ -94,7 +94,7 @@
WaitForDebuggerIfNecessary();
service_manager::ServiceExecutableEnvironment environment;
ServiceMain(environment.TakeServiceRequestFromCommandLine());
- base::TaskScheduler::GetInstance()->Shutdown();
+ base::ThreadPool::GetInstance()->Shutdown();
return 0;
}
diff --git a/services/service_manager/public/cpp/service_executable/service_executable_environment.cc b/services/service_manager/public/cpp/service_executable/service_executable_environment.cc
index 0b7c58f..6c6755e 100644
--- a/services/service_manager/public/cpp/service_executable/service_executable_environment.cc
+++ b/services/service_manager/public/cpp/service_executable/service_executable_environment.cc
@@ -9,7 +9,7 @@
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/public/cpp/platform/platform_channel.h"
@@ -62,7 +62,7 @@
mojo::core::Init();
- base::TaskScheduler::CreateAndStartWithDefaultParams("StandaloneService");
+ base::ThreadPool::CreateAndStartWithDefaultParams("StandaloneService");
ipc_thread_.StartWithOptions(
base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
diff --git a/services/tracing/public/cpp/perfetto/producer_client.cc b/services/tracing/public/cpp/perfetto/producer_client.cc
index fb77788..e0d747f 100644
--- a/services/tracing/public/cpp/perfetto/producer_client.cc
+++ b/services/tracing/public/cpp/perfetto/producer_client.cc
@@ -9,7 +9,7 @@
#include "base/bind.h"
#include "base/no_destructor.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/scheduler_lock_impl.h"
+#include "base/task/thread_pool/scheduler_lock_impl.h"
#include "services/tracing/public/cpp/perfetto/shared_memory.h"
#include "services/tracing/public/mojom/constants.mojom.h"
#include "third_party/perfetto/include/perfetto/tracing/core/commit_data_request.h"
diff --git a/services/tracing/public/cpp/perfetto/track_event_thread_local_event_sink.cc b/services/tracing/public/cpp/perfetto/track_event_thread_local_event_sink.cc
index ed33b50..162b5b6 100644
--- a/services/tracing/public/cpp/perfetto/track_event_thread_local_event_sink.cc
+++ b/services/tracing/public/cpp/perfetto/track_event_thread_local_event_sink.cc
@@ -52,7 +52,7 @@
const char* kTaskExecutionEventCategory = "toplevel";
const char* kTaskExecutionEventNames[3] = {"ThreadControllerImpl::RunTask",
"ThreadController::Task",
- "TaskScheduler_RunTask"};
+ "ThreadPool_RunTask"};
void AddConvertableToTraceFormat(
base::trace_event::ConvertableToTraceFormat* value,
diff --git a/services/tracing/public/cpp/traced_process_impl.cc b/services/tracing/public/cpp/traced_process_impl.cc
index fd1a778..1824f7c 100644
--- a/services/tracing/public/cpp/traced_process_impl.cc
+++ b/services/tracing/public/cpp/traced_process_impl.cc
@@ -8,7 +8,7 @@
#include "base/bind.h"
#include "base/no_destructor.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "services/tracing/public/cpp/base_agent.h"
#include "services/tracing/public/cpp/perfetto/producer_client.h"
#include "services/tracing/public/cpp/trace_event_agent.h"
@@ -76,9 +76,9 @@
mojom::ConnectToTracingRequestPtr request) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
- // Tracing requires a running TaskScheduler; disable tracing
+ // Tracing requires a running ThreadPool; disable tracing
// for processes without it.
- if (!base::TaskScheduler::GetInstance()) {
+ if (!base::ThreadPool::GetInstance()) {
return;
}
diff --git a/storage/browser/blob/blob_builder_from_stream_unittest.cc b/storage/browser/blob/blob_builder_from_stream_unittest.cc
index 1827b9fc..02f9d1d 100644
--- a/storage/browser/blob/blob_builder_from_stream_unittest.cc
+++ b/storage/browser/blob/blob_builder_from_stream_unittest.cc
@@ -13,7 +13,7 @@
#include "base/rand_util.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/bind_test_util.h"
#include "base/test/scoped_task_environment.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
@@ -66,7 +66,7 @@
void TearDown() override {
// Make sure we clean up files.
base::RunLoop().RunUntilIdle();
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
base::RunLoop().RunUntilIdle();
}
@@ -332,7 +332,7 @@
// Make sure we clean up files.
base::RunLoop().RunUntilIdle();
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(0u, context_->memory_controller().memory_usage());
diff --git a/third_party/blink/renderer/platform/scheduler/public/worker_pool.h b/third_party/blink/renderer/platform/scheduler/public/worker_pool.h
index ba16648..56b00b8bc 100644
--- a/third_party/blink/renderer/platform/scheduler/public/worker_pool.h
+++ b/third_party/blink/renderer/platform/scheduler/public/worker_pool.h
@@ -15,7 +15,7 @@
namespace worker_pool {
-// These are a thin wrapper around base::TaskScheduler to ensure that all
+// These are a thin wrapper around base::ThreadPool to ensure that all
// callers use WTF::CrossThreadBind instead of base::Bind to ensure that
// all non-thread-safe objects are copied properly.
//
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 92e271a..91a0224 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -127240,6 +127240,9 @@
</histogram>
<histogram base="true" name="TaskScheduler.DetachDuration" units="ms">
+ <obsolete>
+ Deprecated 4/2019. Prefix renamed to ThreadPool.
+ </obsolete>
<owner>fdoray@chromium.org</owner>
<owner>gab@chromium.org</owner>
<owner>robliao@chromium.org</owner>
@@ -127253,6 +127256,9 @@
<histogram base="true" name="TaskScheduler.HeartbeatLatencyMicroseconds"
units="microseconds">
+ <obsolete>
+ Deprecated 4/2019. Prefix renamed to ThreadPool.
+ </obsolete>
<owner>fdoray@chromium.org</owner>
<owner>gab@chromium.org</owner>
<owner>robliao@chromium.org</owner>
@@ -127272,6 +127278,9 @@
</histogram>
<histogram base="true" name="TaskScheduler.NumActiveWorkers" units="workers">
+ <obsolete>
+ Deprecated 4/2019. Prefix renamed to ThreadPool.
+ </obsolete>
<owner>etiennep@chromium.org</owner>
<owner>fdoray@chromium.org</owner>
<owner>gab@chromium.org</owner>
@@ -127299,6 +127308,9 @@
</histogram>
<histogram base="true" name="TaskScheduler.NumTasksBeforeDetach" units="tasks">
+ <obsolete>
+ Deprecated 4/2019. Prefix renamed to ThreadPool.
+ </obsolete>
<owner>fdoray@chromium.org</owner>
<owner>gab@chromium.org</owner>
<owner>robliao@chromium.org</owner>
@@ -127309,6 +127321,9 @@
</histogram>
<histogram base="true" name="TaskScheduler.NumTasksBetweenWaits" units="tasks">
+ <obsolete>
+ Deprecated 4/2019. Prefix renamed to ThreadPool.
+ </obsolete>
<owner>fdoray@chromium.org</owner>
<owner>gab@chromium.org</owner>
<owner>robliao@chromium.org</owner>
@@ -127321,6 +127336,9 @@
<histogram base="true" name="TaskScheduler.NumTasksRunWhileQueuing"
units="tasks" expires_after="2019-10-01">
+ <obsolete>
+ Deprecated 4/2019. Prefix renamed to ThreadPool.
+ </obsolete>
<owner>fdoray@chromium.org</owner>
<summary>
Number of tasks run by TaskScheduler while task was queuing (from time task
@@ -127332,6 +127350,9 @@
</histogram>
<histogram base="true" name="TaskScheduler.NumWorkers" units="workers">
+ <obsolete>
+ Deprecated 4/2019. Prefix renamed to ThreadPool.
+ </obsolete>
<owner>etiennep@chromium.org</owner>
<owner>fdoray@chromium.org</owner>
<owner>gab@chromium.org</owner>
@@ -127383,6 +127404,9 @@
<histogram base="true" name="TaskScheduler.TaskLatencyMicroseconds"
units="microseconds">
+ <obsolete>
+ Deprecated 4/2019. Prefix renamed to ThreadPool.
+ </obsolete>
<owner>fdoray@chromium.org</owner>
<owner>gab@chromium.org</owner>
<owner>robliao@chromium.org</owner>
@@ -127756,6 +127780,102 @@
</summary>
</histogram>
+<histogram base="true" name="ThreadPool.DetachDuration" units="ms">
+ <owner>fdoray@chromium.org</owner>
+ <owner>gab@chromium.org</owner>
+ <owner>robliao@chromium.org</owner>
+ <summary>
+ Time elapsed between when the thread managed by a SchedulerWorker is
+ detached and when the main function of a new thread managed by the same
+ SchedulerWorker is entered (following a wake up). Recorded each time that a
+ thread is recreated for a given SchedulerWorker.
+ </summary>
+</histogram>
+
+<histogram base="true" name="ThreadPool.HeartbeatLatencyMicroseconds"
+ units="microseconds">
+ <owner>fdoray@chromium.org</owner>
+ <owner>gab@chromium.org</owner>
+ <owner>robliao@chromium.org</owner>
+ <summary>
+ Latency of dummy "heartbeat" tasks posted with specific traits
+ (see suffix). The heartbeat recording avoids dependencies between this
+ report and other work in the system. See
+ ThreadPool.TaskLatencyMicroseconds.* for a metric that is closer to the real
+ workload.
+
+ Warning: This metric may include reports from clients with low-resolution
+ clocks (i.e. on Windows, ref. |TimeTicks::IsHighResolution()|). Such reports
+ will cause this metric to have an abnormal distribution. When considering
+ revising this histogram, see UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES for the
+ solution.
+ </summary>
+</histogram>
+
+<histogram base="true" name="ThreadPool.NumActiveWorkers" units="workers">
+ <owner>etiennep@chromium.org</owner>
+ <owner>fdoray@chromium.org</owner>
+ <owner>gab@chromium.org</owner>
+ <summary>
+ Number of workers running a task in a given SchedulerWorkerPool. Recorded
+ every 59 minutes (sampling rate is not expected to affect the distribution).
+ </summary>
+</histogram>
+
+<histogram base="true" name="ThreadPool.NumTasksBeforeDetach" units="tasks">
+ <owner>fdoray@chromium.org</owner>
+ <owner>gab@chromium.org</owner>
+ <owner>robliao@chromium.org</owner>
+ <summary>
+ Number of tasks executed by a SchedulerWorker before it detached. Recorded
+ when a SchedulerWorker detaches.
+ </summary>
+</histogram>
+
+<histogram base="true" name="ThreadPool.NumTasksBetweenWaits" units="tasks">
+ <owner>fdoray@chromium.org</owner>
+ <owner>gab@chromium.org</owner>
+ <owner>robliao@chromium.org</owner>
+ <summary>
+ Number of tasks executed by a SchedulerWorker between two waits on its
+ WaitableEvent. This should be maximized without affecting perceived browser
+ performance.
+ </summary>
+</histogram>
+
+<histogram base="true" name="ThreadPool.NumTasksRunWhileQueuing" units="tasks"
+ expires_after="2019-10-01">
+ <owner>fdoray@chromium.org</owner>
+ <summary>
+ Number of tasks run by ThreadPool while task was queuing (from time task was
+ posted until time it was run). Recorded for dummy "heartbeat"
+ tasks posted with specific traits (see suffix). The heartbeat recording
+ avoids dependencies between this report and other work in the system.
+ Recorded every time the ServiceThread performs a heartbeat latency report.
+ </summary>
+</histogram>
+
+<histogram base="true" name="ThreadPool.NumWorkers" units="workers">
+ <owner>etiennep@chromium.org</owner>
+ <owner>fdoray@chromium.org</owner>
+ <owner>gab@chromium.org</owner>
+ <summary>
+ Number of workers that live in a given SchedulerWorkerPool. Recorded every
+ 59 minutes (sampling rate is not expected to affect the distribution).
+ </summary>
+</histogram>
+
+<histogram base="true" name="ThreadPool.TaskLatencyMicroseconds"
+ units="microseconds">
+ <owner>fdoray@chromium.org</owner>
+ <owner>gab@chromium.org</owner>
+ <owner>robliao@chromium.org</owner>
+ <summary>
+ Time elapsed between when a task is posted and when it starts to run.
+ Recorded for each task that runs inside the ThreadPool.
+ </summary>
+</histogram>
+
<histogram name="ThreadWatcher.ResponseTime" units="ms">
<owner>rch@chromium.org</owner>
<summary>
@@ -154809,6 +154929,9 @@
</histogram_suffixes>
<histogram_suffixes name="TaskSchedulerName" separator=".">
+ <obsolete>
+ Deprecated 4/2019. Prefix renamed to ThreadPool.
+ </obsolete>
<suffix base="true" name="Browser"
label="TaskScheduler for the browser process."/>
<suffix base="true" name="ContentChild"
@@ -154866,6 +154989,9 @@
</histogram_suffixes>
<histogram_suffixes name="TaskSchedulerTaskType" separator=".">
+ <obsolete>
+ Deprecated 4/2019. Prefix renamed to ThreadPool.
+ </obsolete>
<suffix name="BackgroundTaskPriority"
label="Applies to tasks posted with a BACKGROUND priority and neither
of MayBlock() nor WithBaseSyncPrimitives()."/>
@@ -154901,6 +155027,9 @@
</histogram_suffixes>
<histogram_suffixes name="TaskSchedulerWorkerPool" separator=".">
+ <obsolete>
+ Deprecated 4/2019. Prefix renamed to ThreadPool.
+ </obsolete>
<suffix name="BackgroundBlockingPool"
label="Applies to the BackgroundBlocking worker pool.">
<obsolete>
@@ -155001,6 +155130,79 @@
<affected-histogram name="OSX.OtherInstances"/>
</histogram_suffixes>
+<histogram_suffixes name="ThreadPoolName" separator=".">
+ <obsolete>
+ Deprecated 4/2019. Prefix renamed to ThreadPool.
+ </obsolete>
+ <suffix base="true" name="Browser"
+ label="ThreadPool for the browser process."/>
+ <suffix base="true" name="ContentChild"
+ label="ThreadPools for various instantiations of content::ChildProcess."/>
+ <suffix base="true" name="Renderer"
+ label="ThreadPools for renderer processes."/>
+ <affected-histogram name="ThreadPool.DetachDuration"/>
+ <affected-histogram name="ThreadPool.HeartbeatLatencyMicroseconds"/>
+ <affected-histogram name="ThreadPool.NumActiveWorkers"/>
+ <affected-histogram name="ThreadPool.NumTasksBeforeDetach"/>
+ <affected-histogram name="ThreadPool.NumTasksBetweenWaits"/>
+ <affected-histogram name="ThreadPool.NumTasksRunWhileQueuing"/>
+ <affected-histogram name="ThreadPool.NumWorkers"/>
+ <affected-histogram name="ThreadPool.TaskLatencyMicroseconds"/>
+</histogram_suffixes>
+
+<histogram_suffixes name="ThreadPoolTaskType" separator=".">
+ <suffix name="BackgroundTaskPriority"
+ label="Applies to tasks posted with a BACKGROUND priority and neither
+ of MayBlock() nor WithBaseSyncPrimitives()."/>
+ <suffix name="BackgroundTaskPriority_MayBlock"
+ label="Applies to tasks posted with a BACKGROUND priority and
+ MayBlock() or WithBaseSyncPrimitives()."/>
+ <suffix name="UserBlockingTaskPriority"
+ label="Applies to tasks posted with a USER_BLOCKING priority and
+ neither of MayBlock() nor WithBaseSyncPrimitives()."/>
+ <suffix name="UserBlockingTaskPriority_MayBlock"
+ label="Applies to tasks posted with a USER_BLOCKING priority and
+ MayBlock() or WithBaseSyncPrimitives()."/>
+ <suffix name="UserVisibleTaskPriority"
+ label="Applies to tasks posted with a USER_VISIBLE priority and neither
+ of MayBlock() nor WithBaseSyncPrimitives()."/>
+ <suffix name="UserVisibleTaskPriority_MayBlock"
+ label="Applies to tasks posted with a USER_VISIBLE priority and
+ MayBlock() or WithBaseSyncPrimitives()."/>
+ <affected-histogram name="ThreadPool.HeartbeatLatencyMicroseconds.Browser"/>
+ <affected-histogram
+ name="ThreadPool.HeartbeatLatencyMicroseconds.ContentChild"/>
+ <affected-histogram name="ThreadPool.HeartbeatLatencyMicroseconds.Renderer"/>
+ <affected-histogram name="ThreadPool.NumTasksRunWhileQueuing.Browser"/>
+ <affected-histogram name="ThreadPool.NumTasksRunWhileQueuing.ContentChild"/>
+ <affected-histogram name="ThreadPool.NumTasksRunWhileQueuing.Renderer"/>
+ <affected-histogram name="ThreadPool.TaskLatencyMicroseconds.Browser"/>
+ <affected-histogram name="ThreadPool.TaskLatencyMicroseconds.ContentChild"/>
+ <affected-histogram name="ThreadPool.TaskLatencyMicroseconds.Renderer"/>
+</histogram_suffixes>
+
+<histogram_suffixes name="ThreadPoolWorkerGroup" separator=".">
+ <suffix name="Background"
+ label="Applies to the Background priority worker group."/>
+ <suffix name="Foreground"
+ label="Applies to the Foreground priority worker group."/>
+ <affected-histogram name="ThreadPool.DetachDuration.Browser"/>
+ <affected-histogram name="ThreadPool.DetachDuration.ContentChild"/>
+ <affected-histogram name="ThreadPool.DetachDuration.Renderer"/>
+ <affected-histogram name="ThreadPool.NumActiveWorkers.Browser"/>
+ <affected-histogram name="ThreadPool.NumActiveWorkers.ContentChild"/>
+ <affected-histogram name="ThreadPool.NumActiveWorkers.Renderer"/>
+ <affected-histogram name="ThreadPool.NumTasksBeforeDetach.Browser"/>
+ <affected-histogram name="ThreadPool.NumTasksBeforeDetach.ContentChild"/>
+ <affected-histogram name="ThreadPool.NumTasksBeforeDetach.Renderer"/>
+ <affected-histogram name="ThreadPool.NumTasksBetweenWaits.Browser"/>
+ <affected-histogram name="ThreadPool.NumTasksBetweenWaits.ContentChild"/>
+ <affected-histogram name="ThreadPool.NumTasksBetweenWaits.Renderer"/>
+ <affected-histogram name="ThreadPool.NumWorkers.Browser"/>
+ <affected-histogram name="ThreadPool.NumWorkers.ContentChild"/>
+ <affected-histogram name="ThreadPool.NumWorkers.Renderer"/>
+</histogram_suffixes>
+
<histogram_suffixes name="ThreadWatcher" separator=".">
<suffix name="CACHE" label="where watched thread is CACHE BrowserThread."/>
<suffix name="DB" label="where watched thread is DB BrowserThread."/>
diff --git a/tools/v8_context_snapshot/v8_context_snapshot_generator.cc b/tools/v8_context_snapshot/v8_context_snapshot_generator.cc
index ff94746..4298bff 100644
--- a/tools/v8_context_snapshot/v8_context_snapshot_generator.cc
+++ b/tools/v8_context_snapshot/v8_context_snapshot_generator.cc
@@ -7,7 +7,7 @@
#include "base/files/file_util.h"
#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "gin/v8_initializer.h"
#include "mojo/core/embedder/embedder.h"
@@ -42,7 +42,7 @@
// Set up environment to make Blink and V8 workable.
base::MessageLoop message_loop;
- base::TaskScheduler::CreateAndStartWithDefaultParams("TakeSnapshot");
+ base::ThreadPool::CreateAndStartWithDefaultParams("TakeSnapshot");
mojo::core::Init();
// Set predictable flag in V8 to generate identical snapshot file.
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc
index 76c1c17..04b12f5 100644
--- a/ui/aura/demo/demo_main.cc
+++ b/ui/aura/demo/demo_main.cc
@@ -13,7 +13,7 @@
#include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_device_source.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "build/build_config.h"
#include "components/viz/host/host_frame_sink_manager.h"
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
@@ -145,7 +145,7 @@
// Create the message-loop here before creating the root window.
base::MessageLoopForUI message_loop;
- base::TaskScheduler::CreateAndStartWithDefaultParams("demo");
+ base::ThreadPool::CreateAndStartWithDefaultParams("demo");
ui::InitializeInputMethodForTesting();
// The ContextFactory must exist before any Compositors are created.
diff --git a/ui/aura/native_window_occlusion_tracker_win_interactive_test.cc b/ui/aura/native_window_occlusion_tracker_win_interactive_test.cc
index c2e2089..b4b6416 100644
--- a/ui/aura/native_window_occlusion_tracker_win_interactive_test.cc
+++ b/ui/aura/native_window_occlusion_tracker_win_interactive_test.cc
@@ -11,7 +11,7 @@
#include "base/feature_list.h"
#include "base/macros.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/test/scoped_feature_list.h"
#include "base/win/scoped_gdi_object.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/ui/ozone/demo/ozone_demo.cc b/ui/ozone/demo/ozone_demo.cc
index 1ca0578..cb36fdb 100644
--- a/ui/ozone/demo/ozone_demo.cc
+++ b/ui/ozone/demo/ozone_demo.cc
@@ -10,7 +10,7 @@
#include "base/debug/stack_trace.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "components/tracing/common/trace_to_console.h"
@@ -71,7 +71,7 @@
mojo::core::Init();
base::MessageLoopForUI message_loop;
- base::TaskScheduler::CreateAndStartWithDefaultParams("OzoneDemo");
+ base::ThreadPool::CreateAndStartWithDefaultParams("OzoneDemo");
ui::OzonePlatform::InitParams params;
params.single_process = true;
diff --git a/ui/ozone/demo/skia/skia_demo.cc b/ui/ozone/demo/skia/skia_demo.cc
index 053eead..857ebae 100644
--- a/ui/ozone/demo/skia/skia_demo.cc
+++ b/ui/ozone/demo/skia/skia_demo.cc
@@ -10,7 +10,7 @@
#include "base/debug/stack_trace.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/trace_event/trace_event.h"
#include "components/tracing/common/trace_to_console.h"
#include "components/tracing/common/tracing_switches.h"
@@ -46,7 +46,7 @@
// Build UI thread message loop. This is used by platform
// implementations for event polling & running background tasks.
base::MessageLoopForUI message_loop;
- base::TaskScheduler::CreateAndStartWithDefaultParams("SkiaDemo");
+ base::ThreadPool::CreateAndStartWithDefaultParams("SkiaDemo");
ui::OzonePlatform::InitParams params;
params.single_process = true;