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

Side by Side Diff: content/browser/browser_thread_unittest.cc

Issue 13168005: Cleanup: Remove unused content::BrowserThread::DeleteOnWebKitThread. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 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 | « no previous file | content/public/browser/browser_thread.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/sequenced_task_runner_helpers.h" 10 #include "base/sequenced_task_runner_helpers.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 friend class base::DeleteHelper<DeletedOnFile>; 52 friend class base::DeleteHelper<DeletedOnFile>;
53 53
54 ~DeletedOnFile() { 54 ~DeletedOnFile() {
55 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 55 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
56 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 56 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
57 } 57 }
58 58
59 MessageLoop* message_loop_; 59 MessageLoop* message_loop_;
60 }; 60 };
61 61
62 class NeverDeleted
63 : public base::RefCountedThreadSafe<
64 NeverDeleted, BrowserThread::DeleteOnWebKitThread> {
65 public:
66
67 private:
68 friend struct BrowserThread::DeleteOnThread<
69 BrowserThread::WEBKIT_DEPRECATED>;
70 friend class base::DeleteHelper<NeverDeleted>;
71
72 ~NeverDeleted() {
73 CHECK(false);
74 }
75 };
76
77 private: 62 private:
78 scoped_ptr<BrowserThreadImpl> ui_thread_; 63 scoped_ptr<BrowserThreadImpl> ui_thread_;
79 scoped_ptr<BrowserThreadImpl> file_thread_; 64 scoped_ptr<BrowserThreadImpl> file_thread_;
80 // It's kind of ugly to make this mutable - solely so we can post the Quit 65 // It's kind of ugly to make this mutable - solely so we can post the Quit
81 // Task from Release(). This should be fixed. 66 // Task from Release(). This should be fixed.
82 mutable MessageLoop loop_; 67 mutable MessageLoop loop_;
83 }; 68 };
84 69
85 TEST_F(BrowserThreadTest, PostTask) { 70 TEST_F(BrowserThreadTest, PostTask) {
86 BrowserThread::PostTask( 71 BrowserThread::PostTask(
87 BrowserThread::FILE, FROM_HERE, 72 BrowserThread::FILE, FROM_HERE,
88 base::Bind(&BasicFunction, MessageLoop::current())); 73 base::Bind(&BasicFunction, MessageLoop::current()));
89 MessageLoop::current()->Run(); 74 MessageLoop::current()->Run();
90 } 75 }
91 76
92 TEST_F(BrowserThreadTest, Release) { 77 TEST_F(BrowserThreadTest, Release) {
93 BrowserThread::ReleaseSoon(BrowserThread::UI, FROM_HERE, this); 78 BrowserThread::ReleaseSoon(BrowserThread::UI, FROM_HERE, this);
94 MessageLoop::current()->Run(); 79 MessageLoop::current()->Run();
95 } 80 }
96 81
97 TEST_F(BrowserThreadTest, ReleasedOnCorrectThread) { 82 TEST_F(BrowserThreadTest, ReleasedOnCorrectThread) {
98 { 83 {
99 scoped_refptr<DeletedOnFile> test( 84 scoped_refptr<DeletedOnFile> test(
100 new DeletedOnFile(MessageLoop::current())); 85 new DeletedOnFile(MessageLoop::current()));
101 } 86 }
102 MessageLoop::current()->Run(); 87 MessageLoop::current()->Run();
103 } 88 }
104 89
105 TEST_F(BrowserThreadTest, NotReleasedIfTargetThreadNonExistent) {
106 scoped_refptr<NeverDeleted> test(new NeverDeleted());
107 }
108
109 TEST_F(BrowserThreadTest, PostTaskViaMessageLoopProxy) { 90 TEST_F(BrowserThreadTest, PostTaskViaMessageLoopProxy) {
110 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = 91 scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
111 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); 92 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE);
112 message_loop_proxy->PostTask( 93 message_loop_proxy->PostTask(
113 FROM_HERE, base::Bind(&BasicFunction, MessageLoop::current())); 94 FROM_HERE, base::Bind(&BasicFunction, MessageLoop::current()));
114 MessageLoop::current()->Run(); 95 MessageLoop::current()->Run();
115 } 96 }
116 97
117 TEST_F(BrowserThreadTest, ReleaseViaMessageLoopProxy) { 98 TEST_F(BrowserThreadTest, ReleaseViaMessageLoopProxy) {
118 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = 99 scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
119 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); 100 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
120 message_loop_proxy->ReleaseSoon(FROM_HERE, this); 101 message_loop_proxy->ReleaseSoon(FROM_HERE, this);
121 MessageLoop::current()->Run(); 102 MessageLoop::current()->Run();
122 } 103 }
123 104
124 TEST_F(BrowserThreadTest, PostTaskAndReply) { 105 TEST_F(BrowserThreadTest, PostTaskAndReply) {
125 // Most of the heavy testing for PostTaskAndReply() is done inside the 106 // Most of the heavy testing for PostTaskAndReply() is done inside the
126 // MessageLoopProxy test. This just makes sure we get piped through at all. 107 // MessageLoopProxy test. This just makes sure we get piped through at all.
127 ASSERT_TRUE(BrowserThread::PostTaskAndReply( 108 ASSERT_TRUE(BrowserThread::PostTaskAndReply(
128 BrowserThread::FILE, 109 BrowserThread::FILE,
129 FROM_HERE, 110 FROM_HERE,
130 base::Bind(&base::DoNothing), 111 base::Bind(&base::DoNothing),
131 base::Bind(&MessageLoop::Quit, 112 base::Bind(&MessageLoop::Quit,
132 base::Unretained(MessageLoop::current()->current())))); 113 base::Unretained(MessageLoop::current()->current()))));
133 MessageLoop::current()->Run(); 114 MessageLoop::current()->Run();
134 } 115 }
135 116
136 } 117 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/public/browser/browser_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698