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

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

Issue 3971004: Revert "Revert "Const-ify RefCountedThreadSafe::AddRef and Release."" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 2 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 | « chrome/browser/browser_thread.h ('k') | chrome/browser/chrome_plugin_unittest.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/message_loop_proxy.h" 6 #include "base/message_loop_proxy.h"
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "chrome/browser/browser_thread.h" 8 #include "chrome/browser/browser_thread.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h" 10 #include "testing/platform_test.h"
11 11
12 class BrowserThreadTest : public testing::Test { 12 class BrowserThreadTest : public testing::Test {
13 public: 13 public:
14 void Release() { 14 void Release() const {
15 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 15 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
16 loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask); 16 loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask);
17 } 17 }
18 18
19 protected: 19 protected:
20 virtual void SetUp() { 20 virtual void SetUp() {
21 ui_thread_.reset(new BrowserThread(BrowserThread::UI)); 21 ui_thread_.reset(new BrowserThread(BrowserThread::UI));
22 file_thread_.reset(new BrowserThread(BrowserThread::FILE)); 22 file_thread_.reset(new BrowserThread(BrowserThread::FILE));
23 ui_thread_->Start(); 23 ui_thread_->Start();
24 file_thread_->Start(); 24 file_thread_->Start();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 NeverDeleted, BrowserThread::DeleteOnWebKitThread> { 70 NeverDeleted, BrowserThread::DeleteOnWebKitThread> {
71 public: 71 public:
72 ~NeverDeleted() { 72 ~NeverDeleted() {
73 CHECK(false); 73 CHECK(false);
74 } 74 }
75 }; 75 };
76 76
77 private: 77 private:
78 scoped_ptr<BrowserThread> ui_thread_; 78 scoped_ptr<BrowserThread> ui_thread_;
79 scoped_ptr<BrowserThread> file_thread_; 79 scoped_ptr<BrowserThread> file_thread_;
80 MessageLoop loop_; 80 // It's kind of ugly to make this mutable - solely so we can post the Quit
81 // Task from Release(). This should be fixed.
82 mutable MessageLoop loop_;
81 }; 83 };
82 84
83 TEST_F(BrowserThreadTest, PostTask) { 85 TEST_F(BrowserThreadTest, PostTask) {
84 BrowserThread::PostTask( 86 BrowserThread::PostTask(
85 BrowserThread::FILE, FROM_HERE, 87 BrowserThread::FILE, FROM_HERE,
86 NewRunnableFunction(&BasicFunction, MessageLoop::current())); 88 NewRunnableFunction(&BasicFunction, MessageLoop::current()));
87 MessageLoop::current()->Run(); 89 MessageLoop::current()->Run();
88 } 90 }
89 91
90 TEST_F(BrowserThreadTest, Release) { 92 TEST_F(BrowserThreadTest, Release) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 io_thread->Start(); 157 io_thread->Start();
156 } 158 }
157 bool deleted = false; 159 bool deleted = false;
158 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = 160 scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
159 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 161 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
160 bool ret = message_loop_proxy->PostTask(FROM_HERE, new DummyTask(&deleted)); 162 bool ret = message_loop_proxy->PostTask(FROM_HERE, new DummyTask(&deleted));
161 EXPECT_FALSE(ret); 163 EXPECT_FALSE(ret);
162 EXPECT_TRUE(deleted); 164 EXPECT_TRUE(deleted);
163 } 165 }
164 166
OLDNEW
« no previous file with comments | « chrome/browser/browser_thread.h ('k') | chrome/browser/chrome_plugin_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698