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

Side by Side Diff: remoting/protocol/ssl_hmac_channel_authenticator_unittest.cc

Issue 1534193004: Use std::move() instead of scoped_ptr<>::Pass(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
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 "remoting/protocol/ssl_hmac_channel_authenticator.h" 5 #include "remoting/protocol/ssl_hmac_channel_authenticator.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 key_pair_ = RsaKeyPair::FromString(key_base64); 69 key_pair_ = RsaKeyPair::FromString(key_base64);
70 ASSERT_TRUE(key_pair_.get()); 70 ASSERT_TRUE(key_pair_.get());
71 } 71 }
72 72
73 void RunChannelAuth(int expected_client_error, int expected_host_error) { 73 void RunChannelAuth(int expected_client_error, int expected_host_error) {
74 client_fake_socket_.reset(new FakeStreamSocket()); 74 client_fake_socket_.reset(new FakeStreamSocket());
75 host_fake_socket_.reset(new FakeStreamSocket()); 75 host_fake_socket_.reset(new FakeStreamSocket());
76 client_fake_socket_->PairWith(host_fake_socket_.get()); 76 client_fake_socket_->PairWith(host_fake_socket_.get());
77 77
78 client_auth_->SecureAndAuthenticate( 78 client_auth_->SecureAndAuthenticate(
79 client_fake_socket_.Pass(), 79 std::move(client_fake_socket_),
80 base::Bind(&SslHmacChannelAuthenticatorTest::OnClientConnected, 80 base::Bind(&SslHmacChannelAuthenticatorTest::OnClientConnected,
81 base::Unretained(this))); 81 base::Unretained(this)));
82 82
83 host_auth_->SecureAndAuthenticate( 83 host_auth_->SecureAndAuthenticate(
84 host_fake_socket_.Pass(), 84 std::move(host_fake_socket_),
85 base::Bind(&SslHmacChannelAuthenticatorTest::OnHostConnected, 85 base::Bind(&SslHmacChannelAuthenticatorTest::OnHostConnected,
86 base::Unretained(this), std::string("ref argument value"))); 86 base::Unretained(this), std::string("ref argument value")));
87 87
88 // Expect two callbacks to be called - the client callback and the host 88 // Expect two callbacks to be called - the client callback and the host
89 // callback. 89 // callback.
90 int callback_counter = 2; 90 int callback_counter = 2;
91 91
92 if (expected_client_error != net::OK) { 92 if (expected_client_error != net::OK) {
93 EXPECT_CALL(client_callback_, OnDone(expected_client_error, nullptr)) 93 EXPECT_CALL(client_callback_, OnDone(expected_client_error, nullptr))
94 .WillOnce(QuitThreadOnCounter(&callback_counter)); 94 .WillOnce(QuitThreadOnCounter(&callback_counter));
(...skipping 20 matching lines...) Expand all
115 115
116 void OnHostConnected(const std::string& ref_argument, 116 void OnHostConnected(const std::string& ref_argument,
117 int error, 117 int error,
118 scoped_ptr<P2PStreamSocket> socket) { 118 scoped_ptr<P2PStreamSocket> socket) {
119 // Try deleting the authenticator and verify that this doesn't destroy 119 // Try deleting the authenticator and verify that this doesn't destroy
120 // reference parameters. 120 // reference parameters.
121 host_auth_.reset(); 121 host_auth_.reset();
122 DCHECK_EQ(ref_argument, "ref argument value"); 122 DCHECK_EQ(ref_argument, "ref argument value");
123 123
124 host_callback_.OnDone(error, socket.get()); 124 host_callback_.OnDone(error, socket.get());
125 host_socket_ = socket.Pass(); 125 host_socket_ = std::move(socket);
126 } 126 }
127 127
128 void OnClientConnected(int error, scoped_ptr<P2PStreamSocket> socket) { 128 void OnClientConnected(int error, scoped_ptr<P2PStreamSocket> socket) {
129 client_auth_.reset(); 129 client_auth_.reset();
130 client_callback_.OnDone(error, socket.get()); 130 client_callback_.OnDone(error, socket.get());
131 client_socket_ = socket.Pass(); 131 client_socket_ = std::move(socket);
132 } 132 }
133 133
134 base::MessageLoop message_loop_; 134 base::MessageLoop message_loop_;
135 135
136 scoped_refptr<RsaKeyPair> key_pair_; 136 scoped_refptr<RsaKeyPair> key_pair_;
137 std::string host_cert_; 137 std::string host_cert_;
138 scoped_ptr<FakeStreamSocket> client_fake_socket_; 138 scoped_ptr<FakeStreamSocket> client_fake_socket_;
139 scoped_ptr<FakeStreamSocket> host_fake_socket_; 139 scoped_ptr<FakeStreamSocket> host_fake_socket_;
140 scoped_ptr<ChannelAuthenticator> client_auth_; 140 scoped_ptr<ChannelAuthenticator> client_auth_;
141 scoped_ptr<ChannelAuthenticator> host_auth_; 141 scoped_ptr<ChannelAuthenticator> host_auth_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( 193 host_auth_ = SslHmacChannelAuthenticator::CreateForHost(
194 host_cert_, key_pair_, kTestSharedSecret); 194 host_cert_, key_pair_, kTestSharedSecret);
195 195
196 RunChannelAuth(net::ERR_CERT_INVALID, net::ERR_CONNECTION_CLOSED); 196 RunChannelAuth(net::ERR_CERT_INVALID, net::ERR_CONNECTION_CLOSED);
197 197
198 ASSERT_TRUE(host_socket_.get() == nullptr); 198 ASSERT_TRUE(host_socket_.get() == nullptr);
199 } 199 }
200 200
201 } // namespace protocol 201 } // namespace protocol
202 } // namespace remoting 202 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698