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" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 return g_globals.Get().blocking_pool->PostNamedSequencedWorkerTask( | 332 return g_globals.Get().blocking_pool->PostNamedSequencedWorkerTask( |
| 333 sequence_token_name, from_here, task); | 333 sequence_token_name, from_here, task); |
| 334 } | 334 } |
| 335 | 335 |
| 336 // static | 336 // static |
| 337 base::SequencedWorkerPool* BrowserThread::GetBlockingPool() { | 337 base::SequencedWorkerPool* BrowserThread::GetBlockingPool() { |
| 338 return g_globals.Get().blocking_pool.get(); | 338 return g_globals.Get().blocking_pool.get(); |
| 339 } | 339 } |
| 340 | 340 |
| 341 // static | 341 // static |
| 342 bool BrowserThread::IsWellKnownThread(ID identifier) { | 342 bool BrowserThread::IsThreadInitialized(ID identifier) { |
| 343 if (g_globals == NULL) | 343 if (g_globals == NULL) |
| 344 return false; | 344 return false; |
| 345 | 345 |
| 346 BrowserThreadGlobals& globals = g_globals.Get(); | 346 BrowserThreadGlobals& globals = g_globals.Get(); |
| 347 base::AutoLock lock(globals.lock); | 347 base::AutoLock lock(globals.lock); |
| 348 return (identifier >= 0 && identifier < ID_COUNT && | 348 DCHECK(identifier >= 0 && identifier < ID_COUNT); |
|
Matt Giuca
2013/08/05 01:31:16
I changed this because if |identifier| is not a va
| |
| 349 globals.threads[identifier]); | 349 return globals.threads[identifier]; |
| 350 } | 350 } |
| 351 | 351 |
| 352 // static | 352 // static |
| 353 bool BrowserThread::CurrentlyOn(ID identifier) { | 353 bool BrowserThread::CurrentlyOn(ID identifier) { |
| 354 // We shouldn't use MessageLoop::current() since it uses LazyInstance which | 354 // We shouldn't use MessageLoop::current() since it uses LazyInstance which |
| 355 // may be deleted by ~AtExitManager when a WorkerPool thread calls this | 355 // may be deleted by ~AtExitManager when a WorkerPool thread calls this |
| 356 // function. | 356 // function. |
| 357 // http://crbug.com/63678 | 357 // http://crbug.com/63678 |
| 358 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton; | 358 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton; |
| 359 BrowserThreadGlobals& globals = g_globals.Get(); | 359 BrowserThreadGlobals& globals = g_globals.Get(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 473 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
| 474 &globals.thread_delegates[identifier]); | 474 &globals.thread_delegates[identifier]); |
| 475 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 475 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
| 476 storage, reinterpret_cast<AtomicWord>(delegate)); | 476 storage, reinterpret_cast<AtomicWord>(delegate)); |
| 477 | 477 |
| 478 // This catches registration when previously registered. | 478 // This catches registration when previously registered. |
| 479 DCHECK(!delegate || !old_pointer); | 479 DCHECK(!delegate || !old_pointer); |
| 480 } | 480 } |
| 481 | 481 |
| 482 } // namespace content | 482 } // namespace content |
| OLD | NEW |