| 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 "base/atomicops.h" | 7 #include "base/atomicops.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // This array is protected by |lock|. The threads are not owned by this | 45 // This array is protected by |lock|. The threads are not owned by this |
| 46 // array. Typically, the threads are owned on the UI thread by | 46 // array. Typically, the threads are owned on the UI thread by |
| 47 // content::BrowserMainLoop. BrowserThreadImpl objects remove themselves from | 47 // content::BrowserMainLoop. BrowserThreadImpl objects remove themselves from |
| 48 // this array upon destruction. | 48 // this array upon destruction. |
| 49 BrowserThreadImpl* threads[BrowserThread::ID_COUNT]; | 49 BrowserThreadImpl* threads[BrowserThread::ID_COUNT]; |
| 50 | 50 |
| 51 // Only atomic operations are used on this array. The delegates are not owned | 51 // Only atomic operations are used on this array. The delegates are not owned |
| 52 // by this array, rather by whoever calls BrowserThread::SetDelegate. | 52 // by this array, rather by whoever calls BrowserThread::SetDelegate. |
| 53 BrowserThreadDelegate* thread_delegates[BrowserThread::ID_COUNT]; | 53 BrowserThreadDelegate* thread_delegates[BrowserThread::ID_COUNT]; |
| 54 | 54 |
| 55 // This pointer is deliberately leaked on shutdown. This allows the pool to | 55 const scoped_refptr<base::SequencedWorkerPool> blocking_pool; |
| 56 // implement "continue on shutdown" semantics. | |
| 57 base::SequencedWorkerPool* blocking_pool; | |
| 58 }; | 56 }; |
| 59 | 57 |
| 60 base::LazyInstance<BrowserThreadGlobals>::Leaky | 58 base::LazyInstance<BrowserThreadGlobals>::Leaky |
| 61 g_globals = LAZY_INSTANCE_INITIALIZER; | 59 g_globals = LAZY_INSTANCE_INITIALIZER; |
| 62 | 60 |
| 63 } // namespace | 61 } // namespace |
| 64 | 62 |
| 65 BrowserThreadImpl::BrowserThreadImpl(ID identifier) | 63 BrowserThreadImpl::BrowserThreadImpl(ID identifier) |
| 66 : Thread(g_browser_thread_names[identifier]), | 64 : Thread(g_browser_thread_names[identifier]), |
| 67 identifier_(identifier) { | 65 identifier_(identifier) { |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 390 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
| 393 &globals.thread_delegates[identifier]); | 391 &globals.thread_delegates[identifier]); |
| 394 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 392 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
| 395 storage, reinterpret_cast<AtomicWord>(delegate)); | 393 storage, reinterpret_cast<AtomicWord>(delegate)); |
| 396 | 394 |
| 397 // This catches registration when previously registered. | 395 // This catches registration when previously registered. |
| 398 DCHECK(!delegate || !old_pointer); | 396 DCHECK(!delegate || !old_pointer); |
| 399 } | 397 } |
| 400 | 398 |
| 401 } // namespace content | 399 } // namespace content |
| OLD | NEW |