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

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

Issue 10068037: RefCounted types should not have public destructors, content/browser part 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MSVC fixes Created 8 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
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 "content/browser/browser_thread_impl.h" 11 #include "content/browser/browser_thread_impl.h"
11 #include "content/test/test_browser_thread.h" 12 #include "content/test/test_browser_thread.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/platform_test.h" 14 #include "testing/platform_test.h"
14 15
15 namespace content { 16 namespace content {
16 17
17 class BrowserThreadTest : public testing::Test { 18 class BrowserThreadTest : public testing::Test {
18 public: 19 public:
19 void Release() const { 20 void Release() const {
(...skipping 19 matching lines...) Expand all
39 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 40 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure());
40 } 41 }
41 42
42 class DeletedOnFile 43 class DeletedOnFile
43 : public base::RefCountedThreadSafe< 44 : public base::RefCountedThreadSafe<
44 DeletedOnFile, BrowserThread::DeleteOnFileThread> { 45 DeletedOnFile, BrowserThread::DeleteOnFileThread> {
45 public: 46 public:
46 explicit DeletedOnFile(MessageLoop* message_loop) 47 explicit DeletedOnFile(MessageLoop* message_loop)
47 : message_loop_(message_loop) { } 48 : message_loop_(message_loop) { }
48 49
50 private:
51 friend struct BrowserThread::DeleteOnThread<BrowserThread::FILE>;
52 friend class base::DeleteHelper<DeletedOnFile>;
53
49 ~DeletedOnFile() { 54 ~DeletedOnFile() {
50 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 55 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
51 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 56 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
52 } 57 }
53 58
54 private:
55 MessageLoop* message_loop_; 59 MessageLoop* message_loop_;
56 }; 60 };
57 61
58 class NeverDeleted 62 class NeverDeleted
59 : public base::RefCountedThreadSafe< 63 : public base::RefCountedThreadSafe<
60 NeverDeleted, BrowserThread::DeleteOnWebKitThread> { 64 NeverDeleted, BrowserThread::DeleteOnWebKitThread> {
61 public: 65 public:
66
67 private:
68 friend struct BrowserThread::DeleteOnThread<
69 BrowserThread::WEBKIT_DEPRECATED>;
70 friend class base::DeleteHelper<NeverDeleted>;
71
62 ~NeverDeleted() { 72 ~NeverDeleted() {
63 CHECK(false); 73 CHECK(false);
64 } 74 }
65 }; 75 };
66 76
67 private: 77 private:
68 scoped_ptr<BrowserThreadImpl> ui_thread_; 78 scoped_ptr<BrowserThreadImpl> ui_thread_;
69 scoped_ptr<BrowserThreadImpl> file_thread_; 79 scoped_ptr<BrowserThreadImpl> file_thread_;
70 // It's kind of ugly to make this mutable - solely so we can post the Quit 80 // It's kind of ugly to make this mutable - solely so we can post the Quit
71 // Task from Release(). This should be fixed. 81 // Task from Release(). This should be fixed.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 ASSERT_TRUE(BrowserThread::PostTaskAndReply( 127 ASSERT_TRUE(BrowserThread::PostTaskAndReply(
118 BrowserThread::FILE, 128 BrowserThread::FILE,
119 FROM_HERE, 129 FROM_HERE,
120 base::Bind(&base::DoNothing), 130 base::Bind(&base::DoNothing),
121 base::Bind(&MessageLoop::Quit, 131 base::Bind(&MessageLoop::Quit,
122 base::Unretained(MessageLoop::current()->current())))); 132 base::Unretained(MessageLoop::current()->current()))));
123 MessageLoop::current()->Run(); 133 MessageLoop::current()->Run();
124 } 134 }
125 135
126 } 136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698