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