| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 | 9 |
| 10 // Friendly names for the well-known threads. | 10 // Friendly names for the well-known threads. |
| 11 static const char* chrome_thread_names[ChromeThread::ID_COUNT] = { | 11 static const char* chrome_thread_names[ChromeThread::ID_COUNT] = { |
| 12 "", // UI (name assembled in browser_main.cc). | 12 "", // UI (name assembled in browser_main.cc). |
| 13 "Chrome_DBThread", // DB | 13 "Chrome_DBThread", // DB |
| 14 "Chrome_WebKitThread", // WEBKIT | 14 "Chrome_WebKitThread", // WEBKIT |
| 15 "Chrome_FileThread", // FILE | 15 "Chrome_FileThread", // FILE |
| 16 "Chrome_ProcessLauncherThread", // PROCESS_LAUNCHER | 16 "Chrome_ProcessLauncherThread", // PROCESS_LAUNCHER |
| 17 "Chrome_IOThread", // IO | 17 "Chrome_IOThread", // IO |
| 18 #if defined(USE_X11) | 18 #if defined(USE_X11) |
| 19 "Chrome_Background_X11Thread", // BACKGROUND_X11 | 19 "Chrome_Background_X11Thread", // BACKGROUND_X11 |
| 20 #endif | 20 #endif |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 // An implementation of MessageLoopProxy to be used in conjunction | 23 // An implementation of MessageLoopProxy to be used in conjunction |
| 24 // with ChromeThread. | 24 // with ChromeThread. |
| 25 class ChromeThreadMessageLoopProxy : public MessageLoopProxy { | 25 class ChromeThreadMessageLoopProxy : public base::MessageLoopProxy { |
| 26 public: | 26 public: |
| 27 explicit ChromeThreadMessageLoopProxy(ChromeThread::ID identifier) | 27 explicit ChromeThreadMessageLoopProxy(ChromeThread::ID identifier) |
| 28 : id_(identifier) { | 28 : id_(identifier) { |
| 29 } | 29 } |
| 30 | 30 |
| 31 // MessageLoopProxy implementation. | 31 // MessageLoopProxy implementation. |
| 32 virtual bool PostTask(const tracked_objects::Location& from_here, | 32 virtual bool PostTask(const tracked_objects::Location& from_here, |
| 33 Task* task) { | 33 Task* task) { |
| 34 return ChromeThread::PostTask(id_, from_here, task); | 34 return ChromeThread::PostTask(id_, from_here, task); |
| 35 } | 35 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 chrome_threads_[i]->message_loop() == cur_message_loop) { | 157 chrome_threads_[i]->message_loop() == cur_message_loop) { |
| 158 *identifier = chrome_threads_[i]->identifier_; | 158 *identifier = chrome_threads_[i]->identifier_; |
| 159 return true; | 159 return true; |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 return false; | 163 return false; |
| 164 } | 164 } |
| 165 | 165 |
| 166 // static | 166 // static |
| 167 scoped_refptr<MessageLoopProxy> ChromeThread::GetMessageLoopProxyForThread( | 167 scoped_refptr<base::MessageLoopProxy> |
| 168 ChromeThread::GetMessageLoopProxyForThread( |
| 168 ID identifier) { | 169 ID identifier) { |
| 169 scoped_refptr<MessageLoopProxy> proxy = | 170 scoped_refptr<base::MessageLoopProxy> proxy = |
| 170 new ChromeThreadMessageLoopProxy(identifier); | 171 new ChromeThreadMessageLoopProxy(identifier); |
| 171 return proxy; | 172 return proxy; |
| 172 } | 173 } |
| 173 | 174 |
| 174 // static | 175 // static |
| 175 bool ChromeThread::PostTaskHelper( | 176 bool ChromeThread::PostTaskHelper( |
| 176 ID identifier, | 177 ID identifier, |
| 177 const tracked_objects::Location& from_here, | 178 const tracked_objects::Location& from_here, |
| 178 Task* task, | 179 Task* task, |
| 179 int64 delay_ms, | 180 int64 delay_ms, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 203 } | 204 } |
| 204 } else { | 205 } else { |
| 205 delete task; | 206 delete task; |
| 206 } | 207 } |
| 207 | 208 |
| 208 if (!guaranteed_to_outlive_target_thread) | 209 if (!guaranteed_to_outlive_target_thread) |
| 209 lock_.Release(); | 210 lock_.Release(); |
| 210 | 211 |
| 211 return !!message_loop; | 212 return !!message_loop; |
| 212 } | 213 } |
| OLD | NEW |