Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: content/public/test/test_browser_thread.cc

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/public/test/render_view_test.cc ('k') | content/public/test/test_renderer_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/threading/thread.h" 8 #include "base/threading/thread.h"
9 #include "content/browser/browser_thread_impl.h" 9 #include "content/browser/browser_thread_impl.h"
10 #include "content/browser/notification_service_impl.h" 10 #include "content/browser/notification_service_impl.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 class TestBrowserThreadImpl : public BrowserThreadImpl { 14 class TestBrowserThreadImpl : public BrowserThreadImpl {
15 public: 15 public:
16 explicit TestBrowserThreadImpl(BrowserThread::ID identifier) 16 explicit TestBrowserThreadImpl(BrowserThread::ID identifier)
17 : BrowserThreadImpl(identifier), 17 : BrowserThreadImpl(identifier),
18 notification_service_(NULL) { 18 notification_service_(NULL) {
19 } 19 }
20 20
21 TestBrowserThreadImpl(BrowserThread::ID identifier, 21 TestBrowserThreadImpl(BrowserThread::ID identifier,
22 MessageLoop* message_loop) 22 base::MessageLoop* message_loop)
23 : BrowserThreadImpl(identifier, message_loop), 23 : BrowserThreadImpl(identifier, message_loop),
24 notification_service_(NULL) { 24 notification_service_(NULL) {}
25 }
26 25
27 virtual ~TestBrowserThreadImpl() { 26 virtual ~TestBrowserThreadImpl() {
28 Stop(); 27 Stop();
29 } 28 }
30 29
31 virtual void Init() OVERRIDE { 30 virtual void Init() OVERRIDE {
32 notification_service_ = new NotificationServiceImpl; 31 notification_service_ = new NotificationServiceImpl;
33 BrowserThreadImpl::Init(); 32 BrowserThreadImpl::Init();
34 } 33 }
35 34
36 virtual void CleanUp() OVERRIDE { 35 virtual void CleanUp() OVERRIDE {
37 delete notification_service_; 36 delete notification_service_;
38 notification_service_ = NULL; 37 notification_service_ = NULL;
39 BrowserThreadImpl::CleanUp(); 38 BrowserThreadImpl::CleanUp();
40 } 39 }
41 40
42 private: 41 private:
43 NotificationService* notification_service_; 42 NotificationService* notification_service_;
44 43
45 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadImpl); 44 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadImpl);
46 }; 45 };
47 46
48 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier) 47 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier)
49 : impl_(new TestBrowserThreadImpl(identifier)) { 48 : impl_(new TestBrowserThreadImpl(identifier)) {
50 } 49 }
51 50
52 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier, 51 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier,
53 MessageLoop* message_loop) 52 base::MessageLoop* message_loop)
54 : impl_(new TestBrowserThreadImpl(identifier, message_loop)) { 53 : impl_(new TestBrowserThreadImpl(identifier, message_loop)) {}
55 }
56 54
57 TestBrowserThread::~TestBrowserThread() { 55 TestBrowserThread::~TestBrowserThread() {
58 Stop(); 56 Stop();
59 } 57 }
60 58
61 bool TestBrowserThread::Start() { 59 bool TestBrowserThread::Start() {
62 return impl_->Start(); 60 return impl_->Start();
63 } 61 }
64 62
65 bool TestBrowserThread::StartIOThread() { 63 bool TestBrowserThread::StartIOThread() {
66 base::Thread::Options options; 64 base::Thread::Options options;
67 options.message_loop_type = MessageLoop::TYPE_IO; 65 options.message_loop_type = base::MessageLoop::TYPE_IO;
68 return impl_->StartWithOptions(options); 66 return impl_->StartWithOptions(options);
69 } 67 }
70 68
71 void TestBrowserThread::Stop() { 69 void TestBrowserThread::Stop() {
72 impl_->Stop(); 70 impl_->Stop();
73 } 71 }
74 72
75 bool TestBrowserThread::IsRunning() { 73 bool TestBrowserThread::IsRunning() {
76 return impl_->IsRunning(); 74 return impl_->IsRunning();
77 } 75 }
78 76
79 base::Thread* TestBrowserThread::DeprecatedGetThreadObject() { 77 base::Thread* TestBrowserThread::DeprecatedGetThreadObject() {
80 return impl_.get(); 78 return impl_.get();
81 } 79 }
82 80
83 } // namespace content 81 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/render_view_test.cc ('k') | content/public/test/test_renderer_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698