| 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(pp::Instance* pp_instance, |
| 38 const TransportConfig& transport_config, |
| 39 const std::string& remote_cert) OVERRIDE; |
| 40 virtual void AddRemoveCandidate(const cricket::Candidate& candidate) OVERRIDE; |
| 41 virtual const std::string& name() OVERRIDE; |
| 42 |
| 43 // PepperTransportSocketAdapter implementation. |
| 44 virtual void OnChannelDeleted() OVERRIDE; |
| 45 virtual void OnChannelNewLocalCandidate( |
| 46 const std::string& candidate) OVERRIDE; |
| 47 |
| 48 private: |
| 49 void OnP2PConnect(int result); |
| 50 |
| 51 bool EstablishSSLConnection(); |
| 52 void OnSSLConnect(int result); |
| 53 |
| 54 void AuthenticateChannel(); |
| 55 void OnAuthenticationDone(ChannelAuthenticator::Result result); |
| 56 |
| 57 void NotifyConnected(net::StreamSocket* socket); |
| 58 void NotifyConnectFailed(); |
| 59 |
| 60 PepperSession* session_; |
| 61 std::string name_; |
| 62 Session::StreamChannelCallback callback_; |
| 63 |
| 64 std::string remote_cert_; |
| 65 |
| 66 // We own |channel_| until it is connected. After that |
| 67 // SSLClientSocket owns it. |
| 68 scoped_ptr<PepperTransportSocketAdapter> owned_channel_; |
| 69 PepperTransportSocketAdapter* channel_; |
| 70 |
| 71 // Indicates that we've finished connecting. |
| 72 bool connected_; |
| 73 |
| 74 scoped_ptr<net::StreamSocket> socket_; |
| 75 net::SSLClientSocket* ssl_client_socket_; |
| 76 |
| 77 // Used to verify the certificate received in SSLClientSocket. |
| 78 scoped_ptr<net::CertVerifier> cert_verifier_; |
| 79 |
| 80 scoped_ptr<ChannelAuthenticator> authenticator_; |
| 81 |
| 82 // Callback called by the TCP and SSL layers. |
| 83 net::CompletionCallbackImpl<PepperStreamChannel> p2p_connect_callback_; |
| 84 net::CompletionCallbackImpl<PepperStreamChannel> ssl_connect_callback_; |
| 85 |
| 86 DISALLOW_COPY_AND_ASSIGN(PepperStreamChannel); |
| 87 }; |
| 88 |
| 89 } // namespace protocol |
| 90 } // namespace remoting |
| 91 |
| 92 #endif // REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ |
| OLD | NEW |