Chromium Code Reviews| Index: remoting/protocol/pepper_session.h |
| diff --git a/remoting/protocol/pepper_session.h b/remoting/protocol/pepper_session.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..25c839f661d67f5431b0888ade674f9663b50d2d |
| --- /dev/null |
| +++ b/remoting/protocol/pepper_session.h |
| @@ -0,0 +1,168 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef REMOTING_PROTOCOL_PEPPER_SESSION_H_ |
| +#define REMOTING_PROTOCOL_PEPPER_SESSION_H_ |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "base/timer.h" |
| +#include "crypto/rsa_private_key.h" |
| +#include "net/base/completion_callback.h" |
| +#include "remoting/protocol/jingle_messages.h" |
| +#include "remoting/protocol/session.h" |
| +#include "remoting/protocol/session_config.h" |
| + |
| +namespace net { |
| +class CertVerifier; |
| +class ClientSocketFactory; |
| +class Socket; |
| +class StreamSocket; |
| +class X509Certificate; |
| +} // namespace net |
| + |
| +namespace pp { |
| +class Instance; |
| +} // namespace pp |
| + |
| +namespace remoting { |
| + |
| +class IqRequest; |
| + |
| +namespace protocol { |
| + |
| +class PepperChannel; |
| +class PepperSessionManager; |
| +class SocketWrapper; |
| + |
| +// Implements protocol::Session that work over Pepper P2P Transport |
| +// API. Created by PepperSessionManager for incoming and outgoing |
| +// connections. |
|
Wez
2011/09/01 01:08:29
Wording. How about:
"Implements the protocol::Se
Sergey Ulanov
2011/09/08 00:48:36
Done.
|
| +class PepperSession : public Session { |
| + public: |
| + // TODO(sergeyu): Move this type and error() method to Session class. |
| + enum Error { |
| + NO_ERROR = 0, |
| + HOST_IS_OFFLINE, |
| + SESSION_REJECTED, |
| + INCOMPATIBLE_PROTOCOL, |
| + CHANNEL_CONNECTION_FAILURE, |
| + }; |
| + |
| + virtual ~PepperSession(); |
| + |
| + pp::Instance* pp_instance(); |
|
Wez
2011/09/01 01:08:29
Why is this exposed?
Sergey Ulanov
2011/09/08 00:48:36
Done.
|
| + |
| + Error error(); |
| + |
| + // Chromotocol Session interface. |
|
Wez
2011/09/01 01:08:29
Do we need all the blank lines between the definit
Sergey Ulanov
2011/09/08 00:48:36
Done.
|
| + virtual void SetStateChangeCallback(StateChangeCallback* callback) OVERRIDE; |
| + |
| + virtual void CreateStreamChannel( |
| + const std::string& name, |
| + const StreamChannelCallback& callback) OVERRIDE; |
| + virtual void CreateDatagramChannel( |
| + const std::string& name, |
| + const DatagramChannelCallback& callback) OVERRIDE; |
| + |
| + virtual net::Socket* control_channel() OVERRIDE; |
| + virtual net::Socket* event_channel() OVERRIDE; |
| + |
| + virtual const std::string& jid() OVERRIDE; |
| + |
| + virtual const CandidateSessionConfig* candidate_config() OVERRIDE; |
| + |
| + virtual const SessionConfig* config() OVERRIDE; |
| + virtual void set_config(const SessionConfig* config) OVERRIDE; |
| + |
| + virtual const std::string& initiator_token() OVERRIDE; |
| + virtual void set_initiator_token(const std::string& initiator_token) OVERRIDE; |
| + virtual const std::string& receiver_token() OVERRIDE; |
| + virtual void set_receiver_token(const std::string& receiver_token) OVERRIDE; |
| + |
| + virtual void set_shared_secret(const std::string& secret) OVERRIDE; |
| + virtual const std::string& shared_secret() OVERRIDE; |
| + |
| + virtual void Close() OVERRIDE; |
| + |
| + private: |
| + friend class PepperSessionManager; |
| + friend class PepperStreamChannel; |
| + |
| + typedef std::map<std::string, PepperChannel*> ChannelsMap; |
| + |
| + PepperSession(PepperSessionManager* session_manager); |
| + |
| + void StartConnection(const std::string& host_jid, |
| + const std::string& host_public_key, |
| + const std::string& client_token, |
| + CandidateSessionConfig* config, |
| + Session::StateChangeCallback* state_change_callback); |
| + void OnSessionInitiateResponse(const buzz::XmlElement* response); |
| + |
| + void OnError(Error error); |
| + |
| + // Called by PepperSessionManager on incoming |message|. Must fill |
| + // in |reply|. |
| + void OnIncomingMessage(const JingleMessage& message, |
| + JingleMessageReply* reply); |
|
Wez
2011/09/01 01:08:29
Do we need to re-name the JingleXXX classes to som
Sergey Ulanov
2011/09/08 00:48:36
JingleXXX is the right name for these, they implem
|
| + |
| + void OnAccept(const JingleMessage& message, JingleMessageReply* reply); |
| + void OnReject(const JingleMessage& message, JingleMessageReply* reply); |
| + void OnTerminate(const JingleMessage& message, JingleMessageReply* reply); |
| + void ProcessTransportInfo(const JingleMessage& message); |
| + |
| + bool InitializeConfigFromDescription(const ContentDescription* description); |
| + |
| + // Called by PepperChannel. |
| + void AddLocalCandidate(const cricket::Candidate& candidate); |
| + void OnDeleteChannel(PepperChannel* channel); |
| + |
| + void SendTransportInfos(); |
|
Wez
2011/09/01 01:08:29
I assume the s means we're sending multiple Transp
Sergey Ulanov
2011/09/08 00:48:36
Renamed it to SendTransportInfo() It sends just on
|
| + |
| + void CreateChannels(); |
| + void OnChannelConnected(scoped_ptr<net::Socket>* socket_container, |
| + net::StreamSocket* socket); |
| + |
| + // Close all the channels and terminate the session. |
| + void CloseInternal(bool failed); |
| + |
| + void SetState(State new_state); |
| + |
| + PepperSessionManager* session_manager_; |
| + std::string host_jid_; |
| + std::string host_public_key_; |
| + scoped_ptr<CandidateSessionConfig> candidate_config_; |
| + scoped_ptr<StateChangeCallback> state_change_callback_; |
| + |
| + std::string sid_; |
|
Wez
2011/09/01 01:08:29
What is "sid"?
Sergey Ulanov
2011/09/08 00:48:36
renamed to session_id_
|
| + State state_; |
| + Error error_; |
| + |
| + std::string remote_cert_; |
| + scoped_ptr<SessionConfig> config_; |
| + |
| + std::string shared_secret_; |
| + std::string initiator_token_; |
| + std::string receiver_token_; |
| + |
| + scoped_ptr<IqRequest> initiate_request_; |
| + |
| + ChannelsMap channels_; |
| + |
| + scoped_ptr<net::Socket> control_channel_socket_; |
| + scoped_ptr<net::Socket> event_channel_socket_; |
| + |
| + base::OneShotTimer<PepperSession> transport_infos_timer_; |
| + std::list<cricket::Candidate> pending_candidates_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PepperSession); |
| +}; |
| + |
| +} // namespace protocol |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_PROTOCOL_PEPPER_SESSION_H_ |