jingle_session_manager.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.
  4. #ifndef REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_
  5. #define REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_
  6. #include <map>
  7. #include <string>
  8. #include "base/memory/raw_ptr.h"
  9. #include "base/sequence_checker.h"
  10. #include "remoting/protocol/jingle_messages.h"
  11. #include "remoting/protocol/session_manager.h"
  12. #include "remoting/signaling/signal_strategy.h"
  13. namespace jingle_xmpp {
  14. class XmlElement;
  15. } // namespace jingle_xmpp
  16. namespace remoting {
  17. class IqSender;
  18. namespace protocol {
  19. class JingleSession;
  20. // JingleSessionManager and JingleSession implement the subset of the
  21. // Jingle protocol used in Chromoting. JingleSessionManager provides
  22. // the protocol::SessionManager interface for accepting incoming and
  23. // creating outgoing sessions.
  24. class JingleSessionManager : public SessionManager,
  25. public SignalStrategy::Listener {
  26. public:
  27. explicit JingleSessionManager(SignalStrategy* signal_strategy);
  28. JingleSessionManager(const JingleSessionManager&) = delete;
  29. JingleSessionManager& operator=(const JingleSessionManager&) = delete;
  30. ~JingleSessionManager() override;
  31. // SessionManager interface.
  32. void AcceptIncoming(
  33. const IncomingSessionCallback& incoming_session_callback) override;
  34. void set_protocol_config(
  35. std::unique_ptr<CandidateSessionConfig> config) override;
  36. std::unique_ptr<Session> Connect(
  37. const SignalingAddress& peer_address,
  38. std::unique_ptr<Authenticator> authenticator) override;
  39. void set_authenticator_factory(
  40. std::unique_ptr<AuthenticatorFactory> authenticator_factory) override;
  41. private:
  42. friend class JingleSession;
  43. // SignalStrategy::Listener interface.
  44. void OnSignalStrategyStateChange(SignalStrategy::State state) override;
  45. bool OnSignalStrategyIncomingStanza(const jingle_xmpp::XmlElement* stanza) override;
  46. typedef std::map<std::string, JingleSession*> SessionsMap;
  47. IqSender* iq_sender() { return iq_sender_.get(); }
  48. void SendReply(std::unique_ptr<jingle_xmpp::XmlElement> original_stanza,
  49. JingleMessageReply::ErrorType error);
  50. // Called by JingleSession when it is being destroyed.
  51. void SessionDestroyed(JingleSession* session);
  52. raw_ptr<SignalStrategy> signal_strategy_ = nullptr;
  53. IncomingSessionCallback incoming_session_callback_;
  54. std::unique_ptr<CandidateSessionConfig> protocol_config_;
  55. std::unique_ptr<AuthenticatorFactory> authenticator_factory_;
  56. std::unique_ptr<IqSender> iq_sender_;
  57. SessionsMap sessions_;
  58. SEQUENCE_CHECKER(sequence_checker_);
  59. };
  60. } // namespace protocol
  61. } // namespace remoting
  62. #endif // REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_