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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // We don't want to create a pool if none exists. | 178 // We don't want to create a pool if none exists. |
179 if (g_globals == nullptr) | 179 if (g_globals == nullptr) |
180 return; | 180 return; |
181 g_globals.Get().blocking_pool->FlushForTesting(); | 181 g_globals.Get().blocking_pool->FlushForTesting(); |
182 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); | 182 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); |
183 } | 183 } |
184 | 184 |
185 void BrowserThreadImpl::Init() { | 185 void BrowserThreadImpl::Init() { |
186 BrowserThreadGlobals& globals = g_globals.Get(); | 186 BrowserThreadGlobals& globals = g_globals.Get(); |
187 | 187 |
| 188 if (BrowserThread::CurrentlyOn(BrowserThread::DB) || |
| 189 BrowserThread::CurrentlyOn(BrowserThread::FILE) || |
| 190 BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING) || |
| 191 BrowserThread::CurrentlyOn(BrowserThread::PROCESS_LAUNCHER) || |
| 192 BrowserThread::CurrentlyOn(BrowserThread::CACHE)) { |
| 193 base::MessageLoop* message_loop = base::MessageLoop::current(); |
| 194 message_loop->DisableNesting(); |
| 195 message_loop->DisableDestructionObservers(); |
| 196 message_loop->DisableTaskObservers(); |
| 197 } |
| 198 |
188 using base::subtle::AtomicWord; | 199 using base::subtle::AtomicWord; |
189 AtomicWord* storage = | 200 AtomicWord* storage = |
190 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier_]); | 201 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier_]); |
191 AtomicWord stored_pointer = base::subtle::NoBarrier_Load(storage); | 202 AtomicWord stored_pointer = base::subtle::NoBarrier_Load(storage); |
192 BrowserThreadDelegate* delegate = | 203 BrowserThreadDelegate* delegate = |
193 reinterpret_cast<BrowserThreadDelegate*>(stored_pointer); | 204 reinterpret_cast<BrowserThreadDelegate*>(stored_pointer); |
194 if (delegate) | 205 if (delegate) |
195 delegate->Init(); | 206 delegate->Init(); |
196 } | 207 } |
197 | 208 |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 593 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
583 &globals.thread_delegates[identifier]); | 594 &globals.thread_delegates[identifier]); |
584 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 595 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
585 storage, reinterpret_cast<AtomicWord>(delegate)); | 596 storage, reinterpret_cast<AtomicWord>(delegate)); |
586 | 597 |
587 // This catches registration when previously registered. | 598 // This catches registration when previously registered. |
588 DCHECK(!delegate || !old_pointer); | 599 DCHECK(!delegate || !old_pointer); |
589 } | 600 } |
590 | 601 |
591 } // namespace content | 602 } // namespace content |
OLD | NEW |