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

Unified Diff: mojo/edk/system/dispatcher_unittest.cc

Issue 1412283002: Convert mojo::system::Dispatcher to use our new refcounting stuff (instead of base's). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: no change Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/dispatcher.cc ('k') | mojo/edk/system/handle_table.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/dispatcher_unittest.cc
diff --git a/mojo/edk/system/dispatcher_unittest.cc b/mojo/edk/system/dispatcher_unittest.cc
index 47c7de9bb7bb06262b4b692e961f28a732bc3543..827b1f41ab8b66f7eb2f4916212f2fb8e47e34ce 100644
--- a/mojo/edk/system/dispatcher_unittest.cc
+++ b/mojo/edk/system/dispatcher_unittest.cc
@@ -7,10 +7,10 @@
#include <memory>
#include <vector>
-#include "base/memory/ref_counted.h"
#include "base/synchronization/waitable_event.h"
#include "mojo/edk/embedder/platform_shared_buffer.h"
#include "mojo/edk/system/memory.h"
+#include "mojo/edk/system/ref_ptr.h"
#include "mojo/edk/system/waiter.h"
#include "mojo/edk/test/simple_test_thread.h"
#include "mojo/edk/util/make_unique.h"
@@ -24,24 +24,26 @@ namespace {
// Trivial subclass that makes the constructor public.
class TrivialDispatcher final : public Dispatcher {
public:
- TrivialDispatcher() {}
+ // Note: Use |MakeRefCounted<TrivialDispatcher>()|.
Type GetType() const override { return Type::UNKNOWN; }
private:
+ FRIEND_MAKE_REF_COUNTED(TrivialDispatcher);
+
+ TrivialDispatcher() {}
~TrivialDispatcher() override {}
- scoped_refptr<Dispatcher> CreateEquivalentDispatcherAndCloseImplNoLock()
- override {
+ RefPtr<Dispatcher> CreateEquivalentDispatcherAndCloseImplNoLock() override {
mutex().AssertHeld();
- return scoped_refptr<Dispatcher>(new TrivialDispatcher());
+ return AdoptRef(new TrivialDispatcher());
}
MOJO_DISALLOW_COPY_AND_ASSIGN(TrivialDispatcher);
};
TEST(DispatcherTest, Basic) {
- scoped_refptr<Dispatcher> d(new TrivialDispatcher());
+ auto d = MakeRefCounted<TrivialDispatcher>();
EXPECT_EQ(Dispatcher::Type::UNKNOWN, d->GetType());
@@ -135,7 +137,7 @@ class ThreadSafetyStressThread : public mojo::test::SimpleTestThread {
};
ThreadSafetyStressThread(base::WaitableEvent* event,
- scoped_refptr<Dispatcher> dispatcher,
+ RefPtr<Dispatcher> dispatcher,
DispatcherOp op)
: event_(event), dispatcher_(dispatcher), op_(op) {
CHECK_LE(0, op_);
@@ -196,7 +198,7 @@ class ThreadSafetyStressThread : public mojo::test::SimpleTestThread {
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, dispatcher_->EndReadData(0));
break;
case DUPLICATE_BUFFER_HANDLE: {
- scoped_refptr<Dispatcher> unused;
+ RefPtr<Dispatcher> unused;
EXPECT_EQ(
MOJO_RESULT_INVALID_ARGUMENT,
dispatcher_->DuplicateBufferHandle(NullUserPointer(), &unused));
@@ -239,7 +241,7 @@ class ThreadSafetyStressThread : public mojo::test::SimpleTestThread {
}
base::WaitableEvent* const event_;
- const scoped_refptr<Dispatcher> dispatcher_;
+ const RefPtr<Dispatcher> dispatcher_;
const DispatcherOp op_;
Waiter waiter_;
@@ -254,7 +256,7 @@ TEST(DispatcherTest, ThreadSafetyStress) {
for (size_t i = 0; i < kRepeatCount; i++) {
// Manual reset, not initially signalled.
base::WaitableEvent event(true, false);
- scoped_refptr<Dispatcher> d(new TrivialDispatcher());
+ auto d = MakeRefCounted<TrivialDispatcher>();
{
std::vector<std::unique_ptr<ThreadSafetyStressThread>> threads;
@@ -282,7 +284,7 @@ TEST(DispatcherTest, ThreadSafetyStressNoClose) {
for (size_t i = 0; i < kRepeatCount; i++) {
// Manual reset, not initially signalled.
base::WaitableEvent event(true, false);
- scoped_refptr<Dispatcher> d(new TrivialDispatcher());
+ auto d = MakeRefCounted<TrivialDispatcher>();
{
std::vector<std::unique_ptr<ThreadSafetyStressThread>> threads;
« no previous file with comments | « mojo/edk/system/dispatcher.cc ('k') | mojo/edk/system/handle_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698