OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef REMOTING_PROTOCOL_JINGLE_SESSION_H_ |
6 #define REMOTING_PROTOCOL_JINGLE_SESSION_H_ | 6 #define REMOTING_PROTOCOL_JINGLE_SESSION_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
11 #include "remoting/protocol/session.h" | 11 #include "remoting/protocol/session.h" |
12 #include "third_party/libjingle/source/talk/base/sigslot.h" | 12 #include "third_party/libjingle/source/talk/base/sigslot.h" |
13 #include "third_party/libjingle/source/talk/p2p/base/session.h" | 13 #include "third_party/libjingle/source/talk/p2p/base/session.h" |
14 | 14 |
15 namespace remoting { | 15 namespace remoting { |
16 namespace protocol { | 16 namespace protocol { |
17 | 17 |
18 class Authenticator; | 18 class Authenticator; |
19 class JingleChannelConnector; | 19 class JingleChannelConnector; |
20 class JingleSessionManager; | 20 class JingleSessionManager; |
21 | 21 |
22 // Implements protocol::Session that work over libjingle session (the | 22 // Implements protocol::Session that work over libjingle session (the |
23 // cricket::Session object is passed to Init() method). Created | 23 // cricket::Session object is passed to Init() method). Created |
24 // by JingleSessionManager for incoming and outgoing connections. | 24 // by JingleSessionManager for incoming and outgoing connections. |
25 class JingleSession : public protocol::Session, | 25 class JingleSession : public protocol::Session, |
26 public sigslot::has_slots<> { | 26 public sigslot::has_slots<> { |
27 public: | 27 public: |
| 28 virtual ~JingleSession(); |
| 29 |
28 // Session interface. | 30 // Session interface. |
29 virtual void SetStateChangeCallback( | 31 virtual void SetStateChangeCallback( |
30 const StateChangeCallback& callback) OVERRIDE; | 32 const StateChangeCallback& callback) OVERRIDE; |
31 virtual Error error() OVERRIDE; | 33 virtual Error error() OVERRIDE; |
32 virtual void CreateStreamChannel( | 34 virtual void CreateStreamChannel( |
33 const std::string& name, | 35 const std::string& name, |
34 const StreamChannelCallback& callback) OVERRIDE; | 36 const StreamChannelCallback& callback) OVERRIDE; |
35 virtual void CreateDatagramChannel( | 37 virtual void CreateDatagramChannel( |
36 const std::string& name, | 38 const std::string& name, |
37 const DatagramChannelCallback& callback) OVERRIDE; | 39 const DatagramChannelCallback& callback) OVERRIDE; |
38 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; | 40 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; |
39 virtual const std::string& jid() OVERRIDE; | 41 virtual const std::string& jid() OVERRIDE; |
40 virtual const CandidateSessionConfig* candidate_config() OVERRIDE; | 42 virtual const CandidateSessionConfig* candidate_config() OVERRIDE; |
41 virtual const SessionConfig& config() OVERRIDE; | 43 virtual const SessionConfig& config() OVERRIDE; |
42 virtual void set_config(const SessionConfig& config) OVERRIDE; | 44 virtual void set_config(const SessionConfig& config) OVERRIDE; |
43 virtual void Close() OVERRIDE; | 45 virtual void Close() OVERRIDE; |
44 | 46 |
45 private: | 47 private: |
46 friend class JingleDatagramConnector; | 48 friend class JingleDatagramConnector; |
47 friend class JingleSessionManager; | 49 friend class JingleSessionManager; |
48 friend class JingleStreamConnector; | 50 friend class JingleStreamConnector; |
49 | 51 |
50 typedef std::map<std::string, JingleChannelConnector*> ChannelConnectorsMap; | 52 typedef std::map<std::string, JingleChannelConnector*> ChannelConnectorsMap; |
51 | 53 |
52 // Takes ownership of |authenticator|. | |
53 JingleSession(JingleSessionManager* jingle_session_manager, | 54 JingleSession(JingleSessionManager* jingle_session_manager, |
54 cricket::Session* cricket_session, | 55 cricket::Session* cricket_session, |
55 Authenticator* authenticator); | 56 scoped_ptr<Authenticator> authenticator); |
56 virtual ~JingleSession(); | |
57 | 57 |
58 // Called by JingleSessionManager. | 58 // Called by JingleSessionManager. |
59 void set_candidate_config(const CandidateSessionConfig* candidate_config); | 59 void set_candidate_config( |
| 60 scoped_ptr<CandidateSessionConfig> candidate_config); |
60 | 61 |
61 // Sends session-initiate for new session. | 62 // Sends session-initiate for new session. |
62 void SendSessionInitiate(); | 63 void SendSessionInitiate(); |
63 | 64 |
64 // Close all the channels and terminate the session. |result| | 65 // Close all the channels and terminate the session. |result| |
65 // defines error code that should returned to currently opened | 66 // defines error code that should returned to currently opened |
66 // channels. |error| specified new value for error(). | 67 // channels. |error| specified new value for error(). |
67 void CloseInternal(int result, Error error); | 68 void CloseInternal(int result, Error error); |
68 | 69 |
69 bool HasSession(cricket::Session* cricket_session); | 70 bool HasSession(cricket::Session* cricket_session); |
(...skipping 30 matching lines...) Expand all Loading... |
100 // Called by JingleChannelConnector when it has finished connecting | 101 // Called by JingleChannelConnector when it has finished connecting |
101 // the channel, to remove itself from the table of pending connectors. The | 102 // the channel, to remove itself from the table of pending connectors. The |
102 // connector assumes responsibility for destroying itself after this call. | 103 // connector assumes responsibility for destroying itself after this call. |
103 void OnChannelConnectorFinished(const std::string& name, | 104 void OnChannelConnectorFinished(const std::string& name, |
104 JingleChannelConnector* connector); | 105 JingleChannelConnector* connector); |
105 | 106 |
106 const cricket::ContentInfo* GetContentInfo() const; | 107 const cricket::ContentInfo* GetContentInfo() const; |
107 | 108 |
108 void SetState(State new_state); | 109 void SetState(State new_state); |
109 | 110 |
110 static cricket::SessionDescription* CreateSessionDescription( | 111 static scoped_ptr<cricket::SessionDescription> CreateSessionDescription( |
111 const CandidateSessionConfig* candidate_config, | 112 scoped_ptr<CandidateSessionConfig> candidate_config, |
112 const buzz::XmlElement* authenticator_message); | 113 scoped_ptr<buzz::XmlElement> authenticator_message); |
113 | 114 |
114 // JingleSessionManager that created this session. Guaranteed to | 115 // JingleSessionManager that created this session. Guaranteed to |
115 // exist throughout the lifetime of the session. | 116 // exist throughout the lifetime of the session. |
116 JingleSessionManager* jingle_session_manager_; | 117 JingleSessionManager* jingle_session_manager_; |
117 | 118 |
118 scoped_ptr<Authenticator> authenticator_; | 119 scoped_ptr<Authenticator> authenticator_; |
119 | 120 |
120 State state_; | 121 State state_; |
121 StateChangeCallback state_change_callback_; | 122 StateChangeCallback state_change_callback_; |
122 | 123 |
(...skipping 25 matching lines...) Expand all Loading... |
148 base::WeakPtrFactory<JingleSession> weak_factory_; | 149 base::WeakPtrFactory<JingleSession> weak_factory_; |
149 | 150 |
150 DISALLOW_COPY_AND_ASSIGN(JingleSession); | 151 DISALLOW_COPY_AND_ASSIGN(JingleSession); |
151 }; | 152 }; |
152 | 153 |
153 } // namespace protocol | 154 } // namespace protocol |
154 | 155 |
155 } // namespace remoting | 156 } // namespace remoting |
156 | 157 |
157 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_H_ | 158 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_H_ |
OLD | NEW |