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

Side by Side Diff: base/message_loop_unittest.cc

Issue 360042: First patch in making destructors of refcounted objects private. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/logging.h" 5 #include "base/logging.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/platform_thread.h" 7 #include "base/platform_thread.h"
8 #include "base/ref_counted.h" 8 #include "base/ref_counted.h"
9 #include "base/thread.h" 9 #include "base/thread.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 void Test2Mixed(const std::string& a, std::string* b) { 60 void Test2Mixed(const std::string& a, std::string* b) {
61 ++test_count_; 61 ++test_count_;
62 result_.append(a); 62 result_.append(a);
63 result_.append(*b); 63 result_.append(*b);
64 } 64 }
65 65
66 int test_count() const { return test_count_; } 66 int test_count() const { return test_count_; }
67 const std::string& result() const { return result_; } 67 const std::string& result() const { return result_; }
68 68
69 private: 69 private:
70 friend class base::RefCounted<Foo>;
71
72 ~Foo() {}
73
70 int test_count_; 74 int test_count_;
71 std::string result_; 75 std::string result_;
72 }; 76 };
73 77
74 class QuitMsgLoop : public base::RefCounted<QuitMsgLoop> { 78 class QuitMsgLoop : public base::RefCounted<QuitMsgLoop> {
75 public: 79 public:
76 void QuitNow() { 80 void QuitNow() {
77 MessageLoop::current()->Quit(); 81 MessageLoop::current()->Quit();
78 } 82 }
83
84 private:
85 friend class base::RefCounted<QuitMsgLoop>;
86
87 ~QuitMsgLoop() {}
79 }; 88 };
80 89
81 void RunTest_PostTask(MessageLoop::Type message_loop_type) { 90 void RunTest_PostTask(MessageLoop::Type message_loop_type) {
82 MessageLoop loop(message_loop_type); 91 MessageLoop loop(message_loop_type);
83 92
84 // Add tests to message loop 93 // Add tests to message loop
85 scoped_refptr<Foo> foo = new Foo(); 94 scoped_refptr<Foo> foo = new Foo();
86 std::string a("a"), b("b"), c("c"), d("d"); 95 std::string a("a"), b("b"), c("c"), d("d");
87 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 96 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
88 foo.get(), &Foo::Test0)); 97 foo.get(), &Foo::Test0));
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 message_loop.WatchFileDescriptor(fd, 1496 message_loop.WatchFileDescriptor(fd,
1488 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate); 1497 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate);
1489 controller.StopWatchingFileDescriptor(); 1498 controller.StopWatchingFileDescriptor();
1490 } 1499 }
1491 } 1500 }
1492 close(pipefds[0]); 1501 close(pipefds[0]);
1493 close(pipefds[1]); 1502 close(pipefds[1]);
1494 } 1503 }
1495 1504
1496 #endif // defined(OS_LINUX) 1505 #endif // defined(OS_LINUX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698