OLD | NEW |
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/fake_authenticator.h" | 5 #include "remoting/protocol/fake_authenticator.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 FakeChannelAuthenticator::~FakeChannelAuthenticator() { | 30 FakeChannelAuthenticator::~FakeChannelAuthenticator() { |
31 } | 31 } |
32 | 32 |
33 void FakeChannelAuthenticator::SecureAndAuthenticate( | 33 void FakeChannelAuthenticator::SecureAndAuthenticate( |
34 scoped_ptr<P2PStreamSocket> socket, | 34 scoped_ptr<P2PStreamSocket> socket, |
35 const DoneCallback& done_callback) { | 35 const DoneCallback& done_callback) { |
36 socket_ = std::move(socket); | 36 socket_ = std::move(socket); |
37 | 37 |
| 38 done_callback_ = done_callback; |
| 39 |
38 if (async_) { | 40 if (async_) { |
39 done_callback_ = done_callback; | |
40 | |
41 if (result_ != net::OK) { | 41 if (result_ != net::OK) { |
42 // Don't write anything if we are going to reject auth to make test | 42 // Don't write anything if we are going to reject auth to make test |
43 // ordering deterministic. | 43 // ordering deterministic. |
44 did_write_bytes_ = true; | 44 did_write_bytes_ = true; |
45 } else { | 45 } else { |
46 scoped_refptr<net::IOBuffer> write_buf = new net::IOBuffer(1); | 46 scoped_refptr<net::IOBuffer> write_buf = new net::IOBuffer(1); |
47 write_buf->data()[0] = 0; | 47 write_buf->data()[0] = 0; |
48 int result = socket_->Write( | 48 int result = socket_->Write( |
49 write_buf.get(), 1, | 49 write_buf.get(), 1, |
50 base::Bind(&FakeChannelAuthenticator::OnAuthBytesWritten, | 50 base::Bind(&FakeChannelAuthenticator::OnAuthBytesWritten, |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 const std::string& remote_jid, | 216 const std::string& remote_jid, |
217 const buzz::XmlElement* first_message) { | 217 const buzz::XmlElement* first_message) { |
218 scoped_ptr<FakeAuthenticator> authenticator(new FakeAuthenticator( | 218 scoped_ptr<FakeAuthenticator> authenticator(new FakeAuthenticator( |
219 FakeAuthenticator::HOST, round_trips_, action_, async_)); | 219 FakeAuthenticator::HOST, round_trips_, action_, async_)); |
220 authenticator->set_messages_till_started(messages_till_started_); | 220 authenticator->set_messages_till_started(messages_till_started_); |
221 return std::move(authenticator); | 221 return std::move(authenticator); |
222 } | 222 } |
223 | 223 |
224 } // namespace protocol | 224 } // namespace protocol |
225 } // namespace remoting | 225 } // namespace remoting |
OLD | NEW |