| 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 #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 "", // UI (name assembled in browser_main.cc). | 9 "", // UI (name assembled in browser_main.cc). |
| 10 "Chrome_DBThread", // DB | 10 "Chrome_DBThread", // DB |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #ifndef NDEBUG | 52 #ifndef NDEBUG |
| 53 // Double check that the threads are ordererd correctly in the enumeration. | 53 // Double check that the threads are ordererd correctly in the enumeration. |
| 54 for (int i = identifier_ + 1; i < ID_COUNT; ++i) { | 54 for (int i = identifier_ + 1; i < ID_COUNT; ++i) { |
| 55 DCHECK(!chrome_threads_[i]) << | 55 DCHECK(!chrome_threads_[i]) << |
| 56 "Threads must be listed in the reverse order that they die"; | 56 "Threads must be listed in the reverse order that they die"; |
| 57 } | 57 } |
| 58 #endif | 58 #endif |
| 59 } | 59 } |
| 60 | 60 |
| 61 // static | 61 // static |
| 62 bool ChromeThread::IsWellKnownThread(ID identifier) { |
| 63 AutoLock lock(lock_); |
| 64 return (identifier >= 0 && identifier < ID_COUNT && |
| 65 chrome_threads_[identifier]); |
| 66 } |
| 67 |
| 68 // static |
| 62 bool ChromeThread::CurrentlyOn(ID identifier) { | 69 bool ChromeThread::CurrentlyOn(ID identifier) { |
| 63 AutoLock lock(lock_); | 70 AutoLock lock(lock_); |
| 64 DCHECK(identifier >= 0 && identifier < ID_COUNT); | 71 DCHECK(identifier >= 0 && identifier < ID_COUNT); |
| 65 return chrome_threads_[identifier] && | 72 return chrome_threads_[identifier] && |
| 66 chrome_threads_[identifier]->message_loop() == MessageLoop::current(); | 73 chrome_threads_[identifier]->message_loop() == MessageLoop::current(); |
| 67 } | 74 } |
| 68 | 75 |
| 69 // static | 76 // static |
| 70 bool ChromeThread::PostTask(ID identifier, | 77 bool ChromeThread::PostTask(ID identifier, |
| 71 const tracked_objects::Location& from_here, | 78 const tracked_objects::Location& from_here, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 151 } |
| 145 } else { | 152 } else { |
| 146 delete task; | 153 delete task; |
| 147 } | 154 } |
| 148 | 155 |
| 149 if (!guaranteed_to_outlive_target_thread) | 156 if (!guaranteed_to_outlive_target_thread) |
| 150 lock_.Release(); | 157 lock_.Release(); |
| 151 | 158 |
| 152 return !!message_loop; | 159 return !!message_loop; |
| 153 } | 160 } |
| OLD | NEW |