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 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 215 |
216 // If the current message loop is one of the known threads, returns true and | 216 // If the current message loop is one of the known threads, returns true and |
217 // sets identifier to its ID. Otherwise returns false. | 217 // sets identifier to its ID. Otherwise returns false. |
218 static bool GetCurrentThreadIdentifier(ID* identifier) WARN_UNUSED_RESULT; | 218 static bool GetCurrentThreadIdentifier(ID* identifier) WARN_UNUSED_RESULT; |
219 | 219 |
220 // Callers can hold on to a refcounted task runner beyond the lifetime | 220 // Callers can hold on to a refcounted task runner beyond the lifetime |
221 // of the thread. | 221 // of the thread. |
222 static scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunnerForThread( | 222 static scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunnerForThread( |
223 ID identifier); | 223 ID identifier); |
224 | 224 |
225 // Returns a pointer to the thread's message loop, which will become | |
226 // invalid during shutdown, so you probably shouldn't hold onto it. | |
227 // | |
228 // This must not be called before the thread is started, or after | |
229 // the thread is stopped, or it will DCHECK. | |
230 // | |
231 // Ownership remains with the BrowserThread implementation, so you | |
232 // must not delete the pointer. | |
233 static base::MessageLoop* UnsafeGetMessageLoopForThread(ID identifier); | |
234 | |
235 // Sets the delegate for the specified BrowserThread. | 225 // Sets the delegate for the specified BrowserThread. |
236 // | 226 // |
237 // Only one delegate may be registered at a time. Delegates may be | 227 // Only one delegate may be registered at a time. Delegates may be |
238 // unregistered by providing a nullptr pointer. | 228 // unregistered by providing a nullptr pointer. |
239 // | 229 // |
240 // If the caller unregisters a delegate before CleanUp has been | 230 // If the caller unregisters a delegate before CleanUp has been |
241 // called, it must perform its own locking to ensure the delegate is | 231 // called, it must perform its own locking to ensure the delegate is |
242 // not deleted while unregistering. | 232 // not deleted while unregistering. |
243 static void SetDelegate(ID identifier, BrowserThreadDelegate* delegate); | 233 static void SetDelegate(ID identifier, BrowserThreadDelegate* delegate); |
244 | 234 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 private: | 288 private: |
299 friend class BrowserThreadImpl; | 289 friend class BrowserThreadImpl; |
300 | 290 |
301 BrowserThread() {} | 291 BrowserThread() {} |
302 DISALLOW_COPY_AND_ASSIGN(BrowserThread); | 292 DISALLOW_COPY_AND_ASSIGN(BrowserThread); |
303 }; | 293 }; |
304 | 294 |
305 } // namespace content | 295 } // namespace content |
306 | 296 |
307 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ | 297 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ |
OLD | NEW |