OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 11 matching lines...) Expand all Loading... |
22 class SessionManager; | 22 class SessionManager; |
23 } // namespace cricket | 23 } // namespace cricket |
24 | 24 |
25 namespace remoting { | 25 namespace remoting { |
26 | 26 |
27 class JingleThread; | 27 class JingleThread; |
28 | 28 |
29 namespace protocol { | 29 namespace protocol { |
30 | 30 |
31 // ContentDescription used for chromoting sessions. It simply wraps | 31 // ContentDescription used for chromoting sessions. It simply wraps |
32 // CandidateChromotocolConfig. CandidateChromotocolConfig doesn't inherit | 32 // CandidateSessionConfig. CandidateSessionConfig doesn't inherit |
33 // from ContentDescription to avoid dependency on libjingle in | 33 // from ContentDescription to avoid dependency on libjingle in |
34 // Chromotocol Session interface. | 34 // Chromotocol Session interface. |
35 class ContentDescription : public cricket::ContentDescription { | 35 class ContentDescription : public cricket::ContentDescription { |
36 public: | 36 public: |
37 explicit ContentDescription(const CandidateChromotocolConfig* config); | 37 explicit ContentDescription(const CandidateSessionConfig* config); |
38 ~ContentDescription(); | 38 ~ContentDescription(); |
39 | 39 |
40 const CandidateChromotocolConfig* config() const { | 40 const CandidateSessionConfig* config() const { |
41 return candidate_config_.get(); | 41 return candidate_config_.get(); |
42 } | 42 } |
43 | 43 |
44 private: | 44 private: |
45 scoped_ptr<const CandidateChromotocolConfig> candidate_config_; | 45 scoped_ptr<const CandidateSessionConfig> candidate_config_; |
46 }; | 46 }; |
47 | 47 |
48 // This class implements SessionClient for Chromoting sessions. It acts as a | 48 // This class implements SessionClient for Chromoting sessions. It acts as a |
49 // server that accepts chromoting connections and can also make new connections | 49 // server that accepts chromoting connections and can also make new connections |
50 // to other hosts. | 50 // to other hosts. |
51 class JingleSessionManager | 51 class JingleSessionManager |
52 : public protocol::SessionManager, | 52 : public protocol::SessionManager, |
53 public cricket::SessionClient { | 53 public cricket::SessionClient { |
54 public: | 54 public: |
55 explicit JingleSessionManager(remoting::JingleThread* jingle_thread); | 55 explicit JingleSessionManager(remoting::JingleThread* jingle_thread); |
56 | 56 |
57 // Initializes the session client. Doesn't accept ownership of the | 57 // Initializes the session client. Doesn't accept ownership of the |
58 // |session_manager|. Close() must be called _before_ the |session_manager| | 58 // |session_manager|. Close() must be called _before_ the |session_manager| |
59 // is destroyed. | 59 // is destroyed. |
60 virtual void Init(const std::string& local_jid, | 60 virtual void Init(const std::string& local_jid, |
61 cricket::SessionManager* cricket_session_manager, | 61 cricket::SessionManager* cricket_session_manager, |
62 IncomingSessionCallback* incoming_session_callback); | 62 IncomingSessionCallback* incoming_session_callback); |
63 | 63 |
64 // ChromotocolServer interface. | 64 // ChromotocolServer interface. |
65 virtual scoped_refptr<protocol::Session> Connect( | 65 virtual scoped_refptr<protocol::Session> Connect( |
66 const std::string& jid, | 66 const std::string& jid, |
67 CandidateChromotocolConfig* chromotocol_config, | 67 CandidateSessionConfig* candidate_config, |
68 protocol::Session::StateChangeCallback* state_change_callback); | 68 protocol::Session::StateChangeCallback* state_change_callback); |
69 virtual void Close(Task* closed_task); | 69 virtual void Close(Task* closed_task); |
70 | 70 |
71 void set_allow_local_ips(bool allow_local_ips); | 71 void set_allow_local_ips(bool allow_local_ips); |
72 | 72 |
73 protected: | 73 protected: |
74 virtual ~JingleSessionManager(); | 74 virtual ~JingleSessionManager(); |
75 | 75 |
76 private: | 76 private: |
77 friend class JingleSession; | 77 friend class JingleSession; |
78 | 78 |
79 // The jingle thread used by this object. | 79 // The jingle thread used by this object. |
80 JingleThread* jingle_thread(); | 80 JingleThread* jingle_thread(); |
81 | 81 |
82 // Message loop that corresponds to jingle_thread(). | 82 // Message loop that corresponds to jingle_thread(). |
83 MessageLoop* message_loop(); | 83 MessageLoop* message_loop(); |
84 | 84 |
85 // Called by JingleChromotocolConnection when a new connection is initiated. | 85 // Called by JingleChromotocolConnection when a new connection is initiated. |
86 void AcceptConnection(JingleSession* jingle_session, | 86 void AcceptConnection(JingleSession* jingle_session, |
87 cricket::Session* cricket_session); | 87 cricket::Session* cricket_session); |
88 | 88 |
89 void DoConnect( | 89 void DoConnect( |
90 scoped_refptr<JingleSession> jingle_session, | 90 scoped_refptr<JingleSession> jingle_session, |
91 const std::string& jid, | 91 const std::string& jid, |
92 protocol::Session::StateChangeCallback* state_change_callback); | 92 protocol::Session::StateChangeCallback* state_change_callback); |
93 | 93 |
94 // Creates outgoing session description for an incoming session. | 94 // Creates outgoing session description for an incoming session. |
95 cricket::SessionDescription* CreateSessionDescription( | 95 cricket::SessionDescription* CreateSessionDescription( |
96 const CandidateChromotocolConfig* config); | 96 const CandidateSessionConfig* candidate_config); |
97 | 97 |
98 // cricket::SessionClient interface. | 98 // cricket::SessionClient interface. |
99 virtual void OnSessionCreate(cricket::Session* cricket_session, | 99 virtual void OnSessionCreate(cricket::Session* cricket_session, |
100 bool received_initiate); | 100 bool received_initiate); |
101 virtual void OnSessionDestroy(cricket::Session* cricket_session); | 101 virtual void OnSessionDestroy(cricket::Session* cricket_session); |
102 | 102 |
103 virtual bool ParseContent(cricket::SignalingProtocol protocol, | 103 virtual bool ParseContent(cricket::SignalingProtocol protocol, |
104 const buzz::XmlElement* elem, | 104 const buzz::XmlElement* elem, |
105 const cricket::ContentDescription** content, | 105 const cricket::ContentDescription** content, |
106 cricket::ParseError* error); | 106 cricket::ParseError* error); |
(...skipping 13 matching lines...) Expand all Loading... |
120 std::list<scoped_refptr<JingleSession> > sessions_; | 120 std::list<scoped_refptr<JingleSession> > sessions_; |
121 | 121 |
122 DISALLOW_COPY_AND_ASSIGN(JingleSessionManager); | 122 DISALLOW_COPY_AND_ASSIGN(JingleSessionManager); |
123 }; | 123 }; |
124 | 124 |
125 } // namespace protocol | 125 } // namespace protocol |
126 | 126 |
127 } // namespace remoting | 127 } // namespace remoting |
128 | 128 |
129 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_ | 129 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_MANAGER_H_ |
OLD | NEW |