| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ |
| 6 #define REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "net/base/completion_callback.h" |
| 11 #include "remoting/protocol/channel_authenticator.h" |
| 12 #include "remoting/protocol/pepper_channel.h" |
| 13 #include "remoting/protocol/pepper_transport_socket_adapter.h" |
| 14 #include "remoting/protocol/session.h" |
| 15 |
| 16 namespace net { |
| 17 class CertVerifier; |
| 18 class StreamSocket; |
| 19 class SSLClientSocket; |
| 20 class SSLServerSocket; |
| 21 } // namespace net |
| 22 |
| 23 namespace remoting { |
| 24 namespace protocol { |
| 25 |
| 26 class PepperSession; |
| 27 |
| 28 class PepperStreamChannel : public PepperChannel, |
| 29 public PepperTransportSocketAdapter::Observer { |
| 30 public: |
| 31 PepperStreamChannel(PepperSession* session, |
| 32 const std::string& name, |
| 33 const Session::StreamChannelCallback& callback); |
| 34 virtual ~PepperStreamChannel(); |
| 35 |
| 36 // PepperChannel implementation. |
| 37 virtual void Connect(const TransportConfig& transport_config, |
| 38 const std::string& remote_cert) OVERRIDE; |
| 39 virtual void AddRemoveCandidate(const cricket::Candidate& candidate) OVERRIDE; |
| 40 virtual const std::string& name() OVERRIDE; |
| 41 |
| 42 // PepperTransportSocketAdapter implementation. |
| 43 virtual void OnChannelDeleted() OVERRIDE; |
| 44 virtual void OnChannelNewLocalCandidate( |
| 45 const std::string& candidate) OVERRIDE; |
| 46 |
| 47 private: |
| 48 void OnP2PConnect(int result); |
| 49 |
| 50 bool EstablishSSLConnection(); |
| 51 void OnSSLConnect(int result); |
| 52 |
| 53 void AuthenticateChannel(); |
| 54 void OnAuthenticationDone(ChannelAuthenticator::Result result); |
| 55 |
| 56 void NotifyConnected(net::StreamSocket* socket); |
| 57 void NotifyConnectFailed(); |
| 58 |
| 59 PepperSession* session_; |
| 60 std::string name_; |
| 61 Session::StreamChannelCallback callback_; |
| 62 |
| 63 std::string remote_cert_; |
| 64 |
| 65 // We own |channel_| until it is connected. After that |
| 66 // SSLClientSocket owns it. |
| 67 scoped_ptr<PepperTransportSocketAdapter> owned_channel_; |
| 68 PepperTransportSocketAdapter* channel_; |
| 69 |
| 70 // Indicates that we've finished connecting. |
| 71 bool connected_; |
| 72 |
| 73 scoped_ptr<net::StreamSocket> socket_; |
| 74 net::SSLClientSocket* ssl_client_socket_; |
| 75 |
| 76 // Used to verify the certificate received in SSLClientSocket. |
| 77 scoped_ptr<net::CertVerifier> cert_verifier_; |
| 78 |
| 79 scoped_ptr<ChannelAuthenticator> authenticator_; |
| 80 |
| 81 // Callback called by the TCP and SSL layers. |
| 82 net::CompletionCallbackImpl<PepperStreamChannel> p2p_connect_callback_; |
| 83 net::CompletionCallbackImpl<PepperStreamChannel> ssl_connect_callback_; |
| 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(PepperStreamChannel); |
| 86 }; |
| 87 |
| 88 } // namespace protocol |
| 89 } // namespace remoting |
| 90 |
| 91 #endif // REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ |
| OLD | NEW |