| 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 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 std::move(task), std::move(reply)); | 132 std::move(task), std::move(reply)); |
| 133 } | 133 } |
| 134 | 134 |
| 135 template <class T> | 135 template <class T> |
| 136 static bool DeleteSoon(ID identifier, | 136 static bool DeleteSoon(ID identifier, |
| 137 const tracked_objects::Location& from_here, | 137 const tracked_objects::Location& from_here, |
| 138 const T* object) { | 138 const T* object) { |
| 139 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object); | 139 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object); |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Simplified wrappers for posting to the blocking thread pool. Use this | |
| 143 // for doing things like blocking I/O. | |
| 144 // | |
| 145 // The first variant will run the task in the pool with no sequencing | |
| 146 // semantics, so may get run in parallel with other posted tasks. The second | |
| 147 // variant will all post a task with no sequencing semantics, and will post a | |
| 148 // reply task to the origin TaskRunner upon completion. The third variant | |
| 149 // provides sequencing between tasks with the same sequence token name. | |
| 150 // | |
| 151 // These tasks are guaranteed to run before shutdown. | |
| 152 // | |
| 153 // If you need to provide different shutdown semantics (like you have | |
| 154 // something slow and noncritical that doesn't need to block shutdown), | |
| 155 // or you want to manually provide a sequence token (which saves a map | |
| 156 // lookup and is guaranteed unique without you having to come up with a | |
| 157 // unique string), you can access the sequenced worker pool directly via | |
| 158 // GetBlockingPool(). | |
| 159 // | |
| 160 // If you need to PostTaskAndReplyWithResult, use | |
| 161 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task | |
| 162 // runner. | |
| 163 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here, | |
| 164 base::OnceClosure task); | |
| 165 static bool PostBlockingPoolTaskAndReply( | |
| 166 const tracked_objects::Location& from_here, | |
| 167 base::OnceClosure task, | |
| 168 base::OnceClosure reply); | |
| 169 static bool PostBlockingPoolSequencedTask( | |
| 170 const std::string& sequence_token_name, | |
| 171 const tracked_objects::Location& from_here, | |
| 172 base::OnceClosure task); | |
| 173 | |
| 174 // Returns the thread pool used for blocking file I/O. Use this object to | 142 // Returns the thread pool used for blocking file I/O. Use this object to |
| 175 // perform random blocking operations such as file writes. | 143 // perform random blocking operations such as file writes. |
| 176 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT; | 144 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT; |
| 177 | 145 |
| 178 // Callable on any thread. Returns whether the given well-known thread is | 146 // Callable on any thread. Returns whether the given well-known thread is |
| 179 // initialized. | 147 // initialized. |
| 180 static bool IsThreadInitialized(ID identifier) WARN_UNUSED_RESULT; | 148 static bool IsThreadInitialized(ID identifier) WARN_UNUSED_RESULT; |
| 181 | 149 |
| 182 // Callable on any thread. Returns whether execution is currently on the | 150 // Callable on any thread. Returns whether execution is currently on the |
| 183 // given thread. To DCHECK this, use the DCHECK_CURRENTLY_ON() macro above. | 151 // given thread. To DCHECK this, use the DCHECK_CURRENTLY_ON() macro above. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 private: | 228 private: |
| 261 friend class WebThreadImpl; | 229 friend class WebThreadImpl; |
| 262 | 230 |
| 263 WebThread() {} | 231 WebThread() {} |
| 264 DISALLOW_COPY_AND_ASSIGN(WebThread); | 232 DISALLOW_COPY_AND_ASSIGN(WebThread); |
| 265 }; | 233 }; |
| 266 | 234 |
| 267 } // namespace web | 235 } // namespace web |
| 268 | 236 |
| 269 #endif // IOS_WEB_PUBLIC_WEB_THREAD_H_ | 237 #endif // IOS_WEB_PUBLIC_WEB_THREAD_H_ |
| OLD | NEW |