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 CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ |
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ | 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
| 9 #include <utility> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/location.h" | 12 #include "base/location.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "base/task_runner_util.h" | 17 #include "base/task_runner_util.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 base::TimeDelta delay); | 113 base::TimeDelta delay); |
113 static bool PostNonNestableTask(ID identifier, | 114 static bool PostNonNestableTask(ID identifier, |
114 const tracked_objects::Location& from_here, | 115 const tracked_objects::Location& from_here, |
115 const base::Closure& task); | 116 const base::Closure& task); |
116 static bool PostNonNestableDelayedTask( | 117 static bool PostNonNestableDelayedTask( |
117 ID identifier, | 118 ID identifier, |
118 const tracked_objects::Location& from_here, | 119 const tracked_objects::Location& from_here, |
119 const base::Closure& task, | 120 const base::Closure& task, |
120 base::TimeDelta delay); | 121 base::TimeDelta delay); |
121 | 122 |
122 static bool PostTaskAndReply( | 123 static bool PostTaskAndReply(ID identifier, |
123 ID identifier, | 124 const tracked_objects::Location& from_here, |
124 const tracked_objects::Location& from_here, | 125 base::Closure task, |
125 const base::Closure& task, | 126 base::Closure reply); |
126 const base::Closure& reply); | |
127 | 127 |
128 template <typename ReturnType, typename ReplyArgType> | 128 template <typename ReturnType, typename ReplyArgType> |
129 static bool PostTaskAndReplyWithResult( | 129 static bool PostTaskAndReplyWithResult( |
130 ID identifier, | 130 ID identifier, |
131 const tracked_objects::Location& from_here, | 131 const tracked_objects::Location& from_here, |
132 const base::Callback<ReturnType(void)>& task, | 132 base::Callback<ReturnType()> task, |
133 const base::Callback<void(ReplyArgType)>& reply) { | 133 base::Callback<void(ReplyArgType)> reply) { |
134 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 134 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
135 GetTaskRunnerForThread(identifier); | 135 GetTaskRunnerForThread(identifier); |
136 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, task, | 136 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, |
137 reply); | 137 std::move(task), std::move(reply)); |
138 } | 138 } |
139 | 139 |
140 template <class T> | 140 template <class T> |
141 static bool DeleteSoon(ID identifier, | 141 static bool DeleteSoon(ID identifier, |
142 const tracked_objects::Location& from_here, | 142 const tracked_objects::Location& from_here, |
143 const T* object) { | 143 const T* object) { |
144 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object); | 144 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object); |
145 } | 145 } |
146 | 146 |
147 template <class T> | 147 template <class T> |
(...skipping 21 matching lines...) Expand all Loading... |
169 // unique string), you can access the sequenced worker pool directly via | 169 // unique string), you can access the sequenced worker pool directly via |
170 // GetBlockingPool(). | 170 // GetBlockingPool(). |
171 // | 171 // |
172 // If you need to PostTaskAndReplyWithResult, use | 172 // If you need to PostTaskAndReplyWithResult, use |
173 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task | 173 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task |
174 // runner. | 174 // runner. |
175 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here, | 175 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here, |
176 const base::Closure& task); | 176 const base::Closure& task); |
177 static bool PostBlockingPoolTaskAndReply( | 177 static bool PostBlockingPoolTaskAndReply( |
178 const tracked_objects::Location& from_here, | 178 const tracked_objects::Location& from_here, |
179 const base::Closure& task, | 179 base::Closure task, |
180 const base::Closure& reply); | 180 base::Closure reply); |
181 static bool PostBlockingPoolSequencedTask( | 181 static bool PostBlockingPoolSequencedTask( |
182 const std::string& sequence_token_name, | 182 const std::string& sequence_token_name, |
183 const tracked_objects::Location& from_here, | 183 const tracked_objects::Location& from_here, |
184 const base::Closure& task); | 184 const base::Closure& task); |
185 | 185 |
186 // For use with scheduling non-critical tasks for execution after startup. | 186 // For use with scheduling non-critical tasks for execution after startup. |
187 // The order or execution of tasks posted here is unspecified even when | 187 // The order or execution of tasks posted here is unspecified even when |
188 // posting to a SequencedTaskRunner and tasks are not guaranteed to be run | 188 // posting to a SequencedTaskRunner and tasks are not guaranteed to be run |
189 // prior to browser shutdown. | 189 // prior to browser shutdown. |
190 // When called after the browser startup is complete, will post |task| | 190 // When called after the browser startup is complete, will post |task| |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 private: | 292 private: |
293 friend class BrowserThreadImpl; | 293 friend class BrowserThreadImpl; |
294 | 294 |
295 BrowserThread() {} | 295 BrowserThread() {} |
296 DISALLOW_COPY_AND_ASSIGN(BrowserThread); | 296 DISALLOW_COPY_AND_ASSIGN(BrowserThread); |
297 }; | 297 }; |
298 | 298 |
299 } // namespace content | 299 } // namespace content |
300 | 300 |
301 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ | 301 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ |
OLD | NEW |