| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 IOS_WEB_PUBLIC_WEB_THREAD_H_ | 5 #ifndef IOS_WEB_PUBLIC_WEB_THREAD_H_ |
| 6 #define IOS_WEB_PUBLIC_WEB_THREAD_H_ | 6 #define IOS_WEB_PUBLIC_WEB_THREAD_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // identifier. | 91 // identifier. |
| 92 ID_COUNT | 92 ID_COUNT |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 // These are the same methods as in message_loop.h, but are guaranteed to | 95 // These are the same methods as in message_loop.h, but are guaranteed to |
| 96 // either get posted to the MessageLoop if it's still alive, or be deleted | 96 // either get posted to the MessageLoop if it's still alive, or be deleted |
| 97 // otherwise. | 97 // otherwise. |
| 98 // They return true iff the thread existed and the task was posted. | 98 // They return true iff the thread existed and the task was posted. |
| 99 static bool PostTask(ID identifier, | 99 static bool PostTask(ID identifier, |
| 100 const tracked_objects::Location& from_here, | 100 const tracked_objects::Location& from_here, |
| 101 const base::Closure& task); | 101 base::OnceClosure task); |
| 102 static bool PostDelayedTask(ID identifier, | 102 static bool PostDelayedTask(ID identifier, |
| 103 const tracked_objects::Location& from_here, | 103 const tracked_objects::Location& from_here, |
| 104 const base::Closure& task, | 104 base::OnceClosure task, |
| 105 base::TimeDelta delay); | 105 base::TimeDelta delay); |
| 106 static bool PostNonNestableTask(ID identifier, | 106 static bool PostNonNestableTask(ID identifier, |
| 107 const tracked_objects::Location& from_here, | 107 const tracked_objects::Location& from_here, |
| 108 const base::Closure& task); | 108 base::OnceClosure task); |
| 109 static bool PostNonNestableDelayedTask( | 109 static bool PostNonNestableDelayedTask( |
| 110 ID identifier, | 110 ID identifier, |
| 111 const tracked_objects::Location& from_here, | 111 const tracked_objects::Location& from_here, |
| 112 const base::Closure& task, | 112 base::OnceClosure task, |
| 113 base::TimeDelta delay); | 113 base::TimeDelta delay); |
| 114 | 114 |
| 115 static bool PostTaskAndReply(ID identifier, | 115 static bool PostTaskAndReply(ID identifier, |
| 116 const tracked_objects::Location& from_here, | 116 const tracked_objects::Location& from_here, |
| 117 const base::Closure& task, | 117 base::OnceClosure task, |
| 118 const base::Closure& reply); | 118 base::OnceClosure reply); |
| 119 | 119 |
| 120 template <typename ReturnType, typename ReplyArgType> | 120 template <typename ReturnType, typename ReplyArgType> |
| 121 static bool PostTaskAndReplyWithResult( | 121 static bool PostTaskAndReplyWithResult( |
| 122 ID identifier, | 122 ID identifier, |
| 123 const tracked_objects::Location& from_here, | 123 const tracked_objects::Location& from_here, |
| 124 const base::Callback<ReturnType(void)>& task, | 124 const base::Callback<ReturnType(void)>& task, |
| 125 const base::Callback<void(ReplyArgType)>& reply) { | 125 const base::Callback<void(ReplyArgType)>& reply) { |
| 126 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 126 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 127 GetTaskRunnerForThread(identifier); | 127 GetTaskRunnerForThread(identifier); |
| 128 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, task, | 128 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, task, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 151 // something slow and noncritical that doesn't need to block shutdown), | 151 // something slow and noncritical that doesn't need to block shutdown), |
| 152 // or you want to manually provide a sequence token (which saves a map | 152 // or you want to manually provide a sequence token (which saves a map |
| 153 // lookup and is guaranteed unique without you having to come up with a | 153 // lookup and is guaranteed unique without you having to come up with a |
| 154 // unique string), you can access the sequenced worker pool directly via | 154 // unique string), you can access the sequenced worker pool directly via |
| 155 // GetBlockingPool(). | 155 // GetBlockingPool(). |
| 156 // | 156 // |
| 157 // If you need to PostTaskAndReplyWithResult, use | 157 // If you need to PostTaskAndReplyWithResult, use |
| 158 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task | 158 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task |
| 159 // runner. | 159 // runner. |
| 160 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here, | 160 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here, |
| 161 const base::Closure& task); | 161 base::OnceClosure task); |
| 162 static bool PostBlockingPoolTaskAndReply( | 162 static bool PostBlockingPoolTaskAndReply( |
| 163 const tracked_objects::Location& from_here, | 163 const tracked_objects::Location& from_here, |
| 164 const base::Closure& task, | 164 base::OnceClosure task, |
| 165 const base::Closure& reply); | 165 base::OnceClosure reply); |
| 166 static bool PostBlockingPoolSequencedTask( | 166 static bool PostBlockingPoolSequencedTask( |
| 167 const std::string& sequence_token_name, | 167 const std::string& sequence_token_name, |
| 168 const tracked_objects::Location& from_here, | 168 const tracked_objects::Location& from_here, |
| 169 const base::Closure& task); | 169 base::OnceClosure task); |
| 170 | 170 |
| 171 // Returns the thread pool used for blocking file I/O. Use this object to | 171 // Returns the thread pool used for blocking file I/O. Use this object to |
| 172 // perform random blocking operations such as file writes. | 172 // perform random blocking operations such as file writes. |
| 173 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT; | 173 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT; |
| 174 | 174 |
| 175 // Returns a pointer to the thread's message loop, which will become | 175 // Returns a pointer to the thread's message loop, which will become |
| 176 // invalid during shutdown, so you probably shouldn't hold onto it. | 176 // invalid during shutdown, so you probably shouldn't hold onto it. |
| 177 // | 177 // |
| 178 // This must not be called before the thread is started, or after | 178 // This must not be called before the thread is started, or after |
| 179 // the thread is stopped, or it will DCHECK. | 179 // the thread is stopped, or it will DCHECK. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 private: | 267 private: |
| 268 friend class WebThreadImpl; | 268 friend class WebThreadImpl; |
| 269 | 269 |
| 270 WebThread() {} | 270 WebThread() {} |
| 271 DISALLOW_COPY_AND_ASSIGN(WebThread); | 271 DISALLOW_COPY_AND_ASSIGN(WebThread); |
| 272 }; | 272 }; |
| 273 | 273 |
| 274 } // namespace web | 274 } // namespace web |
| 275 | 275 |
| 276 #endif // IOS_WEB_PUBLIC_WEB_THREAD_H_ | 276 #endif // IOS_WEB_PUBLIC_WEB_THREAD_H_ |
| OLD | NEW |