[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 <[email protected]>
Auto-Submit: Gabriel Charette <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Reviewed-by: François Doray <[email protected]>
Reviewed-by: Ilya Sherman <[email protected]>
Reviewed-by: Richard Coles <[email protected]>
Reviewed-by: Joe Mason <[email protected]>
Reviewed-by: Etienne Pierre-Doray <[email protected]>
Cr-Commit-Position: refs/heads/master@{#650997}
diff --git a/base/task/thread_pool/task_tracker_posix.h b/base/task/thread_pool/task_tracker_posix.h
new file mode 100644
index 0000000..14ed817
--- /dev/null
+++ b/base/task/thread_pool/task_tracker_posix.h
@@ -0,0 +1,57 @@
+// 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_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/thread_pool/task_tracker.h"
+#include "base/threading/platform_thread.h"
+
+namespace base {
+namespace internal {
+
+struct Task;
+
+// A TaskTracker that instantiates a FileDescriptorWatcher in the scope in which
+// a task runs. Used on all POSIX platforms except NaCl SFI.
+// set_io_thread_task_runner() must be called before the
+// TaskTracker can run tasks.
+class BASE_EXPORT TaskTrackerPosix : public TaskTracker {
+ public:
+ TaskTrackerPosix(StringPiece name);
+ ~TaskTrackerPosix() override;
+
+ // Sets the task runner with which to setup FileDescriptorWatcher in
+ // the scope in which tasks run. |io_thread_task_runner| must refer to
+ // a Thread with MessageLoop::TYPE_IO.
+ // Must be called before starting to run tasks.
+ // External synchronization is required between a call to this and a call to
+ // RunTask().
+ void set_io_thread_task_runner(
+ scoped_refptr<SingleThreadTaskRunner> io_thread_task_runner) {
+ io_thread_task_runner_ = std::move(io_thread_task_runner);
+ }
+
+ protected:
+ // TaskTracker:
+ void RunOrSkipTask(Task task,
+ Sequence* sequence,
+ const TaskTraits& traits,
+ bool can_run_task) override;
+
+ private:
+ scoped_refptr<SingleThreadTaskRunner> io_thread_task_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(TaskTrackerPosix);
+};
+
+} // namespace internal
+} // namespace base
+
+#endif // BASE_TASK_THREAD_POOL_TASK_TRACKER_POSIX_H_