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

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

Issue 9419033: Move creation of BrowserContext objects that live in content to content, instead of depending on th… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fix memory leaks in tests Created 8 years, 10 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/test/test_browser_context.cc ('k') | webkit/appcache/appcache_storage_impl.cc » ('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/test/test_browser_thread.h" 5 #include "content/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 11
11 namespace content { 12 namespace content {
12 13
13 // This gives access to set_message_loop(). 14 // This gives access to set_message_loop().
14 class TestBrowserThreadImpl : public BrowserThreadImpl { 15 class TestBrowserThreadImpl : public BrowserThreadImpl {
15 public: 16 public:
16 explicit TestBrowserThreadImpl(BrowserThread::ID identifier) 17 explicit TestBrowserThreadImpl(BrowserThread::ID identifier)
17 : BrowserThreadImpl(identifier) { 18 : BrowserThreadImpl(identifier),
19 notification_service_(NULL) {
18 } 20 }
19 21
20 TestBrowserThreadImpl(BrowserThread::ID identifier, 22 TestBrowserThreadImpl(BrowserThread::ID identifier,
21 MessageLoop* message_loop) 23 MessageLoop* message_loop)
22 : BrowserThreadImpl(identifier, message_loop) { 24 : BrowserThreadImpl(identifier, message_loop),
25 notification_service_(NULL) {
23 } 26 }
24 27
25 virtual ~TestBrowserThreadImpl() { 28 virtual ~TestBrowserThreadImpl() {
26 Stop(); 29 Stop();
27 } 30 }
28 31
29 void set_message_loop(MessageLoop* loop) { 32 void set_message_loop(MessageLoop* loop) {
30 Thread::set_message_loop(loop); 33 Thread::set_message_loop(loop);
31 } 34 }
32 35
36 virtual void Init() OVERRIDE {
37 notification_service_ = new NotificationServiceImpl;
38 BrowserThreadImpl::Init();
39 }
40
41 virtual void CleanUp() OVERRIDE {
42 delete notification_service_;
43 notification_service_ = NULL;
44 BrowserThreadImpl::CleanUp();
45 }
46
33 private: 47 private:
48 NotificationService* notification_service_;
34 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadImpl); 49 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadImpl);
35 }; 50 };
36 51
37 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier) 52 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier)
38 : impl_(new TestBrowserThreadImpl(identifier)) { 53 : impl_(new TestBrowserThreadImpl(identifier)) {
39 } 54 }
40 55
41 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier, 56 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier,
42 MessageLoop* message_loop) 57 MessageLoop* message_loop)
43 : impl_(new TestBrowserThreadImpl(identifier, message_loop)) { 58 : impl_(new TestBrowserThreadImpl(identifier, message_loop)) {
(...skipping 23 matching lines...) Expand all
67 82
68 base::Thread* TestBrowserThread::DeprecatedGetThreadObject() { 83 base::Thread* TestBrowserThread::DeprecatedGetThreadObject() {
69 return impl_.get(); 84 return impl_.get();
70 } 85 }
71 86
72 void TestBrowserThread::DeprecatedSetMessageLoop(MessageLoop* loop) { 87 void TestBrowserThread::DeprecatedSetMessageLoop(MessageLoop* loop) {
73 impl_->set_message_loop(loop); 88 impl_->set_message_loop(loop);
74 } 89 }
75 90
76 } // namespace content 91 } // namespace content
OLDNEW
« no previous file with comments | « content/test/test_browser_context.cc ('k') | webkit/appcache/appcache_storage_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698