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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 } | 349 } |
350 | 350 |
351 // static | 351 // static |
352 void BrowserThreadImpl::ResetGlobalsForTesting(BrowserThread::ID identifier) { | 352 void BrowserThreadImpl::ResetGlobalsForTesting(BrowserThread::ID identifier) { |
353 BrowserThreadGlobals& globals = g_globals.Get(); | 353 BrowserThreadGlobals& globals = g_globals.Get(); |
354 | 354 |
355 base::AutoLock lock(globals.lock); | 355 base::AutoLock lock(globals.lock); |
356 DCHECK_EQ(globals.states[identifier], BrowserThreadState::SHUTDOWN); | 356 DCHECK_EQ(globals.states[identifier], BrowserThreadState::SHUTDOWN); |
357 globals.states[identifier] = BrowserThreadState::UNINITIALIZED; | 357 globals.states[identifier] = BrowserThreadState::UNINITIALIZED; |
358 globals.task_runners[identifier] = nullptr; | 358 globals.task_runners[identifier] = nullptr; |
359 SetIOThreadDelegate(nullptr); | 359 if (identifier == BrowserThread::IO) |
360 SetIOThreadDelegate(nullptr); | |
gab
2017/01/10 15:48:28
This call only needs to happen once for the IO thr
| |
360 } | 361 } |
361 | 362 |
362 BrowserThreadImpl::~BrowserThreadImpl() { | 363 BrowserThreadImpl::~BrowserThreadImpl() { |
363 // All Thread subclasses must call Stop() in the destructor. This is | 364 // All Thread subclasses must call Stop() in the destructor. This is |
364 // doubly important here as various bits of code check they are on | 365 // doubly important here as various bits of code check they are on |
365 // the right BrowserThread. | 366 // the right BrowserThread. |
366 Stop(); | 367 Stop(); |
367 | 368 |
368 BrowserThreadGlobals& globals = g_globals.Get(); | 369 BrowserThreadGlobals& globals = g_globals.Get(); |
369 base::AutoLock lock(globals.lock); | 370 base::AutoLock lock(globals.lock); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 BrowserThreadDelegateAtomicPtr old_delegate = | 696 BrowserThreadDelegateAtomicPtr old_delegate = |
696 base::subtle::NoBarrier_AtomicExchange( | 697 base::subtle::NoBarrier_AtomicExchange( |
697 &globals.io_thread_delegate, | 698 &globals.io_thread_delegate, |
698 reinterpret_cast<BrowserThreadDelegateAtomicPtr>(delegate)); | 699 reinterpret_cast<BrowserThreadDelegateAtomicPtr>(delegate)); |
699 | 700 |
700 // This catches registration when previously registered. | 701 // This catches registration when previously registered. |
701 DCHECK(!delegate || !old_delegate); | 702 DCHECK(!delegate || !old_delegate); |
702 } | 703 } |
703 | 704 |
704 } // namespace content | 705 } // namespace content |
OLD | NEW |