| 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 #include "content/browser/browser_thread.h" | 5 #include "content/browser/browser_thread.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 7 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 8 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 9 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| 10 | 11 |
| 11 // Friendly names for the well-known threads. | 12 // Friendly names for the well-known threads. |
| 12 static const char* browser_thread_names[BrowserThread::ID_COUNT] = { | 13 static const char* browser_thread_names[BrowserThread::ID_COUNT] = { |
| 13 "", // UI (name assembled in browser_main.cc). | 14 "", // UI (name assembled in browser_main.cc). |
| 14 "Chrome_DBThread", // DB | 15 "Chrome_DBThread", // DB |
| 15 "Chrome_WebKitThread", // WEBKIT | 16 "Chrome_WebKitThread", // WEBKIT |
| 16 "Chrome_FileThread", // FILE | 17 "Chrome_FileThread", // FILE |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // static | 215 // static |
| 215 bool BrowserThread::PostNonNestableDelayedTask( | 216 bool BrowserThread::PostNonNestableDelayedTask( |
| 216 ID identifier, | 217 ID identifier, |
| 217 const tracked_objects::Location& from_here, | 218 const tracked_objects::Location& from_here, |
| 218 Task* task, | 219 Task* task, |
| 219 int64 delay_ms) { | 220 int64 delay_ms) { |
| 220 return PostTaskHelper(identifier, from_here, task, delay_ms, false); | 221 return PostTaskHelper(identifier, from_here, task, delay_ms, false); |
| 221 } | 222 } |
| 222 | 223 |
| 223 // static | 224 // static |
| 225 bool BrowserThread::PostTaskAndReply( |
| 226 ID identifier, |
| 227 const tracked_objects::Location& from_here, |
| 228 const base::Closure& task, |
| 229 const base::Closure& reply) { |
| 230 return GetMessageLoopProxyForThread(identifier)->PostTaskAndReply(from_here, |
| 231 task, |
| 232 reply); |
| 233 } |
| 234 |
| 235 // static |
| 224 bool BrowserThread::GetCurrentThreadIdentifier(ID* identifier) { | 236 bool BrowserThread::GetCurrentThreadIdentifier(ID* identifier) { |
| 225 // We shouldn't use MessageLoop::current() since it uses LazyInstance which | 237 // We shouldn't use MessageLoop::current() since it uses LazyInstance which |
| 226 // may be deleted by ~AtExitManager when a WorkerPool thread calls this | 238 // may be deleted by ~AtExitManager when a WorkerPool thread calls this |
| 227 // function. | 239 // function. |
| 228 // http://crbug.com/63678 | 240 // http://crbug.com/63678 |
| 229 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton; | 241 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton; |
| 230 MessageLoop* cur_message_loop = MessageLoop::current(); | 242 MessageLoop* cur_message_loop = MessageLoop::current(); |
| 231 for (int i = 0; i < ID_COUNT; ++i) { | 243 for (int i = 0; i < ID_COUNT; ++i) { |
| 232 if (browser_threads_[i] && | 244 if (browser_threads_[i] && |
| 233 browser_threads_[i]->message_loop() == cur_message_loop) { | 245 browser_threads_[i]->message_loop() == cur_message_loop) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 } else { | 331 } else { |
| 320 message_loop->PostNonNestableDelayedTask(from_here, task, delay_ms); | 332 message_loop->PostNonNestableDelayedTask(from_here, task, delay_ms); |
| 321 } | 333 } |
| 322 } | 334 } |
| 323 | 335 |
| 324 if (!guaranteed_to_outlive_target_thread) | 336 if (!guaranteed_to_outlive_target_thread) |
| 325 lock_.Release(); | 337 lock_.Release(); |
| 326 | 338 |
| 327 return !!message_loop; | 339 return !!message_loop; |
| 328 } | 340 } |
| OLD | NEW |