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_impl.h" | 5 #include "content/browser/browser_thread_impl.h" |
6 | 6 |
7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 388 |
389 // static | 389 // static |
390 scoped_refptr<base::MessageLoopProxy> | 390 scoped_refptr<base::MessageLoopProxy> |
391 BrowserThread::GetMessageLoopProxyForThread( | 391 BrowserThread::GetMessageLoopProxyForThread( |
392 ID identifier) { | 392 ID identifier) { |
393 scoped_refptr<base::MessageLoopProxy> proxy( | 393 scoped_refptr<base::MessageLoopProxy> proxy( |
394 new BrowserThreadMessageLoopProxy(identifier)); | 394 new BrowserThreadMessageLoopProxy(identifier)); |
395 return proxy; | 395 return proxy; |
396 } | 396 } |
397 | 397 |
398 base::Thread* BrowserThread::UnsafeGetBrowserThread(ID identifier) { | 398 // static |
| 399 MessageLoop* BrowserThread::UnsafeGetMessageLoopForThread(ID identifier) { |
399 base::AutoLock lock(g_lock.Get()); | 400 base::AutoLock lock(g_lock.Get()); |
400 base::Thread* thread = g_browser_threads[identifier]; | 401 base::Thread* thread = g_browser_threads[identifier]; |
401 DCHECK(thread); | 402 DCHECK(thread); |
402 return thread; | 403 MessageLoop* loop = thread->message_loop(); |
| 404 return loop; |
403 } | 405 } |
404 | 406 |
405 MessageLoop* BrowserThread::UnsafeGetMessageLoop(ID identifier) { | 407 // static |
406 return UnsafeGetBrowserThread(identifier)->message_loop(); | |
407 } | |
408 | |
409 void BrowserThread::SetDelegate(ID identifier, | 408 void BrowserThread::SetDelegate(ID identifier, |
410 BrowserThreadDelegate* delegate) { | 409 BrowserThreadDelegate* delegate) { |
411 using base::subtle::AtomicWord; | 410 using base::subtle::AtomicWord; |
412 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 411 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
413 &g_browser_thread_delegates[identifier]); | 412 &g_browser_thread_delegates[identifier]); |
414 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 413 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
415 storage, reinterpret_cast<AtomicWord>(delegate)); | 414 storage, reinterpret_cast<AtomicWord>(delegate)); |
416 | 415 |
417 // This catches registration when previously registered. | 416 // This catches registration when previously registered. |
418 DCHECK(!delegate || !old_pointer); | 417 DCHECK(!delegate || !old_pointer); |
419 } | 418 } |
420 | 419 |
421 } // namespace content | 420 } // namespace content |
OLD | NEW |