OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ | 5 #ifndef REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ |
6 #define REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ | 6 #define REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 public PepperTransportSocketAdapter::Observer { | 30 public PepperTransportSocketAdapter::Observer { |
31 public: | 31 public: |
32 PepperStreamChannel(PepperSession* session, | 32 PepperStreamChannel(PepperSession* session, |
33 const std::string& name, | 33 const std::string& name, |
34 const Session::StreamChannelCallback& callback); | 34 const Session::StreamChannelCallback& callback); |
35 virtual ~PepperStreamChannel(); | 35 virtual ~PepperStreamChannel(); |
36 | 36 |
37 // PepperChannel implementation. | 37 // PepperChannel implementation. |
38 virtual void Connect(pp::Instance* pp_instance, | 38 virtual void Connect(pp::Instance* pp_instance, |
39 const TransportConfig& transport_config, | 39 const TransportConfig& transport_config, |
40 const std::string& remote_cert) OVERRIDE; | 40 ChannelAuthenticator* authenticator) OVERRIDE; |
41 virtual void AddRemoveCandidate(const cricket::Candidate& candidate) OVERRIDE; | 41 virtual void AddRemoveCandidate(const cricket::Candidate& candidate) OVERRIDE; |
42 virtual const std::string& name() const OVERRIDE; | 42 virtual const std::string& name() const OVERRIDE; |
43 virtual bool is_connected() const OVERRIDE; | 43 virtual bool is_connected() const OVERRIDE; |
44 | 44 |
45 // PepperTransportSocketAdapter implementation. | 45 // PepperTransportSocketAdapter implementation. |
46 virtual void OnChannelDeleted() OVERRIDE; | 46 virtual void OnChannelDeleted() OVERRIDE; |
47 virtual void OnChannelNewLocalCandidate( | 47 virtual void OnChannelNewLocalCandidate( |
48 const std::string& candidate) OVERRIDE; | 48 const std::string& candidate) OVERRIDE; |
49 | 49 |
50 private: | 50 private: |
51 void OnP2PConnect(int result); | 51 void OnP2PConnect(int result); |
52 | 52 void OnAuthenticationDone(net::Error error, net::StreamSocket* socket); |
53 bool EstablishSSLConnection(); | |
54 void OnSSLConnect(int result); | |
55 | |
56 void AuthenticateChannel(); | |
57 void OnAuthenticationDone(ChannelAuthenticator::Result result); | |
58 | 53 |
59 void NotifyConnected(net::StreamSocket* socket); | 54 void NotifyConnected(net::StreamSocket* socket); |
60 void NotifyConnectFailed(); | 55 void NotifyConnectFailed(); |
61 | 56 |
62 PepperSession* session_; | 57 PepperSession* session_; |
63 std::string name_; | 58 std::string name_; |
64 Session::StreamChannelCallback callback_; | 59 Session::StreamChannelCallback callback_; |
65 | 60 scoped_ptr<ChannelAuthenticator> authenticator_; |
66 std::string remote_cert_; | |
67 | 61 |
68 // We own |channel_| until it is connected. After that | 62 // We own |channel_| until it is connected. After that |
69 // SSLClientSocket owns it. | 63 // |authenticator_| owns it. |
70 scoped_ptr<PepperTransportSocketAdapter> owned_channel_; | 64 scoped_ptr<PepperTransportSocketAdapter> owned_channel_; |
71 PepperTransportSocketAdapter* channel_; | 65 PepperTransportSocketAdapter* channel_; |
72 | 66 |
73 // Indicates that we've finished connecting. | 67 // Indicates that we've finished connecting. |
74 bool connected_; | 68 bool connected_; |
75 | 69 |
76 scoped_ptr<net::StreamSocket> socket_; | 70 // Callback called by the TCP layer. |
77 net::SSLClientSocket* ssl_client_socket_; | |
78 | |
79 // Used to verify the certificate received in SSLClientSocket. | |
80 scoped_ptr<net::CertVerifier> cert_verifier_; | |
81 | |
82 scoped_ptr<ChannelAuthenticator> authenticator_; | |
83 | |
84 // Callback called by the TCP and SSL layers. | |
85 net::OldCompletionCallbackImpl<PepperStreamChannel> p2p_connect_callback_; | 71 net::OldCompletionCallbackImpl<PepperStreamChannel> p2p_connect_callback_; |
86 net::OldCompletionCallbackImpl<PepperStreamChannel> ssl_connect_callback_; | |
87 | 72 |
88 DISALLOW_COPY_AND_ASSIGN(PepperStreamChannel); | 73 DISALLOW_COPY_AND_ASSIGN(PepperStreamChannel); |
89 }; | 74 }; |
90 | 75 |
91 } // namespace protocol | 76 } // namespace protocol |
92 } // namespace remoting | 77 } // namespace remoting |
93 | 78 |
94 #endif // REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ | 79 #endif // REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ |
OLD | NEW |