| 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> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 public Transport::EventHandler { | 44 public Transport::EventHandler { |
| 45 public: | 45 public: |
| 46 ~JingleSession() override; | 46 ~JingleSession() override; |
| 47 | 47 |
| 48 // Session interface. | 48 // Session interface. |
| 49 void SetEventHandler(Session::EventHandler* event_handler) override; | 49 void SetEventHandler(Session::EventHandler* event_handler) override; |
| 50 ErrorCode error() override; | 50 ErrorCode error() override; |
| 51 const std::string& jid() override; | 51 const std::string& jid() override; |
| 52 const CandidateSessionConfig* candidate_config() override; | 52 const CandidateSessionConfig* candidate_config() override; |
| 53 const SessionConfig& config() override; | 53 const SessionConfig& config() override; |
| 54 void set_config(const SessionConfig& config) override; | 54 void set_config(scoped_ptr<SessionConfig> config) override; |
| 55 StreamChannelFactory* GetTransportChannelFactory() override; | 55 StreamChannelFactory* GetTransportChannelFactory() override; |
| 56 StreamChannelFactory* GetMultiplexedChannelFactory() override; | 56 StreamChannelFactory* GetMultiplexedChannelFactory() override; |
| 57 void Close() override; | 57 void Close() override; |
| 58 | 58 |
| 59 // DatagramChannelFactory interface. | 59 // DatagramChannelFactory interface. |
| 60 void CreateChannel(const std::string& name, | 60 void CreateChannel(const std::string& name, |
| 61 const ChannelCreatedCallback& callback) override; | 61 const ChannelCreatedCallback& callback) override; |
| 62 void CancelChannelCreation(const std::string& name) override; | 62 void CancelChannelCreation(const std::string& name) override; |
| 63 | 63 |
| 64 // Transport::EventHandler interface. | 64 // Transport::EventHandler interface. |
| 65 void OnTransportIceCredentials(Transport* transport, |
| 66 const std::string& ufrag, |
| 67 const std::string& password) override; |
| 65 void OnTransportCandidate(Transport* transport, | 68 void OnTransportCandidate(Transport* transport, |
| 66 const cricket::Candidate& candidate) override; | 69 const cricket::Candidate& candidate) override; |
| 67 void OnTransportRouteChange(Transport* transport, | 70 void OnTransportRouteChange(Transport* transport, |
| 68 const TransportRoute& route) override; | 71 const TransportRoute& route) override; |
| 69 void OnTransportFailed(Transport* transport) override; | 72 void OnTransportFailed(Transport* transport) override; |
| 70 void OnTransportDeleted(Transport* transport) override; | 73 void OnTransportDeleted(Transport* transport) override; |
| 71 | 74 |
| 72 private: | 75 private: |
| 73 friend class JingleSessionManager; | 76 friend class JingleSessionManager; |
| 74 | 77 |
| 75 typedef std::map<std::string, Transport*> ChannelsMap; | 78 typedef std::map<std::string, Transport*> ChannelsMap; |
| 76 typedef base::Callback<void(JingleMessageReply::ErrorType)> ReplyCallback; | 79 typedef base::Callback<void(JingleMessageReply::ErrorType)> ReplyCallback; |
| 77 | 80 |
| 78 explicit JingleSession(JingleSessionManager* session_manager); | 81 explicit JingleSession(JingleSessionManager* session_manager); |
| 79 | 82 |
| 80 // Start connection by sending session-initiate message. | 83 // Start connection by sending session-initiate message. |
| 81 void StartConnection(const std::string& peer_jid, | 84 void StartConnection(const std::string& peer_jid, |
| 82 scoped_ptr<Authenticator> authenticator, | 85 scoped_ptr<Authenticator> authenticator, |
| 83 scoped_ptr<CandidateSessionConfig> config); | 86 scoped_ptr<CandidateSessionConfig> config); |
| 84 | 87 |
| 85 // Adds to a new channel the remote candidates received before it was created. | 88 // Passes transport info to a new |channel| in case it was received before the |
| 86 void AddPendingRemoteCandidates(Transport* channel, const std::string& name); | 89 // channel was created. |
| 90 void AddPendingRemoteTransportInfo(Transport* channel); |
| 87 | 91 |
| 88 // Called by JingleSessionManager for incoming connections. | 92 // Called by JingleSessionManager for incoming connections. |
| 89 void InitializeIncomingConnection(const JingleMessage& initiate_message, | 93 void InitializeIncomingConnection(const JingleMessage& initiate_message, |
| 90 scoped_ptr<Authenticator> authenticator); | 94 scoped_ptr<Authenticator> authenticator); |
| 91 void AcceptIncomingConnection(const JingleMessage& initiate_message); | 95 void AcceptIncomingConnection(const JingleMessage& initiate_message); |
| 92 | 96 |
| 93 // Sends |message| to the peer. The session is closed if the send fails or no | 97 // Sends |message| to the peer. The session is closed if the send fails or no |
| 94 // response is received within a reasonable time. All other responses are | 98 // response is received within a reasonable time. All other responses are |
| 95 // ignored. | 99 // ignored. |
| 96 void SendMessage(const JingleMessage& message); | 100 void SendMessage(const JingleMessage& message); |
| 97 | 101 |
| 98 // Iq response handler. | 102 // Iq response handler. |
| 99 void OnMessageResponse(JingleMessage::ActionType request_type, | 103 void OnMessageResponse(JingleMessage::ActionType request_type, |
| 100 IqRequest* request, | 104 IqRequest* request, |
| 101 const buzz::XmlElement* response); | 105 const buzz::XmlElement* response); |
| 102 | 106 |
| 107 // Creates empty |pending_transport_info_message_| and schedules timer for |
| 108 // SentTransportInfo() to sent the message later. |
| 109 void EnsurePendingTransportInfoMessage(); |
| 110 |
| 103 // Sends transport-info message with candidates from |pending_candidates_|. | 111 // Sends transport-info message with candidates from |pending_candidates_|. |
| 104 void SendTransportInfo(); | 112 void SendTransportInfo(); |
| 105 | 113 |
| 106 // Response handler for transport-info responses. Transport-info timeouts are | 114 // Response handler for transport-info responses. Transport-info timeouts are |
| 107 // ignored and don't terminate connection. | 115 // ignored and don't terminate connection. |
| 108 void OnTransportInfoResponse(IqRequest* request, | 116 void OnTransportInfoResponse(IqRequest* request, |
| 109 const buzz::XmlElement* response); | 117 const buzz::XmlElement* response); |
| 110 | 118 |
| 111 // Called by JingleSessionManager on incoming |message|. Must call | 119 // Called by JingleSessionManager on incoming |message|. Must call |
| 112 // |reply_callback| to send reply message before sending any other | 120 // |reply_callback| to send reply message before sending any other |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 159 |
| 152 JingleSessionManager* session_manager_; | 160 JingleSessionManager* session_manager_; |
| 153 std::string peer_jid_; | 161 std::string peer_jid_; |
| 154 scoped_ptr<CandidateSessionConfig> candidate_config_; | 162 scoped_ptr<CandidateSessionConfig> candidate_config_; |
| 155 Session::EventHandler* event_handler_; | 163 Session::EventHandler* event_handler_; |
| 156 | 164 |
| 157 std::string session_id_; | 165 std::string session_id_; |
| 158 State state_; | 166 State state_; |
| 159 ErrorCode error_; | 167 ErrorCode error_; |
| 160 | 168 |
| 161 SessionConfig config_; | 169 scoped_ptr<SessionConfig> config_; |
| 162 bool config_is_set_; | |
| 163 | 170 |
| 164 scoped_ptr<Authenticator> authenticator_; | 171 scoped_ptr<Authenticator> authenticator_; |
| 165 | 172 |
| 166 // Pending Iq requests. Used for all messages except transport-info. | 173 // Pending Iq requests. Used for all messages except transport-info. |
| 167 std::set<IqRequest*> pending_requests_; | 174 std::set<IqRequest*> pending_requests_; |
| 168 | 175 |
| 169 // Pending transport-info requests. | 176 // Pending transport-info requests. |
| 170 std::list<IqRequest*> transport_info_requests_; | 177 std::list<IqRequest*> transport_info_requests_; |
| 171 | 178 |
| 172 ChannelsMap channels_; | 179 ChannelsMap channels_; |
| 173 scoped_ptr<PseudoTcpChannelFactory> pseudotcp_channel_factory_; | 180 scoped_ptr<PseudoTcpChannelFactory> pseudotcp_channel_factory_; |
| 174 scoped_ptr<SecureChannelFactory> secure_channel_factory_; | 181 scoped_ptr<SecureChannelFactory> secure_channel_factory_; |
| 175 scoped_ptr<ChannelMultiplexer> channel_multiplexer_; | 182 scoped_ptr<ChannelMultiplexer> channel_multiplexer_; |
| 176 | 183 |
| 177 base::OneShotTimer<JingleSession> transport_infos_timer_; | 184 scoped_ptr<JingleMessage> pending_transport_info_message_; |
| 178 std::list<JingleMessage::NamedCandidate> pending_candidates_; | 185 base::OneShotTimer<JingleSession> transport_info_timer_; |
| 179 | 186 |
| 180 // Pending remote candidates, received before the local channels were created. | 187 // Pending remote transport info received before the local channels were |
| 188 // created. |
| 189 std::list<JingleMessage::IceCredentials> pending_remote_ice_credentials_; |
| 181 std::list<JingleMessage::NamedCandidate> pending_remote_candidates_; | 190 std::list<JingleMessage::NamedCandidate> pending_remote_candidates_; |
| 182 | 191 |
| 183 base::WeakPtrFactory<JingleSession> weak_factory_; | 192 base::WeakPtrFactory<JingleSession> weak_factory_; |
| 184 | 193 |
| 185 DISALLOW_COPY_AND_ASSIGN(JingleSession); | 194 DISALLOW_COPY_AND_ASSIGN(JingleSession); |
| 186 }; | 195 }; |
| 187 | 196 |
| 188 } // namespace protocol | 197 } // namespace protocol |
| 189 } // namespace remoting | 198 } // namespace remoting |
| 190 | 199 |
| 191 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_H_ | 200 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_H_ |
| OLD | NEW |