Chromium Code Reviews| 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_JINGLE_SESSION_MANAGER_H_ | 5 #ifndef REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_ |
| 6 #define REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_ | 6 #define REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 // server that accepts chromoting connections and can also make new connections | 32 // server that accepts chromoting connections and can also make new connections |
| 33 // to other hosts. | 33 // to other hosts. |
| 34 class JingleSessionManager | 34 class JingleSessionManager |
| 35 : public SessionManager, | 35 : public SessionManager, |
| 36 public cricket::SessionClient { | 36 public cricket::SessionClient { |
| 37 public: | 37 public: |
| 38 virtual ~JingleSessionManager(); | 38 virtual ~JingleSessionManager(); |
| 39 | 39 |
| 40 JingleSessionManager(base::MessageLoopProxy* message_loop); | 40 JingleSessionManager(base::MessageLoopProxy* message_loop); |
| 41 | 41 |
| 42 void set_allow_local_ips(bool allow_local_ips); | |
|
Wez
2011/11/25 06:54:11
Can we just remove this? I don't think we have an
Sergey Ulanov
2011/11/28 18:55:16
Done.
Sergey Ulanov
2011/11/28 21:36:17
Actually we do need this to allow connections from
| |
| 43 | |
| 42 // SessionManager interface. | 44 // SessionManager interface. |
| 43 virtual void Init(const std::string& local_jid, | 45 virtual void Init(const std::string& local_jid, |
| 44 SignalStrategy* signal_strategy, | 46 SignalStrategy* signal_strategy, |
| 45 Listener* listener, | 47 Listener* listener, |
| 46 crypto::RSAPrivateKey* private_key, | |
| 47 const std::string& certificate, | |
| 48 bool allow_nat_traversal) OVERRIDE; | 48 bool allow_nat_traversal) OVERRIDE; |
| 49 virtual Session* Connect( | 49 virtual Session* Connect( |
| 50 const std::string& host_jid, | 50 const std::string& host_jid, |
| 51 const std::string& host_public_key, | 51 Authenticator* authenticator, |
| 52 const std::string& client_token, | |
| 53 CandidateSessionConfig* config, | 52 CandidateSessionConfig* config, |
| 54 const Session::StateChangeCallback& state_change_callback) OVERRIDE; | 53 const Session::StateChangeCallback& state_change_callback) OVERRIDE; |
| 55 virtual void Close() OVERRIDE; | 54 virtual void Close() OVERRIDE; |
| 56 | 55 virtual void set_authenticator_factory( |
| 57 void set_allow_local_ips(bool allow_local_ips); | 56 AuthenticatorFactory* authenticator_factory) OVERRIDE; |
| 58 | 57 |
| 59 // cricket::SessionClient interface. | 58 // cricket::SessionClient interface. |
| 60 virtual void OnSessionCreate(cricket::Session* cricket_session, | 59 virtual void OnSessionCreate(cricket::Session* cricket_session, |
| 61 bool received_initiate) OVERRIDE; | 60 bool received_initiate) OVERRIDE; |
| 62 virtual void OnSessionDestroy(cricket::Session* cricket_session) OVERRIDE; | 61 virtual void OnSessionDestroy(cricket::Session* cricket_session) OVERRIDE; |
| 63 | 62 |
| 64 virtual bool ParseContent(cricket::SignalingProtocol protocol, | 63 virtual bool ParseContent(cricket::SignalingProtocol protocol, |
| 65 const buzz::XmlElement* elem, | 64 const buzz::XmlElement* elem, |
| 66 const cricket::ContentDescription** content, | 65 const cricket::ContentDescription** content, |
| 67 cricket::ParseError* error) OVERRIDE; | 66 cricket::ParseError* error) OVERRIDE; |
| 68 virtual bool WriteContent(cricket::SignalingProtocol protocol, | 67 virtual bool WriteContent(cricket::SignalingProtocol protocol, |
| 69 const cricket::ContentDescription* content, | 68 const cricket::ContentDescription* content, |
| 70 buzz::XmlElement** elem, | 69 buzz::XmlElement** elem, |
| 71 cricket::WriteError* error) OVERRIDE; | 70 cricket::WriteError* error) OVERRIDE; |
| 72 | 71 |
| 73 private: | 72 private: |
| 74 friend class JingleSession; | 73 friend class JingleSession; |
| 75 | 74 |
| 76 // Called by JingleSession when a new connection is | 75 // Called by JingleSession when a new connection is initiated. |
| 77 // initiated. Returns true if session is accepted. | 76 SessionManager::IncomingSessionResponse AcceptConnection( |
| 78 bool AcceptConnection(JingleSession* jingle_session, | 77 JingleSession* jingle_session); |
| 79 cricket::Session* cricket_session); | 78 |
| 79 // Creates authenticator for incoming session. Returns NULL if | |
| 80 // authenticator cannot be created, e.g. if |auth_message| is | |
| 81 // invalid. Caller reatins ownership of |auth_message| and must | |
| 82 // accept ownership of the result. | |
| 83 Authenticator* CreateAuthenticator(const std::string& jid, | |
| 84 const buzz::XmlElement* auth_message); | |
| 80 | 85 |
| 81 // Called by JingleSession when it is being destroyed. | 86 // Called by JingleSession when it is being destroyed. |
| 82 void SessionDestroyed(JingleSession* jingle_session); | 87 void SessionDestroyed(JingleSession* jingle_session); |
| 83 | 88 |
| 84 // Callback for JingleInfoRequest. | 89 // Callback for JingleInfoRequest. |
| 85 void OnJingleInfo( | 90 void OnJingleInfo( |
| 86 const std::string& token, | 91 const std::string& token, |
| 87 const std::vector<std::string>& relay_hosts, | 92 const std::vector<std::string>& relay_hosts, |
| 88 const std::vector<talk_base::SocketAddress>& stun_hosts); | 93 const std::vector<talk_base::SocketAddress>& stun_hosts); |
| 89 | 94 |
| 90 // Creates session description for outgoing session. | |
| 91 static cricket::SessionDescription* CreateClientSessionDescription( | |
| 92 const CandidateSessionConfig* candidate_config, | |
| 93 const std::string& auth_token); | |
| 94 // Creates session description for incoming session. | |
| 95 static cricket::SessionDescription* CreateHostSessionDescription( | |
| 96 const CandidateSessionConfig* candidate_config, | |
| 97 const std::string& certificate); | |
| 98 | |
| 99 scoped_refptr<base::MessageLoopProxy> message_loop_; | 95 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 100 | 96 |
| 101 scoped_ptr<talk_base::NetworkManager> network_manager_; | 97 scoped_ptr<talk_base::NetworkManager> network_manager_; |
| 102 scoped_ptr<talk_base::PacketSocketFactory> socket_factory_; | 98 scoped_ptr<talk_base::PacketSocketFactory> socket_factory_; |
| 103 | 99 |
| 104 std::string local_jid_; // Full jid for the local side of the session. | 100 std::string local_jid_; // Full jid for the local side of the session. |
| 105 SignalStrategy* signal_strategy_; | 101 SignalStrategy* signal_strategy_; |
| 102 scoped_ptr<AuthenticatorFactory> authenticator_factory_; | |
| 106 Listener* listener_; | 103 Listener* listener_; |
| 107 std::string certificate_; | |
| 108 scoped_ptr<crypto::RSAPrivateKey> private_key_; | |
| 109 bool allow_nat_traversal_; | 104 bool allow_nat_traversal_; |
| 110 | 105 |
| 111 bool allow_local_ips_; | 106 bool allow_local_ips_; |
| 112 | 107 |
| 113 scoped_ptr<cricket::PortAllocator> port_allocator_; | 108 scoped_ptr<cricket::PortAllocator> port_allocator_; |
| 114 cricket::HttpPortAllocator* http_port_allocator_; | 109 cricket::HttpPortAllocator* http_port_allocator_; |
| 115 scoped_ptr<cricket::SessionManager> cricket_session_manager_; | 110 scoped_ptr<cricket::SessionManager> cricket_session_manager_; |
| 116 scoped_ptr<JingleInfoRequest> jingle_info_request_; | 111 scoped_ptr<JingleInfoRequest> jingle_info_request_; |
| 117 scoped_ptr<JingleSignalingConnector> jingle_signaling_connector_; | 112 scoped_ptr<JingleSignalingConnector> jingle_signaling_connector_; |
| 118 | 113 |
| 119 bool closed_; | 114 bool closed_; |
| 120 | 115 |
| 121 std::list<JingleSession*> sessions_; | 116 std::list<JingleSession*> sessions_; |
| 122 | 117 |
| 123 ScopedRunnableMethodFactory<JingleSessionManager> task_factory_; | 118 ScopedRunnableMethodFactory<JingleSessionManager> task_factory_; |
| 124 | 119 |
| 125 DISALLOW_COPY_AND_ASSIGN(JingleSessionManager); | 120 DISALLOW_COPY_AND_ASSIGN(JingleSessionManager); |
| 126 }; | 121 }; |
| 127 | 122 |
| 128 } // namespace protocol | 123 } // namespace protocol |
| 129 } // namespace remoting | 124 } // namespace remoting |
| 130 | 125 |
| 131 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_ | 126 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_ |
| OLD | NEW |