Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / remoting / protocol / jingle_session_manager.h
blob8d9897c3a051acb3b1a712b0a6610bc325ff4284
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_
8 #include <list>
9 #include <map>
10 #include <string>
12 #include "base/memory/ref_counted.h"
13 #include "net/cert/x509_certificate.h"
14 #include "remoting/protocol/jingle_messages.h"
15 #include "remoting/protocol/session_manager.h"
16 #include "remoting/signaling/signal_strategy.h"
18 namespace pp {
19 class Instance;
20 } // namespace pp
22 namespace buzz {
23 class XmlElement;
24 } // namespace buzz
26 namespace rtc {
27 class SocketAddress;
28 } // namespace rtc
30 namespace remoting {
32 class IqSender;
34 namespace protocol {
36 class JingleSession;
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 {
45 public:
46 explicit JingleSessionManager(scoped_ptr<TransportFactory> transport_factory);
47 ~JingleSessionManager() override;
49 // SessionManager interface.
50 void Init(SignalStrategy* signal_strategy,
51 SessionManager::Listener* listener) override;
52 void set_protocol_config(scoped_ptr<CandidateSessionConfig> config) override;
53 scoped_ptr<Session> Connect(
54 const std::string& host_jid,
55 scoped_ptr<Authenticator> authenticator) override;
56 void Close() override;
57 void set_authenticator_factory(
58 scoped_ptr<AuthenticatorFactory> authenticator_factory) override;
60 // SignalStrategy::Listener interface.
61 void OnSignalStrategyStateChange(SignalStrategy::State state) override;
62 bool OnSignalStrategyIncomingStanza(const buzz::XmlElement* stanza) override;
64 private:
65 friend class JingleSession;
67 typedef std::map<std::string, JingleSession*> SessionsMap;
69 void OnJingleInfo(
70 const std::string& relay_token,
71 const std::vector<std::string>& relay_hosts,
72 const std::vector<rtc::SocketAddress>& stun_hosts);
74 IqSender* iq_sender() { return iq_sender_.get(); }
75 void SendReply(const buzz::XmlElement* original_stanza,
76 JingleMessageReply::ErrorType error);
78 // Called by JingleSession when it is being destroyed.
79 void SessionDestroyed(JingleSession* session);
81 scoped_ptr<CandidateSessionConfig> protocol_config_;
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_;
91 bool ready_;
93 SessionsMap sessions_;
95 DISALLOW_COPY_AND_ASSIGN(JingleSessionManager);
98 } // namespace protocol
99 } // namespace remoting
101 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_