| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_PEPPER_SESSION_H_ | 5 #ifndef REMOTING_PROTOCOL_PEPPER_SESSION_H_ |
| 6 #define REMOTING_PROTOCOL_PEPPER_SESSION_H_ | 6 #define REMOTING_PROTOCOL_PEPPER_SESSION_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/timer.h" | 13 #include "base/timer.h" |
| 14 #include "crypto/rsa_private_key.h" | 14 #include "crypto/rsa_private_key.h" |
| 15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 16 #include "remoting/protocol/jingle_messages.h" | 16 #include "remoting/protocol/jingle_messages.h" |
| 17 #include "remoting/protocol/session.h" | 17 #include "remoting/protocol/session.h" |
| 18 #include "remoting/protocol/session_config.h" | 18 #include "remoting/protocol/session_config.h" |
| 19 #include "remoting/protocol/transport.h" |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 class Socket; | 22 class Socket; |
| 22 class StreamSocket; | 23 class StreamSocket; |
| 23 } // namespace net | 24 } // namespace net |
| 24 | 25 |
| 25 namespace remoting { | 26 namespace remoting { |
| 26 | 27 |
| 27 class IqRequest; | 28 class IqRequest; |
| 28 | 29 |
| 29 namespace protocol { | 30 namespace protocol { |
| 30 | 31 |
| 31 class Authenticator; | 32 class Authenticator; |
| 32 class PepperChannel; | |
| 33 class PepperSessionManager; | 33 class PepperSessionManager; |
| 34 | 34 |
| 35 // Implements the protocol::Session interface using the Pepper P2P | 35 // Implements the protocol::Session interface using the Pepper P2P |
| 36 // Transport API. Created by PepperSessionManager for incoming and | 36 // Transport API. Created by PepperSessionManager for incoming and |
| 37 // outgoing connections. | 37 // outgoing connections. |
| 38 class PepperSession : public Session { | 38 class PepperSession : public Session, |
| 39 public Transport::EventHandler { |
| 39 public: | 40 public: |
| 40 virtual ~PepperSession(); | 41 virtual ~PepperSession(); |
| 41 | 42 |
| 42 // Session interface. | 43 // Session interface. |
| 43 virtual void SetStateChangeCallback( | 44 virtual void SetStateChangeCallback( |
| 44 const StateChangeCallback& callback) OVERRIDE; | 45 const StateChangeCallback& callback) OVERRIDE; |
| 45 virtual void SetRouteChangeCallback( | 46 virtual void SetRouteChangeCallback( |
| 46 const RouteChangeCallback& callback) OVERRIDE; | 47 const RouteChangeCallback& callback) OVERRIDE; |
| 47 virtual Error error() OVERRIDE; | 48 virtual Error error() OVERRIDE; |
| 48 virtual void CreateStreamChannel( | 49 virtual void CreateStreamChannel( |
| 49 const std::string& name, | 50 const std::string& name, |
| 50 const StreamChannelCallback& callback) OVERRIDE; | 51 const StreamChannelCallback& callback) OVERRIDE; |
| 51 virtual void CreateDatagramChannel( | 52 virtual void CreateDatagramChannel( |
| 52 const std::string& name, | 53 const std::string& name, |
| 53 const DatagramChannelCallback& callback) OVERRIDE; | 54 const DatagramChannelCallback& callback) OVERRIDE; |
| 54 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; | 55 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; |
| 55 virtual const std::string& jid() OVERRIDE; | 56 virtual const std::string& jid() OVERRIDE; |
| 56 virtual const CandidateSessionConfig* candidate_config() OVERRIDE; | 57 virtual const CandidateSessionConfig* candidate_config() OVERRIDE; |
| 57 virtual const SessionConfig& config() OVERRIDE; | 58 virtual const SessionConfig& config() OVERRIDE; |
| 58 virtual void set_config(const SessionConfig& config) OVERRIDE; | 59 virtual void set_config(const SessionConfig& config) OVERRIDE; |
| 59 virtual void Close() OVERRIDE; | 60 virtual void Close() OVERRIDE; |
| 60 | 61 |
| 62 // Transport::EventHandler interface. |
| 63 virtual void OnChannelCandidate(Transport* channel, |
| 64 const cricket::Candidate& candidate) OVERRIDE; |
| 65 virtual void OnChannelDeleted(Transport* channel) OVERRIDE; |
| 66 |
| 61 private: | 67 private: |
| 62 friend class PepperSessionManager; | 68 friend class PepperSessionManager; |
| 63 friend class PepperStreamChannel; | 69 friend class PepperStreamChannel; |
| 64 | 70 |
| 65 typedef std::map<std::string, PepperChannel*> ChannelsMap; | 71 typedef std::map<std::string, Transport*> ChannelsMap; |
| 66 | 72 |
| 67 explicit PepperSession(PepperSessionManager* session_manager); | 73 explicit PepperSession(PepperSessionManager* session_manager); |
| 68 | 74 |
| 69 // Start cs connection by sending session-initiate message. | 75 // Start cs connection by sending session-initiate message. |
| 70 void StartConnection(const std::string& peer_jid, | 76 void StartConnection(const std::string& peer_jid, |
| 71 scoped_ptr<Authenticator> authenticator, | 77 scoped_ptr<Authenticator> authenticator, |
| 72 scoped_ptr<CandidateSessionConfig> config, | 78 scoped_ptr<CandidateSessionConfig> config, |
| 73 const StateChangeCallback& state_change_callback); | 79 const StateChangeCallback& state_change_callback); |
| 74 | 80 |
| 75 // Handler for session-initiate response. | 81 // Handler for session-initiate response. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 88 void OnSessionInfo(const JingleMessage& message, JingleMessageReply* reply); | 94 void OnSessionInfo(const JingleMessage& message, JingleMessageReply* reply); |
| 89 void OnTerminate(const JingleMessage& message, JingleMessageReply* reply); | 95 void OnTerminate(const JingleMessage& message, JingleMessageReply* reply); |
| 90 void ProcessTransportInfo(const JingleMessage& message); | 96 void ProcessTransportInfo(const JingleMessage& message); |
| 91 | 97 |
| 92 // Called from OnAccept() to initialize session config. | 98 // Called from OnAccept() to initialize session config. |
| 93 bool InitializeConfigFromDescription(const ContentDescription* description); | 99 bool InitializeConfigFromDescription(const ContentDescription* description); |
| 94 | 100 |
| 95 void ProcessAuthenticationStep(); | 101 void ProcessAuthenticationStep(); |
| 96 void OnSessionInfoResponse(const buzz::XmlElement* response); | 102 void OnSessionInfoResponse(const buzz::XmlElement* response); |
| 97 | 103 |
| 98 // Called by PepperChannel. | |
| 99 void AddLocalCandidate(const cricket::Candidate& candidate); | |
| 100 void OnDeleteChannel(PepperChannel* channel); | |
| 101 | |
| 102 void SendTransportInfo(); | 104 void SendTransportInfo(); |
| 103 void OnTransportInfoResponse(const buzz::XmlElement* response); | 105 void OnTransportInfoResponse(const buzz::XmlElement* response); |
| 104 | 106 |
| 105 // Close all the channels and terminate the session. | 107 // Close all the channels and terminate the session. |
| 106 void CloseInternal(bool failed); | 108 void CloseInternal(bool failed); |
| 107 | 109 |
| 108 // Sets |state_| to |new_state| and calls state change callback. | 110 // Sets |state_| to |new_state| and calls state change callback. |
| 109 void SetState(State new_state); | 111 void SetState(State new_state); |
| 110 | 112 |
| 111 PepperSessionManager* session_manager_; | 113 PepperSessionManager* session_manager_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 130 base::OneShotTimer<PepperSession> transport_infos_timer_; | 132 base::OneShotTimer<PepperSession> transport_infos_timer_; |
| 131 std::list<cricket::Candidate> pending_candidates_; | 133 std::list<cricket::Candidate> pending_candidates_; |
| 132 | 134 |
| 133 DISALLOW_COPY_AND_ASSIGN(PepperSession); | 135 DISALLOW_COPY_AND_ASSIGN(PepperSession); |
| 134 }; | 136 }; |
| 135 | 137 |
| 136 } // namespace protocol | 138 } // namespace protocol |
| 137 } // namespace remoting | 139 } // namespace remoting |
| 138 | 140 |
| 139 #endif // REMOTING_PROTOCOL_PEPPER_SESSION_H_ | 141 #endif // REMOTING_PROTOCOL_PEPPER_SESSION_H_ |
| OLD | NEW |