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