Chromium Code Reviews| 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" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/message_loop/message_loop_proxy.h" | 14 #include "base/message_loop/message_loop_proxy.h" |
| 15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
| 16 #include "base/threading/thread_restrictions.h" | 16 #include "base/threading/thread_restrictions.h" |
| 17 #include "content/public/browser/browser_thread_delegate.h" | 17 #include "content/public/browser/browser_thread_delegate.h" |
| 18 #include "net/disk_cache/simple/simple_backend_impl.h" | |
| 18 | 19 |
| 19 #if defined(OS_ANDROID) | 20 #if defined(OS_ANDROID) |
| 20 #include "base/android/jni_android.h" | 21 #include "base/android/jni_android.h" |
| 21 #endif | 22 #endif |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 // Friendly names for the well-known threads. | 28 // Friendly names for the well-known threads. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 // The goal is to make it impossible for chrome to 'infinite loop' during | 135 // The goal is to make it impossible for chrome to 'infinite loop' during |
| 135 // shutdown, but to reasonably expect that all BLOCKING_SHUTDOWN tasks queued | 136 // shutdown, but to reasonably expect that all BLOCKING_SHUTDOWN tasks queued |
| 136 // during shutdown get run. There's nothing particularly scientific about the | 137 // during shutdown get run. There's nothing particularly scientific about the |
| 137 // number chosen. | 138 // number chosen. |
| 138 const int kMaxNewShutdownBlockingTasks = 1000; | 139 const int kMaxNewShutdownBlockingTasks = 1000; |
| 139 BrowserThreadGlobals& globals = g_globals.Get(); | 140 BrowserThreadGlobals& globals = g_globals.Get(); |
| 140 globals.blocking_pool->Shutdown(kMaxNewShutdownBlockingTasks); | 141 globals.blocking_pool->Shutdown(kMaxNewShutdownBlockingTasks); |
| 141 } | 142 } |
| 142 | 143 |
| 143 // static | 144 // static |
| 144 void BrowserThreadImpl::FlushThreadPoolHelper() { | 145 void BrowserThreadImpl::FlushThreadPoolHelper() { |
|
jochen (gone - plz use gerrit)
2014/09/24 20:02:15
this method should be called FlushThreadPoolHelper
jkarlin
2014/09/26 11:57:05
Done.
| |
| 145 // We don't want to create a pool if none exists. | 146 // We don't want to create a pool if none exists. |
| 146 if (g_globals == NULL) | 147 if (g_globals == NULL) |
| 147 return; | 148 return; |
| 148 g_globals.Get().blocking_pool->FlushForTesting(); | 149 g_globals.Get().blocking_pool->FlushForTesting(); |
| 150 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); | |
| 149 } | 151 } |
| 150 | 152 |
| 151 void BrowserThreadImpl::Init() { | 153 void BrowserThreadImpl::Init() { |
| 152 BrowserThreadGlobals& globals = g_globals.Get(); | 154 BrowserThreadGlobals& globals = g_globals.Get(); |
| 153 | 155 |
| 154 using base::subtle::AtomicWord; | 156 using base::subtle::AtomicWord; |
| 155 AtomicWord* storage = | 157 AtomicWord* storage = |
| 156 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier_]); | 158 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier_]); |
| 157 AtomicWord stored_pointer = base::subtle::NoBarrier_Load(storage); | 159 AtomicWord stored_pointer = base::subtle::NoBarrier_Load(storage); |
| 158 BrowserThreadDelegate* delegate = | 160 BrowserThreadDelegate* delegate = |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 532 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
| 531 &globals.thread_delegates[identifier]); | 533 &globals.thread_delegates[identifier]); |
| 532 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 534 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
| 533 storage, reinterpret_cast<AtomicWord>(delegate)); | 535 storage, reinterpret_cast<AtomicWord>(delegate)); |
| 534 | 536 |
| 535 // This catches registration when previously registered. | 537 // This catches registration when previously registered. |
| 536 DCHECK(!delegate || !old_pointer); | 538 DCHECK(!delegate || !old_pointer); |
| 537 } | 539 } |
| 538 | 540 |
| 539 } // namespace content | 541 } // namespace content |
| OLD | NEW |