| 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 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 | 35 |
| 36 void ChromeThread::Initialize() { | 36 void ChromeThread::Initialize() { |
| 37 AutoLock lock(lock_); | 37 AutoLock lock(lock_); |
| 38 DCHECK(identifier_ >= 0 && identifier_ < ID_COUNT); | 38 DCHECK(identifier_ >= 0 && identifier_ < ID_COUNT); |
| 39 DCHECK(chrome_threads_[identifier_] == NULL); | 39 DCHECK(chrome_threads_[identifier_] == NULL); |
| 40 chrome_threads_[identifier_] = this; | 40 chrome_threads_[identifier_] = this; |
| 41 } | 41 } |
| 42 | 42 |
| 43 ChromeThread::~ChromeThread() { | 43 ChromeThread::~ChromeThread() { |
| 44 // Stop the thread here, instead of the parent's class destructor. This is so |
| 45 // that if there are pending tasks that run, code that checks that it's on the |
| 46 // correct ChromeThread succeeds. |
| 47 Stop(); |
| 48 |
| 44 AutoLock lock(lock_); | 49 AutoLock lock(lock_); |
| 45 chrome_threads_[identifier_] = NULL; | 50 chrome_threads_[identifier_] = NULL; |
| 46 #ifndef NDEBUG | 51 #ifndef NDEBUG |
| 47 // Double check that the threads are ordererd correctly in the enumeration. | 52 // Double check that the threads are ordererd correctly in the enumeration. |
| 48 for (int i = identifier_ + 1; i < ID_COUNT; ++i) { | 53 for (int i = identifier_ + 1; i < ID_COUNT; ++i) { |
| 49 DCHECK(!chrome_threads_[i]) << | 54 DCHECK(!chrome_threads_[i]) << |
| 50 "Threads must be listed in the reverse order that they die"; | 55 "Threads must be listed in the reverse order that they die"; |
| 51 } | 56 } |
| 52 #endif | 57 #endif |
| 53 } | 58 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 143 } |
| 139 } else { | 144 } else { |
| 140 delete task; | 145 delete task; |
| 141 } | 146 } |
| 142 | 147 |
| 143 if (!guaranteed_to_outlive_target_thread) | 148 if (!guaranteed_to_outlive_target_thread) |
| 144 lock_.Release(); | 149 lock_.Release(); |
| 145 | 150 |
| 146 return !!message_loop; | 151 return !!message_loop; |
| 147 } | 152 } |
| OLD | NEW |