OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/chrome_thread.h" | 5 #include "chrome/browser/chrome_thread.h" |
6 | 6 |
7 // Friendly names for the well-known threads. | 7 // Friendly names for the well-known threads. |
8 static const char* chrome_thread_names[ChromeThread::ID_COUNT] = { | 8 static const char* chrome_thread_names[ChromeThread::ID_COUNT] = { |
9 "Chrome_IOThread", // IO | 9 "Chrome_IOThread", // IO |
10 "Chrome_FileThread", // FILE | 10 "Chrome_FileThread", // FILE |
11 "Chrome_DBThread", // DB | 11 "Chrome_DBThread", // DB |
| 12 "Chrome_HistoryThread", // HISTORY |
| 13 #if defined(OS_LINUX) |
| 14 "Chrome_Background_X11Thread", // BACKGROUND_X11 |
| 15 #endif |
12 }; | 16 }; |
13 | 17 |
14 Lock ChromeThread::lock_; | 18 Lock ChromeThread::lock_; |
15 | 19 |
16 ChromeThread* ChromeThread::chrome_threads_[ID_COUNT] = { | 20 ChromeThread* ChromeThread::chrome_threads_[ID_COUNT] = { |
17 NULL, // IO | 21 NULL, // IO |
18 NULL, // FILE | 22 NULL, // FILE |
19 NULL, // DB | 23 NULL, // DB |
| 24 NULL, // HISTORY |
| 25 #if defined(OS_LINUX) |
| 26 NULL, // BACKGROUND_X11 |
| 27 #endif |
20 }; | 28 }; |
21 | 29 |
22 ChromeThread::ChromeThread(ChromeThread::ID identifier) | 30 ChromeThread::ChromeThread(ChromeThread::ID identifier) |
23 : Thread(chrome_thread_names[identifier]), | 31 : Thread(chrome_thread_names[identifier]), |
24 identifier_(identifier) { | 32 identifier_(identifier) { |
25 AutoLock lock(lock_); | 33 AutoLock lock(lock_); |
26 DCHECK(identifier >= 0 && identifier < ID_COUNT); | 34 DCHECK(identifier >= 0 && identifier < ID_COUNT); |
27 DCHECK(chrome_threads_[identifier] == NULL); | 35 DCHECK(chrome_threads_[identifier] == NULL); |
28 chrome_threads_[identifier_] = this; | 36 chrome_threads_[identifier_] = this; |
29 } | 37 } |
30 | 38 |
31 ChromeThread::~ChromeThread() { | 39 ChromeThread::~ChromeThread() { |
32 AutoLock lock(lock_); | 40 AutoLock lock(lock_); |
33 chrome_threads_[identifier_] = NULL; | 41 chrome_threads_[identifier_] = NULL; |
34 } | 42 } |
35 | 43 |
36 // static | 44 // static |
37 MessageLoop* ChromeThread::GetMessageLoop(ID identifier) { | 45 MessageLoop* ChromeThread::GetMessageLoop(ID identifier) { |
38 AutoLock lock(lock_); | 46 AutoLock lock(lock_); |
39 DCHECK(identifier >= 0 && identifier < ID_COUNT); | 47 DCHECK(identifier >= 0 && identifier < ID_COUNT); |
40 | 48 |
41 if (chrome_threads_[identifier]) | 49 if (chrome_threads_[identifier]) |
42 return chrome_threads_[identifier]->message_loop(); | 50 return chrome_threads_[identifier]->message_loop(); |
43 | 51 |
44 return NULL; | 52 return NULL; |
45 } | 53 } |
OLD | NEW |