| 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_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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 class SocketWrapper; | 39 class SocketWrapper; |
| 40 | 40 |
| 41 // Implements the protocol::Session interface using the Pepper P2P | 41 // Implements the protocol::Session interface using the Pepper P2P |
| 42 // Transport API. Created by PepperSessionManager for incoming and | 42 // Transport API. Created by PepperSessionManager for incoming and |
| 43 // outgoing connections. | 43 // outgoing connections. |
| 44 class PepperSession : public Session { | 44 class PepperSession : public Session { |
| 45 public: | 45 public: |
| 46 virtual ~PepperSession(); | 46 virtual ~PepperSession(); |
| 47 | 47 |
| 48 // Session interface. | 48 // Session interface. |
| 49 virtual void SetStateChangeCallback(StateChangeCallback* callback) OVERRIDE; | 49 virtual void SetStateChangeCallback( |
| 50 const StateChangeCallback& callback) OVERRIDE; |
| 50 virtual Error error() OVERRIDE; | 51 virtual Error error() OVERRIDE; |
| 51 virtual void CreateStreamChannel( | 52 virtual void CreateStreamChannel( |
| 52 const std::string& name, | 53 const std::string& name, |
| 53 const StreamChannelCallback& callback) OVERRIDE; | 54 const StreamChannelCallback& callback) OVERRIDE; |
| 54 virtual void CreateDatagramChannel( | 55 virtual void CreateDatagramChannel( |
| 55 const std::string& name, | 56 const std::string& name, |
| 56 const DatagramChannelCallback& callback) OVERRIDE; | 57 const DatagramChannelCallback& callback) OVERRIDE; |
| 57 virtual net::Socket* control_channel() OVERRIDE; | 58 virtual net::Socket* control_channel() OVERRIDE; |
| 58 virtual net::Socket* event_channel() OVERRIDE; | 59 virtual net::Socket* event_channel() OVERRIDE; |
| 59 virtual const std::string& jid() OVERRIDE; | 60 virtual const std::string& jid() OVERRIDE; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 74 | 75 |
| 75 typedef std::map<std::string, PepperChannel*> ChannelsMap; | 76 typedef std::map<std::string, PepperChannel*> ChannelsMap; |
| 76 | 77 |
| 77 PepperSession(PepperSessionManager* session_manager); | 78 PepperSession(PepperSessionManager* session_manager); |
| 78 | 79 |
| 79 // Start cs connection by sending session-initiate message. | 80 // Start cs connection by sending session-initiate message. |
| 80 void StartConnection(const std::string& peer_jid, | 81 void StartConnection(const std::string& peer_jid, |
| 81 const std::string& peer_public_key, | 82 const std::string& peer_public_key, |
| 82 const std::string& client_token, | 83 const std::string& client_token, |
| 83 CandidateSessionConfig* config, | 84 CandidateSessionConfig* config, |
| 84 Session::StateChangeCallback* state_change_callback); | 85 const StateChangeCallback& state_change_callback); |
| 85 | 86 |
| 86 // Handler for session-initiate response. | 87 // Handler for session-initiate response. |
| 87 void OnSessionInitiateResponse(const buzz::XmlElement* response); | 88 void OnSessionInitiateResponse(const buzz::XmlElement* response); |
| 88 | 89 |
| 89 // Called when an error occurs. Sets |error_| and closes the session. | 90 // Called when an error occurs. Sets |error_| and closes the session. |
| 90 void OnError(Error error); | 91 void OnError(Error error); |
| 91 | 92 |
| 92 // Called by PepperSessionManager on incoming |message|. Must fill | 93 // Called by PepperSessionManager on incoming |message|. Must fill |
| 93 // in |reply|. | 94 // in |reply|. |
| 94 void OnIncomingMessage(const JingleMessage& message, | 95 void OnIncomingMessage(const JingleMessage& message, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 117 // Close all the channels and terminate the session. | 118 // Close all the channels and terminate the session. |
| 118 void CloseInternal(bool failed); | 119 void CloseInternal(bool failed); |
| 119 | 120 |
| 120 // Sets |state_| to |new_state| and calls state change callback. | 121 // Sets |state_| to |new_state| and calls state change callback. |
| 121 void SetState(State new_state); | 122 void SetState(State new_state); |
| 122 | 123 |
| 123 PepperSessionManager* session_manager_; | 124 PepperSessionManager* session_manager_; |
| 124 std::string peer_jid_; | 125 std::string peer_jid_; |
| 125 std::string peer_public_key_; | 126 std::string peer_public_key_; |
| 126 scoped_ptr<CandidateSessionConfig> candidate_config_; | 127 scoped_ptr<CandidateSessionConfig> candidate_config_; |
| 127 scoped_ptr<StateChangeCallback> state_change_callback_; | 128 StateChangeCallback state_change_callback_; |
| 128 | 129 |
| 129 std::string session_id_; | 130 std::string session_id_; |
| 130 State state_; | 131 State state_; |
| 131 Error error_; | 132 Error error_; |
| 132 | 133 |
| 133 std::string remote_cert_; | 134 std::string remote_cert_; |
| 134 SessionConfig config_; | 135 SessionConfig config_; |
| 135 | 136 |
| 136 std::string shared_secret_; | 137 std::string shared_secret_; |
| 137 std::string initiator_token_; | 138 std::string initiator_token_; |
| 138 std::string receiver_token_; | 139 std::string receiver_token_; |
| 139 | 140 |
| 140 scoped_ptr<IqRequest> initiate_request_; | 141 scoped_ptr<IqRequest> initiate_request_; |
| 141 | 142 |
| 142 ChannelsMap channels_; | 143 ChannelsMap channels_; |
| 143 | 144 |
| 144 scoped_ptr<net::Socket> control_channel_socket_; | 145 scoped_ptr<net::Socket> control_channel_socket_; |
| 145 scoped_ptr<net::Socket> event_channel_socket_; | 146 scoped_ptr<net::Socket> event_channel_socket_; |
| 146 | 147 |
| 147 base::OneShotTimer<PepperSession> transport_infos_timer_; | 148 base::OneShotTimer<PepperSession> transport_infos_timer_; |
| 148 std::list<cricket::Candidate> pending_candidates_; | 149 std::list<cricket::Candidate> pending_candidates_; |
| 149 | 150 |
| 150 DISALLOW_COPY_AND_ASSIGN(PepperSession); | 151 DISALLOW_COPY_AND_ASSIGN(PepperSession); |
| 151 }; | 152 }; |
| 152 | 153 |
| 153 } // namespace protocol | 154 } // namespace protocol |
| 154 } // namespace remoting | 155 } // namespace remoting |
| 155 | 156 |
| 156 #endif // REMOTING_PROTOCOL_PEPPER_SESSION_H_ | 157 #endif // REMOTING_PROTOCOL_PEPPER_SESSION_H_ |
| OLD | NEW |