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