| 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 OnTransportCandidate( |
| 64 Transport* transport, |
| 65 const cricket::Candidate& candidate) OVERRIDE; |
| 66 virtual void OnTransportDeleted(Transport* transport) OVERRIDE; |
| 67 |
| 61 private: | 68 private: |
| 62 friend class PepperSessionManager; | 69 friend class PepperSessionManager; |
| 63 friend class PepperStreamChannel; | 70 friend class PepperStreamChannel; |
| 64 | 71 |
| 65 typedef std::map<std::string, PepperChannel*> ChannelsMap; | 72 typedef std::map<std::string, Transport*> ChannelsMap; |
| 66 | 73 |
| 67 explicit PepperSession(PepperSessionManager* session_manager); | 74 explicit PepperSession(PepperSessionManager* session_manager); |
| 68 | 75 |
| 69 // Start cs connection by sending session-initiate message. | 76 // Start cs connection by sending session-initiate message. |
| 70 void StartConnection(const std::string& peer_jid, | 77 void StartConnection(const std::string& peer_jid, |
| 71 scoped_ptr<Authenticator> authenticator, | 78 scoped_ptr<Authenticator> authenticator, |
| 72 scoped_ptr<CandidateSessionConfig> config, | 79 scoped_ptr<CandidateSessionConfig> config, |
| 73 const StateChangeCallback& state_change_callback); | 80 const StateChangeCallback& state_change_callback); |
| 74 | 81 |
| 75 // Handler for session-initiate response. | 82 // Handler for session-initiate response. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 88 void OnSessionInfo(const JingleMessage& message, JingleMessageReply* reply); | 95 void OnSessionInfo(const JingleMessage& message, JingleMessageReply* reply); |
| 89 void OnTerminate(const JingleMessage& message, JingleMessageReply* reply); | 96 void OnTerminate(const JingleMessage& message, JingleMessageReply* reply); |
| 90 void ProcessTransportInfo(const JingleMessage& message); | 97 void ProcessTransportInfo(const JingleMessage& message); |
| 91 | 98 |
| 92 // Called from OnAccept() to initialize session config. | 99 // Called from OnAccept() to initialize session config. |
| 93 bool InitializeConfigFromDescription(const ContentDescription* description); | 100 bool InitializeConfigFromDescription(const ContentDescription* description); |
| 94 | 101 |
| 95 void ProcessAuthenticationStep(); | 102 void ProcessAuthenticationStep(); |
| 96 void OnSessionInfoResponse(const buzz::XmlElement* response); | 103 void OnSessionInfoResponse(const buzz::XmlElement* response); |
| 97 | 104 |
| 98 // Called by PepperChannel. | |
| 99 void AddLocalCandidate(const cricket::Candidate& candidate); | |
| 100 void OnDeleteChannel(PepperChannel* channel); | |
| 101 | |
| 102 void SendTransportInfo(); | 105 void SendTransportInfo(); |
| 103 void OnTransportInfoResponse(const buzz::XmlElement* response); | 106 void OnTransportInfoResponse(const buzz::XmlElement* response); |
| 104 | 107 |
| 105 // Close all the channels and terminate the session. | 108 // Close all the channels and terminate the session. |
| 106 void CloseInternal(bool failed); | 109 void CloseInternal(bool failed); |
| 107 | 110 |
| 108 // Sets |state_| to |new_state| and calls state change callback. | 111 // Sets |state_| to |new_state| and calls state change callback. |
| 109 void SetState(State new_state); | 112 void SetState(State new_state); |
| 110 | 113 |
| 111 PepperSessionManager* session_manager_; | 114 PepperSessionManager* session_manager_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 130 base::OneShotTimer<PepperSession> transport_infos_timer_; | 133 base::OneShotTimer<PepperSession> transport_infos_timer_; |
| 131 std::list<cricket::Candidate> pending_candidates_; | 134 std::list<cricket::Candidate> pending_candidates_; |
| 132 | 135 |
| 133 DISALLOW_COPY_AND_ASSIGN(PepperSession); | 136 DISALLOW_COPY_AND_ASSIGN(PepperSession); |
| 134 }; | 137 }; |
| 135 | 138 |
| 136 } // namespace protocol | 139 } // namespace protocol |
| 137 } // namespace remoting | 140 } // namespace remoting |
| 138 | 141 |
| 139 #endif // REMOTING_PROTOCOL_PEPPER_SESSION_H_ | 142 #endif // REMOTING_PROTOCOL_PEPPER_SESSION_H_ |
| OLD | NEW |