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
3 // found in the LICENSE file.
5 #ifndef REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_
6 #define REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_
12 #include "base/memory/ref_counted.h"
13 #include "net/cert/x509_certificate.h"
14 #include "remoting/jingle_glue/signal_strategy.h"
15 #include "remoting/protocol/jingle_messages.h"
16 #include "remoting/protocol/session_manager.h"
28 } // namespace talk_base
33 class JingleInfoRequest;
38 class TransportFactory;
40 // JingleSessionManager and JingleSession implement the subset of the
41 // Jingle protocol used in Chromoting. JingleSessionManager provides
42 // the protocol::SessionManager interface for accepting incoming and
43 // creating outgoing sessions.
44 class JingleSessionManager : public SessionManager,
45 public SignalStrategy::Listener {
47 // When |fetch_stun_relay_config| is set to true then
48 // JingleSessionManager will also try to query configuration of STUN
49 // and Relay servers from the signaling server.
51 // TODO(sergeyu): Move NAT-traversal config fetching to a separate
53 explicit JingleSessionManager(
54 scoped_ptr<TransportFactory> transport_factory,
55 bool fetch_stun_relay_config);
56 virtual ~JingleSessionManager();
58 // SessionManager interface.
59 virtual void Init(SignalStrategy* signal_strategy,
60 SessionManager::Listener* listener) OVERRIDE;
61 virtual scoped_ptr<Session> Connect(
62 const std::string& host_jid,
63 scoped_ptr<Authenticator> authenticator,
64 scoped_ptr<CandidateSessionConfig> config) OVERRIDE;
65 virtual void Close() OVERRIDE;
66 virtual void set_authenticator_factory(
67 scoped_ptr<AuthenticatorFactory> authenticator_factory) OVERRIDE;
69 // SignalStrategy::Listener interface.
70 virtual void OnSignalStrategyStateChange(
71 SignalStrategy::State state) OVERRIDE;
72 virtual bool OnSignalStrategyIncomingStanza(
73 const buzz::XmlElement* stanza) OVERRIDE;
76 friend class JingleSession;
78 typedef std::map<std::string, JingleSession*> SessionsMap;
81 const std::string& relay_token,
82 const std::vector<std::string>& relay_hosts,
83 const std::vector<talk_base::SocketAddress>& stun_hosts);
85 IqSender* iq_sender() { return iq_sender_.get(); }
86 void SendReply(const buzz::XmlElement* original_stanza,
87 JingleMessageReply::ErrorType error);
89 // Called by JingleSession when it is being destroyed.
90 void SessionDestroyed(JingleSession* session);
92 scoped_ptr<TransportFactory> transport_factory_;
93 bool fetch_stun_relay_config_;
95 SignalStrategy* signal_strategy_;
96 scoped_ptr<AuthenticatorFactory> authenticator_factory_;
97 scoped_ptr<IqSender> iq_sender_;
98 SessionManager::Listener* listener_;
102 scoped_ptr<JingleInfoRequest> jingle_info_request_;
104 SessionsMap sessions_;
106 DISALLOW_COPY_AND_ASSIGN(JingleSessionManager);
109 } // namespace protocol
110 } // namespace remoting
112 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_