OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/public/test/test_browser_thread.h" | 5 #include "content/public/test/test_browser_thread.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // |impl_| have triggered the shutdown phase for its BrowserThread::ID. This | 52 // |impl_| have triggered the shutdown phase for its BrowserThread::ID. This |
53 // either happens when the thread is stopped (if real) or destroyed (when fake | 53 // either happens when the thread is stopped (if real) or destroyed (when fake |
54 // -- i.e. using an externally provided MessageLoop). | 54 // -- i.e. using an externally provided MessageLoop). |
55 impl_.reset(); | 55 impl_.reset(); |
56 | 56 |
57 // Resets BrowserThreadImpl's globals so that |impl_| is no longer bound to | 57 // Resets BrowserThreadImpl's globals so that |impl_| is no longer bound to |
58 // |identifier_|. This is fine since the underlying MessageLoop has already | 58 // |identifier_|. This is fine since the underlying MessageLoop has already |
59 // been flushed and deleted in Stop(). In the case of an externally provided | 59 // been flushed and deleted in Stop(). In the case of an externally provided |
60 // MessageLoop however, this means that TaskRunners obtained through | 60 // MessageLoop however, this means that TaskRunners obtained through |
61 // |BrowserThreadImpl::GetTaskRunnerForThread(identifier_)| will no longer | 61 // |BrowserThreadImpl::GetTaskRunnerForThread(identifier_)| will no longer |
62 // recognize their BrowserThreadImpl for RunsTasksOnCurrentThread(). This | 62 // recognize their BrowserThreadImpl for RunsTasksInCurrentSequence(). This |
63 // happens most often when such verifications are made from | 63 // happens most often when such verifications are made from |
64 // MessageLoop::DestructionObservers. Callers that care to work around that | 64 // MessageLoop::DestructionObservers. Callers that care to work around that |
65 // should instead use this shutdown sequence: | 65 // should instead use this shutdown sequence: |
66 // 1) TestBrowserThread::Stop() | 66 // 1) TestBrowserThread::Stop() |
67 // 2) ~MessageLoop() | 67 // 2) ~MessageLoop() |
68 // 3) ~TestBrowserThread() | 68 // 3) ~TestBrowserThread() |
69 // (~TestBrowserThreadBundle() does this). | 69 // (~TestBrowserThreadBundle() does this). |
70 BrowserThreadImpl::ResetGlobalsForTesting(identifier_); | 70 BrowserThreadImpl::ResetGlobalsForTesting(identifier_); |
71 } | 71 } |
72 | 72 |
(...skipping 13 matching lines...) Expand all Loading... |
86 | 86 |
87 void TestBrowserThread::Stop() { | 87 void TestBrowserThread::Stop() { |
88 impl_->Stop(); | 88 impl_->Stop(); |
89 } | 89 } |
90 | 90 |
91 bool TestBrowserThread::IsRunning() { | 91 bool TestBrowserThread::IsRunning() { |
92 return impl_->IsRunning(); | 92 return impl_->IsRunning(); |
93 } | 93 } |
94 | 94 |
95 } // namespace content | 95 } // namespace content |
OLD | NEW |