OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_JINGLE_SESSION_H_ | 5 #ifndef REMOTING_PROTOCOL_JINGLE_SESSION_H_ |
6 #define REMOTING_PROTOCOL_JINGLE_SESSION_H_ | 6 #define REMOTING_PROTOCOL_JINGLE_SESSION_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
15 #include "crypto/rsa_private_key.h" | 15 #include "crypto/rsa_private_key.h" |
16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
17 #include "remoting/protocol/authenticator.h" | 17 #include "remoting/protocol/authenticator.h" |
18 #include "remoting/protocol/channel_factory.h" | 18 #include "remoting/protocol/datagram_channel_factory.h" |
19 #include "remoting/protocol/jingle_messages.h" | 19 #include "remoting/protocol/jingle_messages.h" |
20 #include "remoting/protocol/session.h" | 20 #include "remoting/protocol/session.h" |
21 #include "remoting/protocol/session_config.h" | 21 #include "remoting/protocol/session_config.h" |
22 #include "remoting/protocol/transport.h" | 22 #include "remoting/protocol/transport.h" |
23 #include "remoting/signaling/iq_sender.h" | 23 #include "remoting/signaling/iq_sender.h" |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 class Socket; | 26 class Socket; |
27 class StreamSocket; | 27 class StreamSocket; |
28 } // namespace net | 28 } // namespace net |
29 | 29 |
30 namespace remoting { | 30 namespace remoting { |
31 namespace protocol { | 31 namespace protocol { |
32 | 32 |
| 33 class SecureChannelFactory; |
33 class ChannelMultiplexer; | 34 class ChannelMultiplexer; |
34 class JingleSessionManager; | 35 class JingleSessionManager; |
| 36 class PseudoTcpChannelFactory; |
35 | 37 |
36 // JingleSessionManager and JingleSession implement the subset of the | 38 // JingleSessionManager and JingleSession implement the subset of the |
37 // Jingle protocol used in Chromoting. Instances of this class are | 39 // Jingle protocol used in Chromoting. Instances of this class are |
38 // created by the JingleSessionManager. | 40 // created by the JingleSessionManager. |
39 class JingleSession : public Session, | 41 class JingleSession : public base::NonThreadSafe, |
40 public ChannelFactory, | 42 public Session, |
| 43 public DatagramChannelFactory, |
41 public Transport::EventHandler { | 44 public Transport::EventHandler { |
42 public: | 45 public: |
43 virtual ~JingleSession(); | 46 virtual ~JingleSession(); |
44 | 47 |
45 // Session interface. | 48 // Session interface. |
46 virtual void SetEventHandler(Session::EventHandler* event_handler) OVERRIDE; | 49 virtual void SetEventHandler(Session::EventHandler* event_handler) OVERRIDE; |
47 virtual ErrorCode error() OVERRIDE; | 50 virtual ErrorCode error() OVERRIDE; |
48 virtual const std::string& jid() OVERRIDE; | 51 virtual const std::string& jid() OVERRIDE; |
49 virtual const CandidateSessionConfig* candidate_config() OVERRIDE; | 52 virtual const CandidateSessionConfig* candidate_config() OVERRIDE; |
50 virtual const SessionConfig& config() OVERRIDE; | 53 virtual const SessionConfig& config() OVERRIDE; |
51 virtual void set_config(const SessionConfig& config) OVERRIDE; | 54 virtual void set_config(const SessionConfig& config) OVERRIDE; |
52 virtual ChannelFactory* GetTransportChannelFactory() OVERRIDE; | 55 virtual StreamChannelFactory* GetTransportChannelFactory() OVERRIDE; |
53 virtual ChannelFactory* GetMultiplexedChannelFactory() OVERRIDE; | 56 virtual StreamChannelFactory* GetMultiplexedChannelFactory() OVERRIDE; |
54 virtual void Close() OVERRIDE; | 57 virtual void Close() OVERRIDE; |
55 | 58 |
56 // ChannelFactory interface. | 59 // DatagramChannelFactory interface. |
57 virtual void CreateChannel(const std::string& name, | 60 virtual void CreateChannel(const std::string& name, |
58 const ChannelCreatedCallback& callback) OVERRIDE; | 61 const ChannelCreatedCallback& callback) OVERRIDE; |
59 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; | 62 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; |
60 | 63 |
61 // Transport::EventHandler interface. | 64 // Transport::EventHandler interface. |
62 virtual void OnTransportCandidate( | 65 virtual void OnTransportCandidate( |
63 Transport* transport, | 66 Transport* transport, |
64 const cricket::Candidate& candidate) OVERRIDE; | 67 const cricket::Candidate& candidate) OVERRIDE; |
65 virtual void OnTransportRouteChange(Transport* transport, | 68 virtual void OnTransportRouteChange(Transport* transport, |
66 const TransportRoute& route) OVERRIDE; | 69 const TransportRoute& route) OVERRIDE; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 129 |
127 // Called after the initial incoming authenticator message is processed. | 130 // Called after the initial incoming authenticator message is processed. |
128 void ContinueAcceptIncomingConnection(); | 131 void ContinueAcceptIncomingConnection(); |
129 | 132 |
130 // Called after subsequent authenticator messages are processed. | 133 // Called after subsequent authenticator messages are processed. |
131 void ProcessAuthenticationStep(); | 134 void ProcessAuthenticationStep(); |
132 | 135 |
133 // Called after the authenticating step is finished. | 136 // Called after the authenticating step is finished. |
134 void ContinueAuthenticationStep(); | 137 void ContinueAuthenticationStep(); |
135 | 138 |
| 139 // Called when authentication is finished. |
| 140 void OnAuthenticated(); |
| 141 |
136 // Terminates the session and sends session-terminate if it is | 142 // Terminates the session and sends session-terminate if it is |
137 // necessary. |error| specifies the error code in case when the | 143 // necessary. |error| specifies the error code in case when the |
138 // session is being closed due to an error. | 144 // session is being closed due to an error. |
139 void CloseInternal(ErrorCode error); | 145 void CloseInternal(ErrorCode error); |
140 | 146 |
141 // Sets |state_| to |new_state| and calls state change callback. | 147 // Sets |state_| to |new_state| and calls state change callback. |
142 void SetState(State new_state); | 148 void SetState(State new_state); |
143 | 149 |
144 // Returns true if the state of the session is not CLOSED or FAILED | 150 // Returns true if the state of the session is not CLOSED or FAILED |
145 bool is_session_active(); | 151 bool is_session_active(); |
(...skipping 12 matching lines...) Expand all Loading... |
158 | 164 |
159 scoped_ptr<Authenticator> authenticator_; | 165 scoped_ptr<Authenticator> authenticator_; |
160 | 166 |
161 // Pending Iq requests. Used for all messages except transport-info. | 167 // Pending Iq requests. Used for all messages except transport-info. |
162 std::set<IqRequest*> pending_requests_; | 168 std::set<IqRequest*> pending_requests_; |
163 | 169 |
164 // Pending transport-info requests. | 170 // Pending transport-info requests. |
165 std::list<IqRequest*> transport_info_requests_; | 171 std::list<IqRequest*> transport_info_requests_; |
166 | 172 |
167 ChannelsMap channels_; | 173 ChannelsMap channels_; |
| 174 scoped_ptr<PseudoTcpChannelFactory> pseudotcp_channel_factory_; |
| 175 scoped_ptr<SecureChannelFactory> secure_channel_factory_; |
168 scoped_ptr<ChannelMultiplexer> channel_multiplexer_; | 176 scoped_ptr<ChannelMultiplexer> channel_multiplexer_; |
169 | 177 |
170 base::OneShotTimer<JingleSession> transport_infos_timer_; | 178 base::OneShotTimer<JingleSession> transport_infos_timer_; |
171 std::list<JingleMessage::NamedCandidate> pending_candidates_; | 179 std::list<JingleMessage::NamedCandidate> pending_candidates_; |
172 | 180 |
173 // Pending remote candidates, received before the local channels were created. | 181 // Pending remote candidates, received before the local channels were created. |
174 std::list<JingleMessage::NamedCandidate> pending_remote_candidates_; | 182 std::list<JingleMessage::NamedCandidate> pending_remote_candidates_; |
175 | 183 |
176 base::WeakPtrFactory<JingleSession> weak_factory_; | 184 base::WeakPtrFactory<JingleSession> weak_factory_; |
177 | 185 |
178 DISALLOW_COPY_AND_ASSIGN(JingleSession); | 186 DISALLOW_COPY_AND_ASSIGN(JingleSession); |
179 }; | 187 }; |
180 | 188 |
181 } // namespace protocol | 189 } // namespace protocol |
182 } // namespace remoting | 190 } // namespace remoting |
183 | 191 |
184 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_H_ | 192 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_H_ |
OLD | NEW |