OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/task.h" | 11 #include "base/task.h" |
12 #include "base/tracked_objects.h" | 12 #include "base/tracked_objects.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 #include "content/public/browser/browser_thread_delegate.h" | 14 #include "content/public/browser/browser_thread_delegate.h" |
15 | 15 |
16 #if defined(UNIT_TEST) | 16 #if defined(UNIT_TEST) |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #endif // UNIT_TEST | 18 #endif // UNIT_TEST |
19 | 19 |
| 20 class MessageLoop; |
| 21 |
20 namespace base { | 22 namespace base { |
21 class MessageLoopProxy; | 23 class MessageLoopProxy; |
22 class Thread; | 24 class Thread; |
23 } | 25 } |
24 | 26 |
25 namespace content { | 27 namespace content { |
26 | 28 |
27 class BrowserThreadImpl; | 29 class BrowserThreadImpl; |
28 | 30 |
29 /////////////////////////////////////////////////////////////////////////////// | 31 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 ID identifier); | 174 ID identifier); |
173 | 175 |
174 // Gets the Thread object for the specified thread, or NULL if the | 176 // Gets the Thread object for the specified thread, or NULL if the |
175 // thread has not been created (or has been destroyed during | 177 // thread has not been created (or has been destroyed during |
176 // shutdown). | 178 // shutdown). |
177 // | 179 // |
178 // Before calling this, you must have called content::ContentMain | 180 // Before calling this, you must have called content::ContentMain |
179 // with a command-line that would specify a browser process (e.g. an | 181 // with a command-line that would specify a browser process (e.g. an |
180 // empty command line). | 182 // empty command line). |
181 // | 183 // |
182 // This is unsafe as your pointer may become invalid close to | 184 // It is unsafe to store this pointer as it may become invalid close |
183 // shutdown. | 185 // to shutdown. |
184 // | 186 // |
185 // TODO(joi): Remove this once clients such as BrowserProcessImpl | 187 // TODO(joi): Remove this once clients such as BrowserProcessImpl |
186 // (and classes that call things like | 188 // (and classes that call things like |
187 // g_browser_process->file_thread()) are switched to using | 189 // g_browser_process->file_thread()) are switched to using |
188 // MessageLoopProxy. | 190 // MessageLoopProxy. |
189 static base::Thread* UnsafeGetBrowserThread(ID identifier); | 191 static base::Thread* UnsafeGetBrowserThread(ID identifier); |
190 | 192 |
| 193 // Gets the MessageLoop for the specified thread, or NULL if the |
| 194 // thread has not been created (or has been destroyed during |
| 195 // shutdown). |
| 196 // |
| 197 // Before calling this, you must have called content::ContentMain |
| 198 // with a command-line that would specify a browser process (e.g. an |
| 199 // empty command line). |
| 200 // |
| 201 // It is unsafe to store this pointer as it may become invalid close |
| 202 // to shutdown. |
| 203 // |
| 204 // TODO(joi): Remove this once clients such as BrowserProcessImpl |
| 205 // (and classes that call things like |
| 206 // g_browser_process->file_thread()) are switched to using |
| 207 // MessageLoopProxy. |
| 208 static MessageLoop* UnsafeGetMessageLoop(ID identifier); |
| 209 |
191 // Sets the delegate for the specified BrowserThread. | 210 // Sets the delegate for the specified BrowserThread. |
192 // | 211 // |
193 // Only one delegate may be registered at a time. Delegates may be | 212 // Only one delegate may be registered at a time. Delegates may be |
194 // unregistered by providing a NULL pointer. | 213 // unregistered by providing a NULL pointer. |
195 // | 214 // |
196 // If the caller unregisters a delegate before CleanUp has been | 215 // If the caller unregisters a delegate before CleanUp has been |
197 // called, it must perform its own locking to ensure the delegate is | 216 // called, it must perform its own locking to ensure the delegate is |
198 // not deleted while unregistering. | 217 // not deleted while unregistering. |
199 static void SetDelegate(ID identifier, BrowserThreadDelegate* delegate); | 218 static void SetDelegate(ID identifier, BrowserThreadDelegate* delegate); |
200 | 219 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 private: | 262 private: |
244 friend class BrowserThreadImpl; | 263 friend class BrowserThreadImpl; |
245 | 264 |
246 BrowserThread() {} | 265 BrowserThread() {} |
247 DISALLOW_COPY_AND_ASSIGN(BrowserThread); | 266 DISALLOW_COPY_AND_ASSIGN(BrowserThread); |
248 }; | 267 }; |
249 | 268 |
250 } // namespace content | 269 } // namespace content |
251 | 270 |
252 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ | 271 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ |
OLD | NEW |