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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 ID_COUNT | 99 ID_COUNT |
100 }; | 100 }; |
101 | 101 |
102 // These are the same methods in message_loop.h, but are guaranteed to either | 102 // These are the same methods in message_loop.h, but are guaranteed to either |
103 // get posted to the MessageLoop if it's still alive, or be deleted otherwise. | 103 // get posted to the MessageLoop if it's still alive, or be deleted otherwise. |
104 // They return true iff the thread existed and the task was posted. Note that | 104 // They return true iff the thread existed and the task was posted. Note that |
105 // even if the task is posted, there's no guarantee that it will run, since | 105 // even if the task is posted, there's no guarantee that it will run, since |
106 // the target thread may already have a Quit message in its queue. | 106 // the target thread may already have a Quit message in its queue. |
107 static bool PostTask(ID identifier, | 107 static bool PostTask(ID identifier, |
108 const tracked_objects::Location& from_here, | 108 const tracked_objects::Location& from_here, |
109 const base::Closure& task); | 109 base::Closure task); |
110 static bool PostDelayedTask(ID identifier, | 110 static bool PostDelayedTask(ID identifier, |
111 const tracked_objects::Location& from_here, | 111 const tracked_objects::Location& from_here, |
112 const base::Closure& task, | 112 base::Closure task, |
113 base::TimeDelta delay); | 113 base::TimeDelta delay); |
114 static bool PostNonNestableTask(ID identifier, | 114 static bool PostNonNestableTask(ID identifier, |
115 const tracked_objects::Location& from_here, | 115 const tracked_objects::Location& from_here, |
116 const base::Closure& task); | 116 base::Closure task); |
117 static bool PostNonNestableDelayedTask( | 117 static bool PostNonNestableDelayedTask( |
118 ID identifier, | 118 ID identifier, |
119 const tracked_objects::Location& from_here, | 119 const tracked_objects::Location& from_here, |
120 const base::Closure& task, | 120 base::Closure task, |
121 base::TimeDelta delay); | 121 base::TimeDelta delay); |
122 | 122 |
123 static bool PostTaskAndReply(ID identifier, | 123 static bool PostTaskAndReply(ID identifier, |
124 const tracked_objects::Location& from_here, | 124 const tracked_objects::Location& from_here, |
125 base::Closure task, | 125 base::Closure task, |
126 base::Closure reply); | 126 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, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // something slow and noncritical that doesn't need to block shutdown), | 166 // something slow and noncritical that doesn't need to block shutdown), |
167 // or you want to manually provide a sequence token (which saves a map | 167 // or you want to manually provide a sequence token (which saves a map |
168 // lookup and is guaranteed unique without you having to come up with a | 168 // lookup and is guaranteed unique without you having to come up with a |
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 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 base::Closure task, | 179 base::Closure task, |
180 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 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| |
191 // to |task_runner| immediately. | 191 // to |task_runner| immediately. |
192 // Note: see related ContentBrowserClient::PostAfterStartupTask. | 192 // Note: see related ContentBrowserClient::PostAfterStartupTask. |
193 static void PostAfterStartupTask( | 193 static void PostAfterStartupTask( |
194 const tracked_objects::Location& from_here, | 194 const tracked_objects::Location& from_here, |
195 const scoped_refptr<base::TaskRunner>& task_runner, | 195 const scoped_refptr<base::TaskRunner>& task_runner, |
196 const base::Closure& task); | 196 base::Closure task); |
197 | 197 |
198 // Returns the thread pool used for blocking file I/O. Use this object to | 198 // Returns the thread pool used for blocking file I/O. Use this object to |
199 // perform random blocking operations such as file writes or querying the | 199 // perform random blocking operations such as file writes or querying the |
200 // Windows registry. | 200 // Windows registry. |
201 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT; | 201 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT; |
202 | 202 |
203 // Callable on any thread. Returns whether the given well-known thread is | 203 // Callable on any thread. Returns whether the given well-known thread is |
204 // initialized. | 204 // initialized. |
205 static bool IsThreadInitialized(ID identifier) WARN_UNUSED_RESULT; | 205 static bool IsThreadInitialized(ID identifier) WARN_UNUSED_RESULT; |
206 | 206 |
(...skipping 85 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 |