| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 return false; | 450 return false; |
| 451 } | 451 } |
| 452 | 452 |
| 453 // static | 453 // static |
| 454 scoped_refptr<base::MessageLoopProxy> | 454 scoped_refptr<base::MessageLoopProxy> |
| 455 BrowserThread::GetMessageLoopProxyForThread(ID identifier) { | 455 BrowserThread::GetMessageLoopProxyForThread(ID identifier) { |
| 456 return make_scoped_refptr(new BrowserThreadMessageLoopProxy(identifier)); | 456 return make_scoped_refptr(new BrowserThreadMessageLoopProxy(identifier)); |
| 457 } | 457 } |
| 458 | 458 |
| 459 // static | 459 // static |
| 460 MessageLoop* BrowserThread::UnsafeGetMessageLoopForThread(ID identifier) { | 460 base::MessageLoop* BrowserThread::UnsafeGetMessageLoopForThread(ID identifier) { |
| 461 if (g_globals == NULL) | 461 if (g_globals == NULL) |
| 462 return NULL; | 462 return NULL; |
| 463 | 463 |
| 464 BrowserThreadGlobals& globals = g_globals.Get(); | 464 BrowserThreadGlobals& globals = g_globals.Get(); |
| 465 base::AutoLock lock(globals.lock); | 465 base::AutoLock lock(globals.lock); |
| 466 base::Thread* thread = globals.threads[identifier]; | 466 base::Thread* thread = globals.threads[identifier]; |
| 467 DCHECK(thread); | 467 DCHECK(thread); |
| 468 base::MessageLoop* loop = thread->message_loop(); | 468 base::MessageLoop* loop = thread->message_loop(); |
| 469 return loop; | 469 return loop; |
| 470 } | 470 } |
| 471 | 471 |
| 472 // static | 472 // static |
| 473 void BrowserThread::SetDelegate(ID identifier, | 473 void BrowserThread::SetDelegate(ID identifier, |
| 474 BrowserThreadDelegate* delegate) { | 474 BrowserThreadDelegate* delegate) { |
| 475 using base::subtle::AtomicWord; | 475 using base::subtle::AtomicWord; |
| 476 BrowserThreadGlobals& globals = g_globals.Get(); | 476 BrowserThreadGlobals& globals = g_globals.Get(); |
| 477 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 477 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
| 478 &globals.thread_delegates[identifier]); | 478 &globals.thread_delegates[identifier]); |
| 479 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 479 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
| 480 storage, reinterpret_cast<AtomicWord>(delegate)); | 480 storage, reinterpret_cast<AtomicWord>(delegate)); |
| 481 | 481 |
| 482 // This catches registration when previously registered. | 482 // This catches registration when previously registered. |
| 483 DCHECK(!delegate || !old_pointer); | 483 DCHECK(!delegate || !old_pointer); |
| 484 } | 484 } |
| 485 | 485 |
| 486 } // namespace content | 486 } // namespace content |
| OLD | NEW |