OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_RUNNER_H_ | 5 #ifndef BASE_TASK_RUNNER_H_ |
6 #define BASE_TASK_RUNNER_H_ | 6 #define BASE_TASK_RUNNER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/base_export.h" | 9 #include "base/base_export.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/time.h" |
13 | 14 |
14 namespace tracked_objects { | 15 namespace tracked_objects { |
15 class Location; | 16 class Location; |
16 } // namespace tracked_objects | 17 } // namespace tracked_objects |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 | 20 |
20 struct TaskRunnerTraits; | 21 struct TaskRunnerTraits; |
21 | 22 |
22 // A TaskRunner is an object that runs posted tasks (in the form of | 23 // A TaskRunner is an object that runs posted tasks (in the form of |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // Equivalent to PostDelayedTask(from_here, task, 0). | 66 // Equivalent to PostDelayedTask(from_here, task, 0). |
66 bool PostTask(const tracked_objects::Location& from_here, | 67 bool PostTask(const tracked_objects::Location& from_here, |
67 const Closure& task); | 68 const Closure& task); |
68 | 69 |
69 // Like PostTask, but tries to run the posted task only after | 70 // Like PostTask, but tries to run the posted task only after |
70 // |delay_ms| has passed. | 71 // |delay_ms| has passed. |
71 // | 72 // |
72 // It is valid for an implementation to ignore |delay_ms|; that is, | 73 // It is valid for an implementation to ignore |delay_ms|; that is, |
73 // to have PostDelayedTask behave the same as PostTask. | 74 // to have PostDelayedTask behave the same as PostTask. |
74 // | 75 // |
75 // TODO(akalin): Make PostDelayedTask use TimeDelta instead. | 76 // TODO(tedv): Make PostDelayedTask use TimeDelta instead. |
76 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 77 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
77 const Closure& task, | 78 const Closure& task, |
78 int64 delay_ms) = 0; | 79 int64 delay_ms) = 0; |
| 80 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 81 const Closure& task, |
| 82 base::TimeDelta delay) = 0; |
79 | 83 |
80 // Returns true if the current thread is a thread on which a task | 84 // Returns true if the current thread is a thread on which a task |
81 // may be run, and false if no task will be run on the current | 85 // may be run, and false if no task will be run on the current |
82 // thread. | 86 // thread. |
83 // | 87 // |
84 // It is valid for an implementation to always return true, or in | 88 // It is valid for an implementation to always return true, or in |
85 // general to use 'true' as a default value. | 89 // general to use 'true' as a default value. |
86 virtual bool RunsTasksOnCurrentThread() const = 0; | 90 virtual bool RunsTasksOnCurrentThread() const = 0; |
87 | 91 |
88 // Posts |task| on the current TaskRunner. On completion, |reply| | 92 // Posts |task| on the current TaskRunner. On completion, |reply| |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 virtual void OnDestruct() const; | 150 virtual void OnDestruct() const; |
147 }; | 151 }; |
148 | 152 |
149 struct BASE_EXPORT TaskRunnerTraits { | 153 struct BASE_EXPORT TaskRunnerTraits { |
150 static void Destruct(const TaskRunner* task_runner); | 154 static void Destruct(const TaskRunner* task_runner); |
151 }; | 155 }; |
152 | 156 |
153 } // namespace base | 157 } // namespace base |
154 | 158 |
155 #endif // BASE_TASK_RUNNER_H_ | 159 #endif // BASE_TASK_RUNNER_H_ |
OLD | NEW |