| 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 #include <utility> |
| 10 | 10 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object); | 175 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object); |
| 176 } | 176 } |
| 177 | 177 |
| 178 template <class T> | 178 template <class T> |
| 179 static bool ReleaseSoon(ID identifier, | 179 static bool ReleaseSoon(ID identifier, |
| 180 const tracked_objects::Location& from_here, | 180 const tracked_objects::Location& from_here, |
| 181 const T* object) { | 181 const T* object) { |
| 182 return GetTaskRunnerForThread(identifier)->ReleaseSoon(from_here, object); | 182 return GetTaskRunnerForThread(identifier)->ReleaseSoon(from_here, object); |
| 183 } | 183 } |
| 184 | 184 |
| 185 // Simplified wrappers for posting to the blocking thread pool. Use this | |
| 186 // for doing things like blocking I/O. | |
| 187 // | |
| 188 // DEPRECATED: use base/task_scheduler/post_task.h instead. | 185 // DEPRECATED: use base/task_scheduler/post_task.h instead. |
| 189 // * BrowserThread::PostBlockingPoolTask(AndReply)(...) => | |
| 190 // base::PostTaskWithTraits(AndReply)( | |
| 191 // FROM_HERE, base::TaskTraits().MayBlock()...) | |
| 192 // * BrowserThread::PostBlockingPoolSequencedTask => | 186 // * BrowserThread::PostBlockingPoolSequencedTask => |
| 193 // Share a single SequencedTaskRunner created via | 187 // Share a single SequencedTaskRunner created via |
| 194 // base::CreateSequencedTaskRunnerWithTraits() instead of sharing a | 188 // base::CreateSequencedTaskRunnerWithTraits() instead of sharing a |
| 195 // SequenceToken (ping base/task_scheduler/OWNERS if you find a use | 189 // SequenceToken (ping base/task_scheduler/OWNERS if you find a use |
| 196 // case where that's not possible). | 190 // case where that's not possible). |
| 197 // | 191 // |
| 198 // The first variant will run the task in the pool with no sequencing | 192 // Posts a task to the blocking pool. The task is guaranteed to run before |
| 199 // semantics, so may get run in parallel with other posted tasks. The second | 193 // shutdown. Tasks posted with the same sequence token name are sequenced. |
| 200 // variant will all post a task with no sequencing semantics, and will post a | |
| 201 // reply task to the origin TaskRunner upon completion. The third variant | |
| 202 // provides sequencing between tasks with the same sequence token name. | |
| 203 // | |
| 204 // These tasks are guaranteed to run before shutdown. | |
| 205 // | 194 // |
| 206 // If you need to provide different shutdown semantics (like you have | 195 // If you need to provide different shutdown semantics (like you have |
| 207 // something slow and noncritical that doesn't need to block shutdown), | 196 // something slow and noncritical that doesn't need to block shutdown), |
| 208 // or you want to manually provide a sequence token (which saves a map | 197 // or you want to manually provide a sequence token (which saves a map |
| 209 // lookup and is guaranteed unique without you having to come up with a | 198 // lookup and is guaranteed unique without you having to come up with a |
| 210 // unique string), you can access the sequenced worker pool directly via | 199 // unique string), you can access the sequenced worker pool directly via |
| 211 // GetBlockingPool(). | 200 // GetBlockingPool(). |
| 212 // | |
| 213 // If you need to PostTaskAndReplyWithResult, use | |
| 214 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task | |
| 215 // runner. | |
| 216 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here, | |
| 217 base::OnceClosure task); | |
| 218 static bool PostBlockingPoolTaskAndReply( | |
| 219 const tracked_objects::Location& from_here, | |
| 220 base::OnceClosure task, | |
| 221 base::OnceClosure reply); | |
| 222 static bool PostBlockingPoolSequencedTask( | 201 static bool PostBlockingPoolSequencedTask( |
| 223 const std::string& sequence_token_name, | 202 const std::string& sequence_token_name, |
| 224 const tracked_objects::Location& from_here, | 203 const tracked_objects::Location& from_here, |
| 225 base::OnceClosure task); | 204 base::OnceClosure task); |
| 226 | 205 |
| 227 // For use with scheduling non-critical tasks for execution after startup. | 206 // For use with scheduling non-critical tasks for execution after startup. |
| 228 // The order or execution of tasks posted here is unspecified even when | 207 // The order or execution of tasks posted here is unspecified even when |
| 229 // posting to a SequencedTaskRunner and tasks are not guaranteed to be run | 208 // posting to a SequencedTaskRunner and tasks are not guaranteed to be run |
| 230 // prior to browser shutdown. | 209 // prior to browser shutdown. |
| 231 // When called after the browser startup is complete, will post |task| | 210 // When called after the browser startup is complete, will post |task| |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 private: | 319 private: |
| 341 friend class BrowserThreadImpl; | 320 friend class BrowserThreadImpl; |
| 342 | 321 |
| 343 BrowserThread() {} | 322 BrowserThread() {} |
| 344 DISALLOW_COPY_AND_ASSIGN(BrowserThread); | 323 DISALLOW_COPY_AND_ASSIGN(BrowserThread); |
| 345 }; | 324 }; |
| 346 | 325 |
| 347 } // namespace content | 326 } // namespace content |
| 348 | 327 |
| 349 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ | 328 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ |
| OLD | NEW |