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.h> | 7 #include <string.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 | 564 |
565 return false; | 565 return false; |
566 } | 566 } |
567 | 567 |
568 // static | 568 // static |
569 scoped_refptr<base::SingleThreadTaskRunner> | 569 scoped_refptr<base::SingleThreadTaskRunner> |
570 BrowserThread::GetTaskRunnerForThread(ID identifier) { | 570 BrowserThread::GetTaskRunnerForThread(ID identifier) { |
571 return g_task_runners.Get().proxies[identifier]; | 571 return g_task_runners.Get().proxies[identifier]; |
572 } | 572 } |
573 | 573 |
574 // static | |
575 base::MessageLoop* BrowserThread::UnsafeGetMessageLoopForThread(ID identifier) { | |
576 if (g_globals == nullptr) | |
577 return nullptr; | |
578 | |
579 BrowserThreadGlobals& globals = g_globals.Get(); | |
580 base::AutoLock lock(globals.lock); | |
581 base::Thread* thread = globals.threads[identifier]; | |
582 DCHECK(thread); | |
583 base::MessageLoop* loop = thread->message_loop(); | |
584 return loop; | |
585 } | |
586 | |
587 // static | |
588 void BrowserThread::SetDelegate(ID identifier, | 574 void BrowserThread::SetDelegate(ID identifier, |
589 BrowserThreadDelegate* delegate) { | 575 BrowserThreadDelegate* delegate) { |
590 using base::subtle::AtomicWord; | 576 using base::subtle::AtomicWord; |
591 BrowserThreadGlobals& globals = g_globals.Get(); | 577 BrowserThreadGlobals& globals = g_globals.Get(); |
592 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 578 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
593 &globals.thread_delegates[identifier]); | 579 &globals.thread_delegates[identifier]); |
594 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 580 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
595 storage, reinterpret_cast<AtomicWord>(delegate)); | 581 storage, reinterpret_cast<AtomicWord>(delegate)); |
596 | 582 |
597 // This catches registration when previously registered. | 583 // This catches registration when previously registered. |
598 DCHECK(!delegate || !old_pointer); | 584 DCHECK(!delegate || !old_pointer); |
599 } | 585 } |
600 | 586 |
601 } // namespace content | 587 } // namespace content |
OLD | NEW |