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
37 class TransportFactory
;
39 // JingleSessionManager and JingleSession implement the subset of the
40 // Jingle protocol used in Chromoting. JingleSessionManager provides
41 // the protocol::SessionManager interface for accepting incoming and
42 // creating outgoing sessions.
43 class JingleSessionManager
: public SessionManager
,
44 public SignalStrategy::Listener
{
46 explicit JingleSessionManager(scoped_ptr
<TransportFactory
> transport_factory
);
47 virtual ~JingleSessionManager();
49 // SessionManager interface.
50 virtual void Init(SignalStrategy
* signal_strategy
,
51 SessionManager::Listener
* listener
) OVERRIDE
;
52 virtual scoped_ptr
<Session
> Connect(
53 const std::string
& host_jid
,
54 scoped_ptr
<Authenticator
> authenticator
,
55 scoped_ptr
<CandidateSessionConfig
> config
) OVERRIDE
;
56 virtual void Close() OVERRIDE
;
57 virtual void set_authenticator_factory(
58 scoped_ptr
<AuthenticatorFactory
> authenticator_factory
) OVERRIDE
;
60 // SignalStrategy::Listener interface.
61 virtual void OnSignalStrategyStateChange(
62 SignalStrategy::State state
) OVERRIDE
;
63 virtual bool OnSignalStrategyIncomingStanza(
64 const buzz::XmlElement
* stanza
) OVERRIDE
;
67 friend class JingleSession
;
69 typedef std::map
<std::string
, JingleSession
*> SessionsMap
;
72 const std::string
& relay_token
,
73 const std::vector
<std::string
>& relay_hosts
,
74 const std::vector
<talk_base::SocketAddress
>& stun_hosts
);
76 IqSender
* iq_sender() { return iq_sender_
.get(); }
77 void SendReply(const buzz::XmlElement
* original_stanza
,
78 JingleMessageReply::ErrorType error
);
80 // Called by JingleSession when it is being destroyed.
81 void SessionDestroyed(JingleSession
* session
);
83 scoped_ptr
<TransportFactory
> transport_factory_
;
84 bool fetch_stun_relay_config_
;
86 SignalStrategy
* signal_strategy_
;
87 scoped_ptr
<AuthenticatorFactory
> authenticator_factory_
;
88 scoped_ptr
<IqSender
> iq_sender_
;
89 SessionManager::Listener
* listener_
;
93 SessionsMap sessions_
;
95 DISALLOW_COPY_AND_ASSIGN(JingleSessionManager
);
98 } // namespace protocol
99 } // namespace remoting
101 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_