| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/secure_channel_factory.h" | 5 #include "remoting/protocol/secure_channel_factory.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "net/socket/stream_socket.h" | 8 #include "net/socket/stream_socket.h" |
| 9 #include "remoting/protocol/authenticator.h" | 9 #include "remoting/protocol/authenticator.h" |
| 10 #include "remoting/protocol/channel_authenticator.h" | 10 #include "remoting/protocol/channel_authenticator.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 delete it->second; | 44 delete it->second; |
| 45 channel_authenticators_.erase(it); | 45 channel_authenticators_.erase(it); |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 void SecureChannelFactory::OnBaseChannelCreated( | 49 void SecureChannelFactory::OnBaseChannelCreated( |
| 50 const std::string& name, | 50 const std::string& name, |
| 51 const ChannelCreatedCallback& callback, | 51 const ChannelCreatedCallback& callback, |
| 52 scoped_ptr<net::StreamSocket> socket) { | 52 scoped_ptr<net::StreamSocket> socket) { |
| 53 if (!socket) { | 53 if (!socket) { |
| 54 callback.Run(scoped_ptr<net::StreamSocket>()); | 54 callback.Run(nullptr); |
| 55 return; | 55 return; |
| 56 } | 56 } |
| 57 | 57 |
| 58 ChannelAuthenticator* channel_authenticator = | 58 ChannelAuthenticator* channel_authenticator = |
| 59 authenticator_->CreateChannelAuthenticator().release(); | 59 authenticator_->CreateChannelAuthenticator().release(); |
| 60 channel_authenticators_[name] = channel_authenticator; | 60 channel_authenticators_[name] = channel_authenticator; |
| 61 channel_authenticator->SecureAndAuthenticate( | 61 channel_authenticator->SecureAndAuthenticate( |
| 62 socket.Pass(), | 62 socket.Pass(), |
| 63 base::Bind(&SecureChannelFactory::OnSecureChannelCreated, | 63 base::Bind(&SecureChannelFactory::OnSecureChannelCreated, |
| 64 base::Unretained(this), name, callback)); | 64 base::Unretained(this), name, callback)); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void SecureChannelFactory::OnSecureChannelCreated( | 67 void SecureChannelFactory::OnSecureChannelCreated( |
| 68 const std::string& name, | 68 const std::string& name, |
| 69 const ChannelCreatedCallback& callback, | 69 const ChannelCreatedCallback& callback, |
| 70 int error, | 70 int error, |
| 71 scoped_ptr<net::StreamSocket> socket) { | 71 scoped_ptr<net::StreamSocket> socket) { |
| 72 DCHECK((socket && error == net::OK) || (!socket && error != net::OK)); | 72 DCHECK((socket && error == net::OK) || (!socket && error != net::OK)); |
| 73 | 73 |
| 74 AuthenticatorMap::iterator it = channel_authenticators_.find(name); | 74 AuthenticatorMap::iterator it = channel_authenticators_.find(name); |
| 75 DCHECK(it != channel_authenticators_.end()); | 75 DCHECK(it != channel_authenticators_.end()); |
| 76 delete it->second; | 76 delete it->second; |
| 77 channel_authenticators_.erase(it); | 77 channel_authenticators_.erase(it); |
| 78 | 78 |
| 79 callback.Run(socket.Pass()); | 79 callback.Run(socket.Pass()); |
| 80 } | 80 } |
| 81 | 81 |
| 82 } // namespace protocol | 82 } // namespace protocol |
| 83 } // namespace remoting | 83 } // namespace remoting |
| OLD | NEW |