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

Side by Side Diff: mojo/edk/system/test_channel_endpoint_client.cc

Issue 1353683005: EDK: Convert remaining scoped_ptr -> std::unique_ptr in //mojo/edk/system. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « mojo/edk/system/test_channel_endpoint_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mojo/edk/system/test_channel_endpoint_client.h" 5 #include "mojo/edk/system/test_channel_endpoint_client.h"
6 6
7 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
8 #include "mojo/edk/system/message_in_transit.h" 8 #include "mojo/edk/system/message_in_transit.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 16 matching lines...) Expand all
27 bool TestChannelEndpointClient::IsDetached() const { 27 bool TestChannelEndpointClient::IsDetached() const {
28 MutexLocker locker(&mutex_); 28 MutexLocker locker(&mutex_);
29 return !endpoint_; 29 return !endpoint_;
30 } 30 }
31 31
32 size_t TestChannelEndpointClient::NumMessages() const { 32 size_t TestChannelEndpointClient::NumMessages() const {
33 MutexLocker locker(&mutex_); 33 MutexLocker locker(&mutex_);
34 return messages_.Size(); 34 return messages_.Size();
35 } 35 }
36 36
37 scoped_ptr<MessageInTransit> TestChannelEndpointClient::PopMessage() { 37 std::unique_ptr<MessageInTransit> TestChannelEndpointClient::PopMessage() {
38 MutexLocker locker(&mutex_); 38 MutexLocker locker(&mutex_);
39 if (messages_.IsEmpty()) 39 if (messages_.IsEmpty())
40 return nullptr; 40 return nullptr;
41 return messages_.GetMessage(); 41 return messages_.GetMessage();
42 } 42 }
43 43
44 void TestChannelEndpointClient::SetReadEvent(base::WaitableEvent* read_event) { 44 void TestChannelEndpointClient::SetReadEvent(base::WaitableEvent* read_event) {
45 MutexLocker locker(&mutex_); 45 MutexLocker locker(&mutex_);
46 read_event_ = read_event; 46 read_event_ = read_event;
47 } 47 }
48 48
49 bool TestChannelEndpointClient::OnReadMessage(unsigned port, 49 bool TestChannelEndpointClient::OnReadMessage(unsigned port,
50 MessageInTransit* message) { 50 MessageInTransit* message) {
51 MutexLocker locker(&mutex_); 51 MutexLocker locker(&mutex_);
52 52
53 EXPECT_EQ(port_, port); 53 EXPECT_EQ(port_, port);
54 EXPECT_TRUE(endpoint_); 54 EXPECT_TRUE(endpoint_);
55 messages_.AddMessage(make_scoped_ptr(message)); 55 messages_.AddMessage(std::unique_ptr<MessageInTransit>(message));
56 56
57 if (read_event_) 57 if (read_event_)
58 read_event_->Signal(); 58 read_event_->Signal();
59 59
60 return true; 60 return true;
61 } 61 }
62 62
63 void TestChannelEndpointClient::OnDetachFromChannel(unsigned port) { 63 void TestChannelEndpointClient::OnDetachFromChannel(unsigned port) {
64 MutexLocker locker(&mutex_); 64 MutexLocker locker(&mutex_);
65 65
66 EXPECT_EQ(port_, port); 66 EXPECT_EQ(port_, port);
67 ASSERT_TRUE(endpoint_); 67 ASSERT_TRUE(endpoint_);
68 endpoint_->DetachFromClient(); 68 endpoint_->DetachFromClient();
69 endpoint_ = nullptr; 69 endpoint_ = nullptr;
70 } 70 }
71 71
72 TestChannelEndpointClient::~TestChannelEndpointClient() { 72 TestChannelEndpointClient::~TestChannelEndpointClient() {
73 EXPECT_FALSE(endpoint_); 73 EXPECT_FALSE(endpoint_);
74 } 74 }
75 75
76 } // namespace test 76 } // namespace test
77 } // namespace system 77 } // namespace system
78 } // namespace mojo 78 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/test_channel_endpoint_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698