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

Unified Diff: mojo/edk/system/data_pipe_impl_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/data_pipe_consumer_dispatcher.cc ('k') | mojo/edk/system/data_pipe_producer_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/data_pipe_impl_unittest.cc
diff --git a/mojo/edk/system/data_pipe_impl_unittest.cc b/mojo/edk/system/data_pipe_impl_unittest.cc
index c3c30dcc124bdad4ac4fdcd582a8f480e3596ade..42a02c4bf92bf6a596cba6b8b09b9071f1a86dfe 100644
--- a/mojo/edk/system/data_pipe_impl_unittest.cc
+++ b/mojo/edk/system/data_pipe_impl_unittest.cc
@@ -255,8 +255,8 @@ class RemoteDataPipeImplTestHelper : public DataPipeImplTestHelper {
protected:
void SendDispatcher(size_t source_i,
- scoped_refptr<Dispatcher> to_send,
- scoped_refptr<Dispatcher>* to_receive) {
+ RefPtr<Dispatcher> to_send,
+ RefPtr<Dispatcher>* to_receive) {
DCHECK(source_i == 0 || source_i == 1);
size_t dest_i = source_i ^ 1;
@@ -301,7 +301,7 @@ class RemoteDataPipeImplTestHelper : public DataPipeImplTestHelper {
ASSERT_EQ(1u, read_dispatchers.size());
ASSERT_EQ(1u, read_num_dispatchers);
ASSERT_TRUE(read_dispatchers[0]);
- EXPECT_TRUE(read_dispatchers[0]->HasOneRef());
+ read_dispatchers[0]->AssertHasOneRef();
*to_receive = read_dispatchers[0];
}
@@ -368,19 +368,18 @@ class RemoteProducerDataPipeImplTestHelper
void DoTransfer() override {
// This is the producer dispatcher we'll send.
- scoped_refptr<DataPipeProducerDispatcher> to_send =
- DataPipeProducerDispatcher::Create();
+ auto to_send = DataPipeProducerDispatcher::Create();
to_send->Init(dp());
- scoped_refptr<Dispatcher> to_receive;
+ RefPtr<Dispatcher> to_receive;
SendDispatcher(0, to_send, &to_receive);
// |to_send| should have been closed. This is |DCHECK()|ed when it is
// destroyed.
- EXPECT_TRUE(to_send->HasOneRef());
+ to_send->AssertHasOneRef();
to_send = nullptr;
ASSERT_EQ(Dispatcher::Type::DATA_PIPE_PRODUCER, to_receive->GetType());
- producer_dispatcher_ =
- static_cast<DataPipeProducerDispatcher*>(to_receive.get());
+ producer_dispatcher_ = RefPtr<DataPipeProducerDispatcher>(
+ static_cast<DataPipeProducerDispatcher*>(to_receive.get()));
}
DataPipe* DataPipeForProducer() override {
@@ -399,7 +398,7 @@ class RemoteProducerDataPipeImplTestHelper
void ConsumerClose() override { dp()->ConsumerClose(); }
protected:
- scoped_refptr<DataPipeProducerDispatcher> producer_dispatcher_;
+ RefPtr<DataPipeProducerDispatcher> producer_dispatcher_;
private:
MOJO_DISALLOW_COPY_AND_ASSIGN(RemoteProducerDataPipeImplTestHelper);
@@ -418,19 +417,18 @@ class RemoteConsumerDataPipeImplTestHelper
void DoTransfer() override {
// This is the consumer dispatcher we'll send.
- scoped_refptr<DataPipeConsumerDispatcher> to_send =
- DataPipeConsumerDispatcher::Create();
+ auto to_send = DataPipeConsumerDispatcher::Create();
to_send->Init(dp());
- scoped_refptr<Dispatcher> to_receive;
+ RefPtr<Dispatcher> to_receive;
SendDispatcher(0, to_send, &to_receive);
// |to_send| should have been closed. This is |DCHECK()|ed when it is
// destroyed.
- EXPECT_TRUE(to_send->HasOneRef());
+ to_send->AssertHasOneRef();
to_send = nullptr;
ASSERT_EQ(Dispatcher::Type::DATA_PIPE_CONSUMER, to_receive->GetType());
- consumer_dispatcher_ =
- static_cast<DataPipeConsumerDispatcher*>(to_receive.get());
+ consumer_dispatcher_ = RefPtr<DataPipeConsumerDispatcher>(
+ static_cast<DataPipeConsumerDispatcher*>(to_receive.get()));
}
DataPipe* DataPipeForProducer() override { return dp().get(); }
@@ -449,7 +447,7 @@ class RemoteConsumerDataPipeImplTestHelper
}
protected:
- scoped_refptr<DataPipeConsumerDispatcher> consumer_dispatcher_;
+ RefPtr<DataPipeConsumerDispatcher> consumer_dispatcher_;
private:
MOJO_DISALLOW_COPY_AND_ASSIGN(RemoteConsumerDataPipeImplTestHelper);
@@ -473,29 +471,29 @@ class RemoteProducerDataPipeImplTestHelper2
void DoTransfer() override {
// This is the producer dispatcher we'll send.
- scoped_refptr<DataPipeProducerDispatcher> to_send =
- DataPipeProducerDispatcher::Create();
+ auto to_send = DataPipeProducerDispatcher::Create();
to_send->Init(dp());
- scoped_refptr<Dispatcher> to_receive;
+ RefPtr<Dispatcher> to_receive;
SendDispatcher(0, to_send, &to_receive);
// |to_send| should have been closed. This is |DCHECK()|ed when it is
// destroyed.
- EXPECT_TRUE(to_send->HasOneRef());
+ to_send->AssertHasOneRef();
to_send = nullptr;
ASSERT_EQ(Dispatcher::Type::DATA_PIPE_PRODUCER, to_receive->GetType());
- to_send = static_cast<DataPipeProducerDispatcher*>(to_receive.get());
+ to_send = RefPtr<DataPipeProducerDispatcher>(
+ static_cast<DataPipeProducerDispatcher*>(to_receive.get()));
to_receive = nullptr;
// Now send it back the other way.
SendDispatcher(1, to_send, &to_receive);
// |producer_dispatcher_| should have been closed. This is |DCHECK()|ed when
// it is destroyed.
- EXPECT_TRUE(to_send->HasOneRef());
+ to_send->AssertHasOneRef();
to_send = nullptr;
ASSERT_EQ(Dispatcher::Type::DATA_PIPE_PRODUCER, to_receive->GetType());
- producer_dispatcher_ =
- static_cast<DataPipeProducerDispatcher*>(to_receive.get());
+ producer_dispatcher_ = RefPtr<DataPipeProducerDispatcher>(
+ static_cast<DataPipeProducerDispatcher*>(to_receive.get()));
}
private:
@@ -520,29 +518,29 @@ class RemoteConsumerDataPipeImplTestHelper2
void DoTransfer() override {
// This is the consumer dispatcher we'll send.
- scoped_refptr<DataPipeConsumerDispatcher> to_send =
- DataPipeConsumerDispatcher::Create();
+ auto to_send = DataPipeConsumerDispatcher::Create();
to_send->Init(dp());
- scoped_refptr<Dispatcher> to_receive;
+ RefPtr<Dispatcher> to_receive;
SendDispatcher(0, to_send, &to_receive);
// |to_send| should have been closed. This is |DCHECK()|ed when it is
// destroyed.
- EXPECT_TRUE(to_send->HasOneRef());
+ to_send->AssertHasOneRef();
to_send = nullptr;
ASSERT_EQ(Dispatcher::Type::DATA_PIPE_CONSUMER, to_receive->GetType());
- to_send = static_cast<DataPipeConsumerDispatcher*>(to_receive.get());
+ to_send = RefPtr<DataPipeConsumerDispatcher>(
+ static_cast<DataPipeConsumerDispatcher*>(to_receive.get()));
to_receive = nullptr;
// Now send it back the other way.
SendDispatcher(1, to_send, &to_receive);
// |consumer_dispatcher_| should have been closed. This is |DCHECK()|ed when
// it is destroyed.
- EXPECT_TRUE(to_send->HasOneRef());
+ to_send->AssertHasOneRef();
to_send = nullptr;
ASSERT_EQ(Dispatcher::Type::DATA_PIPE_CONSUMER, to_receive->GetType());
- consumer_dispatcher_ =
- static_cast<DataPipeConsumerDispatcher*>(to_receive.get());
+ consumer_dispatcher_ = RefPtr<DataPipeConsumerDispatcher>(
+ static_cast<DataPipeConsumerDispatcher*>(to_receive.get()));
}
private:
« no previous file with comments | « mojo/edk/system/data_pipe_consumer_dispatcher.cc ('k') | mojo/edk/system/data_pipe_producer_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698