OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_TASK_SCHEDULER_SERVICE_THREAD_H_ | 5 #ifndef BASE_TASK_SCHEDULER_SERVICE_THREAD_H_ |
6 #define BASE_TASK_SCHEDULER_SERVICE_THREAD_H_ | 6 #define BASE_TASK_SCHEDULER_SERVICE_THREAD_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 class DelayedTaskManager; | 16 class DelayedTaskManager; |
17 class SchedulerWorkerThread; | 17 class SchedulerWorker; |
18 class TaskTracker; | 18 class TaskTracker; |
19 | 19 |
20 // A thread dedicated to performing Task Scheduler related work. | 20 // A thread dedicated to performing Task Scheduler related work. |
21 class BASE_EXPORT SchedulerServiceThread { | 21 class BASE_EXPORT SchedulerServiceThread { |
22 public: | 22 public: |
23 ~SchedulerServiceThread(); | 23 ~SchedulerServiceThread(); |
24 | 24 |
25 // Creates a SchedulerServiceThread. |task_tracker| and |delayed_task_manager| | 25 // Creates a SchedulerServiceThread. |task_tracker| and |delayed_task_manager| |
26 // are passed through to the underlying SchedulerWorkerThread. Returns a | 26 // are passed through to the underlying SchedulerWorker. Returns a nullptr on |
27 // nullptr on failure. | 27 // failure. |
28 static std::unique_ptr<SchedulerServiceThread> Create( | 28 static std::unique_ptr<SchedulerServiceThread> Create( |
29 TaskTracker* task_tracker, DelayedTaskManager* delayed_task_manager); | 29 TaskTracker* task_tracker, DelayedTaskManager* delayed_task_manager); |
30 | 30 |
31 // Wakes the SchedulerServiceThread if it wasn't already awake. This also has | 31 // Wakes the SchedulerServiceThread if it wasn't already awake. This also has |
32 // the impact of updating the amount of time the thread sleeps for delayed | 32 // the impact of updating the amount of time the thread sleeps for delayed |
33 // tasks. | 33 // tasks. |
34 void WakeUp(); | 34 void WakeUp(); |
35 | 35 |
36 // Joins this SchedulerServiceThread. This can only be called once. | 36 // Joins this SchedulerServiceThread. This can only be called once. |
37 void JoinForTesting(); | 37 void JoinForTesting(); |
38 | 38 |
39 private: | 39 private: |
40 SchedulerServiceThread(std::unique_ptr<SchedulerWorkerThread> worker_thread); | 40 SchedulerServiceThread(std::unique_ptr<SchedulerWorker> worker); |
41 | 41 |
42 const std::unique_ptr<SchedulerWorkerThread> worker_thread_; | 42 const std::unique_ptr<SchedulerWorker> worker_; |
43 | 43 |
44 DISALLOW_COPY_AND_ASSIGN(SchedulerServiceThread); | 44 DISALLOW_COPY_AND_ASSIGN(SchedulerServiceThread); |
45 }; | 45 }; |
46 | 46 |
47 } // namespace internal | 47 } // namespace internal |
48 } // namespace base | 48 } // namespace base |
49 | 49 |
50 #endif // BASE_TASK_SCHEDULER_SERVICE_THREAD_H_ | 50 #endif // BASE_TASK_SCHEDULER_SERVICE_THREAD_H_ |
OLD | NEW |