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 22 matching lines...) Expand all Loading... |
33 BrowserThreadImpl::CleanUp(); | 33 BrowserThreadImpl::CleanUp(); |
34 } | 34 } |
35 | 35 |
36 private: | 36 private: |
37 std::unique_ptr<NotificationService> notification_service_; | 37 std::unique_ptr<NotificationService> notification_service_; |
38 | 38 |
39 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadImpl); | 39 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadImpl); |
40 }; | 40 }; |
41 | 41 |
42 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier) | 42 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier) |
43 : impl_(new TestBrowserThreadImpl(identifier)) { | 43 : impl_(new TestBrowserThreadImpl(identifier)), identifier_(identifier) {} |
44 } | |
45 | 44 |
46 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier, | 45 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier, |
47 base::MessageLoop* message_loop) | 46 base::MessageLoop* message_loop) |
48 : impl_(new TestBrowserThreadImpl(identifier, message_loop)) {} | 47 : impl_(new TestBrowserThreadImpl(identifier, message_loop)), |
| 48 identifier_(identifier) {} |
49 | 49 |
50 TestBrowserThread::~TestBrowserThread() { | 50 TestBrowserThread::~TestBrowserThread() { |
51 Stop(); | 51 Stop(); |
| 52 impl_.reset(); |
| 53 BrowserThreadImpl::ResetGlobalsForTesting(identifier_); |
52 } | 54 } |
53 | 55 |
54 bool TestBrowserThread::Start() { | 56 bool TestBrowserThread::Start() { |
55 return impl_->Start(); | 57 return impl_->Start(); |
56 } | 58 } |
57 | 59 |
58 bool TestBrowserThread::StartAndWaitForTesting() { | 60 bool TestBrowserThread::StartAndWaitForTesting() { |
59 return impl_->StartAndWaitForTesting(); | 61 return impl_->StartAndWaitForTesting(); |
60 } | 62 } |
61 | 63 |
62 bool TestBrowserThread::StartIOThread() { | 64 bool TestBrowserThread::StartIOThread() { |
63 base::Thread::Options options; | 65 base::Thread::Options options; |
64 options.message_loop_type = base::MessageLoop::TYPE_IO; | 66 options.message_loop_type = base::MessageLoop::TYPE_IO; |
65 return impl_->StartWithOptions(options); | 67 return impl_->StartWithOptions(options); |
66 } | 68 } |
67 | 69 |
68 void TestBrowserThread::Stop() { | 70 void TestBrowserThread::Stop() { |
69 impl_->Stop(); | 71 impl_->Stop(); |
70 } | 72 } |
71 | 73 |
72 bool TestBrowserThread::IsRunning() { | 74 bool TestBrowserThread::IsRunning() { |
73 return impl_->IsRunning(); | 75 return impl_->IsRunning(); |
74 } | 76 } |
75 | 77 |
76 } // namespace content | 78 } // namespace content |
OLD | NEW |