| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 ID_COUNT | 109 ID_COUNT |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 // These are the same methods in message_loop.h, but are guaranteed to either | 112 // These are the same methods in message_loop.h, but are guaranteed to either |
| 113 // get posted to the MessageLoop if it's still alive, or be deleted otherwise. | 113 // get posted to the MessageLoop if it's still alive, or be deleted otherwise. |
| 114 // They return true iff the thread existed and the task was posted. Note that | 114 // They return true iff the thread existed and the task was posted. Note that |
| 115 // even if the task is posted, there's no guarantee that it will run, since | 115 // even if the task is posted, there's no guarantee that it will run, since |
| 116 // the target thread may already have a Quit message in its queue. | 116 // the target thread may already have a Quit message in its queue. |
| 117 static bool PostTask(ID identifier, | 117 static bool PostTask(ID identifier, |
| 118 const tracked_objects::Location& from_here, | 118 const tracked_objects::Location& from_here, |
| 119 base::Closure task); | 119 base::OnceClosure task); |
| 120 static bool PostDelayedTask(ID identifier, | 120 static bool PostDelayedTask(ID identifier, |
| 121 const tracked_objects::Location& from_here, | 121 const tracked_objects::Location& from_here, |
| 122 base::Closure task, | 122 base::OnceClosure task, |
| 123 base::TimeDelta delay); | 123 base::TimeDelta delay); |
| 124 static bool PostNonNestableTask(ID identifier, | 124 static bool PostNonNestableTask(ID identifier, |
| 125 const tracked_objects::Location& from_here, | 125 const tracked_objects::Location& from_here, |
| 126 base::Closure task); | 126 base::OnceClosure task); |
| 127 static bool PostNonNestableDelayedTask( | 127 static bool PostNonNestableDelayedTask( |
| 128 ID identifier, | 128 ID identifier, |
| 129 const tracked_objects::Location& from_here, | 129 const tracked_objects::Location& from_here, |
| 130 base::Closure task, | 130 base::OnceClosure task, |
| 131 base::TimeDelta delay); | 131 base::TimeDelta delay); |
| 132 | 132 |
| 133 static bool PostTaskAndReply(ID identifier, | 133 static bool PostTaskAndReply(ID identifier, |
| 134 const tracked_objects::Location& from_here, | 134 const tracked_objects::Location& from_here, |
| 135 base::Closure task, | 135 base::OnceClosure task, |
| 136 base::Closure reply); | 136 base::OnceClosure reply); |
| 137 | 137 |
| 138 template <typename ReturnType, typename ReplyArgType> | 138 template <typename ReturnType, typename ReplyArgType> |
| 139 static bool PostTaskAndReplyWithResult( | 139 static bool PostTaskAndReplyWithResult( |
| 140 ID identifier, | 140 ID identifier, |
| 141 const tracked_objects::Location& from_here, | 141 const tracked_objects::Location& from_here, |
| 142 base::Callback<ReturnType()> task, | 142 base::Callback<ReturnType()> task, |
| 143 base::Callback<void(ReplyArgType)> reply) { | 143 base::Callback<void(ReplyArgType)> reply) { |
| 144 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 144 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 145 GetTaskRunnerForThread(identifier); | 145 GetTaskRunnerForThread(identifier); |
| 146 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, | 146 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // something slow and noncritical that doesn't need to block shutdown), | 186 // something slow and noncritical that doesn't need to block shutdown), |
| 187 // or you want to manually provide a sequence token (which saves a map | 187 // or you want to manually provide a sequence token (which saves a map |
| 188 // lookup and is guaranteed unique without you having to come up with a | 188 // lookup and is guaranteed unique without you having to come up with a |
| 189 // unique string), you can access the sequenced worker pool directly via | 189 // unique string), you can access the sequenced worker pool directly via |
| 190 // GetBlockingPool(). | 190 // GetBlockingPool(). |
| 191 // | 191 // |
| 192 // If you need to PostTaskAndReplyWithResult, use | 192 // If you need to PostTaskAndReplyWithResult, use |
| 193 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task | 193 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task |
| 194 // runner. | 194 // runner. |
| 195 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here, | 195 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here, |
| 196 base::Closure task); | 196 base::OnceClosure task); |
| 197 static bool PostBlockingPoolTaskAndReply( | 197 static bool PostBlockingPoolTaskAndReply( |
| 198 const tracked_objects::Location& from_here, | 198 const tracked_objects::Location& from_here, |
| 199 base::Closure task, | 199 base::OnceClosure task, |
| 200 base::Closure reply); | 200 base::OnceClosure reply); |
| 201 static bool PostBlockingPoolSequencedTask( | 201 static bool PostBlockingPoolSequencedTask( |
| 202 const std::string& sequence_token_name, | 202 const std::string& sequence_token_name, |
| 203 const tracked_objects::Location& from_here, | 203 const tracked_objects::Location& from_here, |
| 204 base::Closure task); | 204 base::OnceClosure task); |
| 205 | 205 |
| 206 // For use with scheduling non-critical tasks for execution after startup. | 206 // For use with scheduling non-critical tasks for execution after startup. |
| 207 // 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 |
| 208 // 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 |
| 209 // prior to browser shutdown. | 209 // prior to browser shutdown. |
| 210 // When called after the browser startup is complete, will post |task| | 210 // When called after the browser startup is complete, will post |task| |
| 211 // to |task_runner| immediately. | 211 // to |task_runner| immediately. |
| 212 // Note: see related ContentBrowserClient::PostAfterStartupTask. | 212 // Note: see related ContentBrowserClient::PostAfterStartupTask. |
| 213 static void PostAfterStartupTask( | 213 static void PostAfterStartupTask( |
| 214 const tracked_objects::Location& from_here, | 214 const tracked_objects::Location& from_here, |
| 215 const scoped_refptr<base::TaskRunner>& task_runner, | 215 const scoped_refptr<base::TaskRunner>& task_runner, |
| 216 base::Closure task); | 216 base::OnceClosure task); |
| 217 | 217 |
| 218 // Returns the thread pool used for blocking file I/O. Use this object to | 218 // Returns the thread pool used for blocking file I/O. Use this object to |
| 219 // perform random blocking operations such as file writes. | 219 // perform random blocking operations such as file writes. |
| 220 // | 220 // |
| 221 // DEPRECATED: use an independent TaskRunner obtained from | 221 // DEPRECATED: use an independent TaskRunner obtained from |
| 222 // base/task_scheduler/post_task.h instead, e.g.: | 222 // base/task_scheduler/post_task.h instead, e.g.: |
| 223 // BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 223 // BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
| 224 // base::SequencedWorkerPool::GetSequenceToken()) | 224 // base::SequencedWorkerPool::GetSequenceToken()) |
| 225 // => | 225 // => |
| 226 // base::CreateSequencedTaskRunnerWithTraits(TaskTraits().MayBlock()...). | 226 // base::CreateSequencedTaskRunnerWithTraits(TaskTraits().MayBlock()...). |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 private: | 318 private: |
| 319 friend class BrowserThreadImpl; | 319 friend class BrowserThreadImpl; |
| 320 | 320 |
| 321 BrowserThread() {} | 321 BrowserThread() {} |
| 322 DISALLOW_COPY_AND_ASSIGN(BrowserThread); | 322 DISALLOW_COPY_AND_ASSIGN(BrowserThread); |
| 323 }; | 323 }; |
| 324 | 324 |
| 325 } // namespace content | 325 } // namespace content |
| 326 | 326 |
| 327 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ | 327 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ |
| OLD | NEW |