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" |
11 #include "content/browser/notification_service_impl.h" | 11 #include "content/browser/notification_service_impl.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 class TestBrowserThreadImpl : public BrowserThreadImpl { | 15 class TestBrowserThreadImpl : public BrowserThreadImpl { |
16 public: | 16 public: |
17 explicit TestBrowserThreadImpl(BrowserThread::ID identifier) | 17 explicit TestBrowserThreadImpl(BrowserThread::ID identifier) |
18 : BrowserThreadImpl(identifier), | 18 : BrowserThreadImpl(identifier) {} |
19 notification_service_(NULL) { | |
20 } | |
21 | 19 |
22 TestBrowserThreadImpl(BrowserThread::ID identifier, | 20 TestBrowserThreadImpl(BrowserThread::ID identifier, |
23 base::MessageLoop* message_loop) | 21 base::MessageLoop* message_loop) |
24 : BrowserThreadImpl(identifier, message_loop), | 22 : BrowserThreadImpl(identifier, message_loop) {} |
25 notification_service_(NULL) {} | |
26 | 23 |
27 ~TestBrowserThreadImpl() override { Stop(); } | 24 ~TestBrowserThreadImpl() override { Stop(); } |
28 | 25 |
29 void Init() override { | 26 void Init() override { |
30 notification_service_ = new NotificationServiceImpl; | 27 notification_service_.reset(new NotificationServiceImpl); |
31 BrowserThreadImpl::Init(); | 28 BrowserThreadImpl::Init(); |
32 } | 29 } |
33 | 30 |
34 void CleanUp() override { | 31 void CleanUp() override { |
35 delete notification_service_; | 32 notification_service_.reset(); |
36 notification_service_ = NULL; | |
37 BrowserThreadImpl::CleanUp(); | 33 BrowserThreadImpl::CleanUp(); |
38 } | 34 } |
39 | 35 |
40 private: | 36 private: |
41 NotificationService* notification_service_; | 37 std::unique_ptr<NotificationService> notification_service_; |
42 | 38 |
43 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadImpl); | 39 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadImpl); |
44 }; | 40 }; |
45 | 41 |
46 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier) | 42 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier) |
47 : impl_(new TestBrowserThreadImpl(identifier)) { | 43 : impl_(new TestBrowserThreadImpl(identifier)) { |
48 } | 44 } |
49 | 45 |
50 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier, | 46 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier, |
51 base::MessageLoop* message_loop) | 47 base::MessageLoop* message_loop) |
(...skipping 18 matching lines...) Expand all Loading... |
70 } | 66 } |
71 | 67 |
72 void TestBrowserThread::Stop() { | 68 void TestBrowserThread::Stop() { |
73 impl_->Stop(); | 69 impl_->Stop(); |
74 } | 70 } |
75 | 71 |
76 bool TestBrowserThread::IsRunning() { | 72 bool TestBrowserThread::IsRunning() { |
77 return impl_->IsRunning(); | 73 return impl_->IsRunning(); |
78 } | 74 } |
79 | 75 |
80 base::Thread* TestBrowserThread::DeprecatedGetThreadObject() { | |
81 return impl_.get(); | |
82 } | |
83 | |
84 } // namespace content | 76 } // namespace content |
OLD | NEW |