Index: base/task_scheduler/task_scheduler_impl.h |
diff --git a/base/task_scheduler/task_scheduler_impl.h b/base/task_scheduler/task_scheduler_impl.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5d085713e8e4ca51abe16794ee6040c493dda38a |
--- /dev/null |
+++ b/base/task_scheduler/task_scheduler_impl.h |
@@ -0,0 +1,62 @@ |
+// 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_SCHEDULER_TASK_SCHEDULER_IMPL_H_ |
+#define BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ |
+ |
+#include "base/base_export.h" |
+#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/task_scheduler/sequence.h" |
+#include "base/task_scheduler/shutdown_manager.h" |
+#include "base/task_scheduler/task_scheduler.h" |
+#include "base/task_scheduler/thread_pool.h" |
+ |
+namespace base { |
+namespace internal { |
+ |
+class WorkerThread; |
+ |
+class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler { |
+ public: |
+ TaskSchedulerImpl(); |
+ ~TaskSchedulerImpl() override; |
+ |
+ // TaskScheduler: |
+ void PostTaskWithTraits(const tracked_objects::Location& from_here, |
+ TaskTraits traits, |
+ const Closure& task) override; |
+ scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits( |
+ TaskTraits traits, |
+ ExecutionMode execution_mode) override; |
+ void Shutdown() override; |
+ |
+ // Initiates shutdown and waits until all threads have exited. This method |
+ // must not be called more than once in the lifetime of the TaskSchedulerImpl. |
+ void ShutdownAndJoinAllThreadsForTesting(); |
+ |
+ private: |
+ // Returns the thread pool that should run tasks with |traits|. |
+ ThreadPool* GetThreadPoolForTraits(const TaskTraits& traits); |
+ |
+ // Callback invoked by |worker_thread| to reinsert |sequence| in the |
+ // appropriate priority queue after it has executed one of its tasks. |
+ void ReinsertSequenceCallback(scoped_refptr<Sequence> sequence, |
+ const WorkerThread* worker_thread); |
+ |
+ ShutdownManager shutdown_manager_; |
+ |
+ scoped_ptr<ThreadPool> background_thread_pool_; |
+ scoped_ptr<ThreadPool> background_file_io_thread_pool_; |
+ scoped_ptr<ThreadPool> normal_thread_pool_; |
+ scoped_ptr<ThreadPool> normal_file_io_thread_pool_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl); |
+}; |
+ |
+} // namespace internal |
+} // namespace base |
+ |
+#endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ |