| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_CHROME_THREAD_H_ | 5 #ifndef CHROME_BROWSER_CHROME_THREAD_H_ |
| 6 #define CHROME_BROWSER_CHROME_THREAD_H_ | 6 #define CHROME_BROWSER_CHROME_THREAD_H_ |
| 7 | 7 |
| 8 #include "base/lock.h" | 8 #include "base/lock.h" |
| 9 #include "base/task.h" | 9 #include "base/task.h" |
| 10 #include "base/thread.h" | 10 #include "base/thread.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 | 108 |
| 109 template <class T> | 109 template <class T> |
| 110 static bool ReleaseSoon(ID identifier, | 110 static bool ReleaseSoon(ID identifier, |
| 111 const tracked_objects::Location& from_here, | 111 const tracked_objects::Location& from_here, |
| 112 T* object) { | 112 T* object) { |
| 113 return PostNonNestableTask( | 113 return PostNonNestableTask( |
| 114 identifier, from_here, new ReleaseTask<T>(object)); | 114 identifier, from_here, new ReleaseTask<T>(object)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 // Callable on any thread. Returns whether the given ID corresponds to a well |
| 118 // known thread. |
| 119 static bool IsWellKnownThread(ID identifier); |
| 120 |
| 117 // Callable on any thread. Returns whether you're currently on a particular | 121 // Callable on any thread. Returns whether you're currently on a particular |
| 118 // thread. | 122 // thread. |
| 119 static bool CurrentlyOn(ID identifier); | 123 static bool CurrentlyOn(ID identifier); |
| 120 | 124 |
| 121 // If the current message loop is one of the known threads, returns true and | 125 // If the current message loop is one of the known threads, returns true and |
| 122 // sets identifier to its ID. Otherwise returns false. | 126 // sets identifier to its ID. Otherwise returns false. |
| 123 static bool GetCurrentThreadIdentifier(ID* identifier); | 127 static bool GetCurrentThreadIdentifier(ID* identifier); |
| 124 | 128 |
| 125 // Use these templates in conjuction with RefCountedThreadSafe when you want | 129 // Use these templates in conjuction with RefCountedThreadSafe when you want |
| 126 // to ensure that an object is deleted on a specific thread. This is needed | 130 // to ensure that an object is deleted on a specific thread. This is needed |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 static Lock lock_; | 182 static Lock lock_; |
| 179 | 183 |
| 180 // An array of the ChromeThread objects. This array is protected by |lock_|. | 184 // An array of the ChromeThread objects. This array is protected by |lock_|. |
| 181 // The threads are not owned by this array. Typically, the threads are owned | 185 // The threads are not owned by this array. Typically, the threads are owned |
| 182 // on the UI thread by the g_browser_process object. ChromeThreads remove | 186 // on the UI thread by the g_browser_process object. ChromeThreads remove |
| 183 // themselves from this array upon destruction. | 187 // themselves from this array upon destruction. |
| 184 static ChromeThread* chrome_threads_[ID_COUNT]; | 188 static ChromeThread* chrome_threads_[ID_COUNT]; |
| 185 }; | 189 }; |
| 186 | 190 |
| 187 #endif // CHROME_BROWSER_CHROME_THREAD_H_ | 191 #endif // CHROME_BROWSER_CHROME_THREAD_H_ |
| OLD | NEW |