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_TASK_TRACKER_H_ | 5 #ifndef BASE_TASK_SCHEDULER_TASK_TRACKER_H_ |
6 #define BASE_TASK_SCHEDULER_TASK_TRACKER_H_ | 6 #define BASE_TASK_SCHEDULER_TASK_TRACKER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
37 void Shutdown(); | 37 void Shutdown(); |
38 | 38 |
39 // Informs this TaskTracker that |task| is about to be posted. Returns true if | 39 // Informs this TaskTracker that |task| is about to be posted. Returns true if |
40 // this operation is allowed (|task| should be posted if-and-only-if it is). | 40 // this operation is allowed (|task| should be posted if-and-only-if it is). |
41 bool WillPostTask(const Task* task); | 41 bool WillPostTask(const Task* task); |
42 | 42 |
43 // Runs |task| unless the current shutdown state prevents that. WillPostTask() | 43 // Runs |task| unless the current shutdown state prevents that. WillPostTask() |
44 // must have allowed |task| to be posted. | 44 // must have allowed |task| to be posted. |
45 void RunTask(const Task* task); | 45 void RunTask(const Task* task); |
46 | 46 |
47 // Returns true if shutdown has completed. | 47 // Returns true once shutdown has started (Shutdown() has been called but |
48 // might not have returned). | |
49 bool HasShutdownStarted() const; | |
50 | |
51 // Returns true if shutdown has completed (Shutdown() has returned). | |
48 bool IsShutdownComplete() const; | 52 bool IsShutdownComplete() const; |
49 | 53 |
50 // Returns true while shutdown is in progress (i.e. Shutdown() has been called | 54 // Causes HasShutdownStarted() to return true. Contrary to Shutdown(), |
robliao
2016/07/20 22:31:48
Nit: s/Contrary to Shutdown()/Unlike Shutdown()/
fdoray
2016/07/21 13:21:56
Done.
| |
51 // but hasn't returned). | 55 // IsShutdownComplete() won't return true after this returns. Shutdown() |
52 bool IsShuttingDownForTesting() const; | 56 // cannot be called after this. |
57 void SetHasShutdownStartedForTesting(); | |
53 | 58 |
54 private: | 59 private: |
55 class State; | 60 class State; |
56 | 61 |
57 // Called before WillPostTask() informs the tracing system that a task has | 62 // Called before WillPostTask() informs the tracing system that a task has |
58 // been posted. Updates |num_tasks_blocking_shutdown_| if necessary and | 63 // been posted. Updates |num_tasks_blocking_shutdown_| if necessary and |
59 // returns true if the current shutdown state allows the task to be posted. | 64 // returns true if the current shutdown state allows the task to be posted. |
60 bool BeforePostTask(TaskShutdownBehavior shutdown_behavior); | 65 bool BeforePostTask(TaskShutdownBehavior shutdown_behavior); |
61 | 66 |
62 // Called before a task with |shutdown_behavior| is run by RunTask(). Updates | 67 // Called before a task with |shutdown_behavior| is run by RunTask(). Updates |
(...skipping 24 matching lines...) Expand all Loading... | |
87 // Number of BLOCK_SHUTDOWN tasks posted during shutdown. | 92 // Number of BLOCK_SHUTDOWN tasks posted during shutdown. |
88 HistogramBase::Sample num_block_shutdown_tasks_posted_during_shutdown_ = 0; | 93 HistogramBase::Sample num_block_shutdown_tasks_posted_during_shutdown_ = 0; |
89 | 94 |
90 DISALLOW_COPY_AND_ASSIGN(TaskTracker); | 95 DISALLOW_COPY_AND_ASSIGN(TaskTracker); |
91 }; | 96 }; |
92 | 97 |
93 } // namespace internal | 98 } // namespace internal |
94 } // namespace base | 99 } // namespace base |
95 | 100 |
96 #endif // BASE_TASK_SCHEDULER_TASK_TRACKER_H_ | 101 #endif // BASE_TASK_SCHEDULER_TASK_TRACKER_H_ |
OLD | NEW |