Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: remoting/protocol/pepper_session.h

Issue 7778022: Chromoting protocol implementation based on P2P Transport API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef REMOTING_PROTOCOL_PEPPER_SESSION_H_
6 #define REMOTING_PROTOCOL_PEPPER_SESSION_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/timer.h"
13 #include "crypto/rsa_private_key.h"
14 #include "net/base/completion_callback.h"
15 #include "remoting/protocol/jingle_messages.h"
16 #include "remoting/protocol/session.h"
17 #include "remoting/protocol/session_config.h"
18
19 namespace net {
20 class CertVerifier;
21 class ClientSocketFactory;
22 class Socket;
23 class StreamSocket;
24 class X509Certificate;
25 } // namespace net
26
27 namespace pp {
28 class Instance;
29 } // namespace pp
30
31 namespace remoting {
32
33 class IqRequest;
34
35 namespace protocol {
36
37 class PepperChannel;
38 class PepperSessionManager;
39 class SocketWrapper;
40
41 // Implements protocol::Session that work over Pepper P2P Transport
42 // API. Created by PepperSessionManager for incoming and outgoing
43 // connections.
Wez 2011/09/01 01:08:29 Wording. How about: "Implements the protocol::Se
Sergey Ulanov 2011/09/08 00:48:36 Done.
44 class PepperSession : public Session {
45 public:
46 // TODO(sergeyu): Move this type and error() method to Session class.
47 enum Error {
48 NO_ERROR = 0,
49 HOST_IS_OFFLINE,
50 SESSION_REJECTED,
51 INCOMPATIBLE_PROTOCOL,
52 CHANNEL_CONNECTION_FAILURE,
53 };
54
55 virtual ~PepperSession();
56
57 pp::Instance* pp_instance();
Wez 2011/09/01 01:08:29 Why is this exposed?
Sergey Ulanov 2011/09/08 00:48:36 Done.
58
59 Error error();
60
61 // 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.
62 virtual void SetStateChangeCallback(StateChangeCallback* callback) OVERRIDE;
63
64 virtual void CreateStreamChannel(
65 const std::string& name,
66 const StreamChannelCallback& callback) OVERRIDE;
67 virtual void CreateDatagramChannel(
68 const std::string& name,
69 const DatagramChannelCallback& callback) OVERRIDE;
70
71 virtual net::Socket* control_channel() OVERRIDE;
72 virtual net::Socket* event_channel() OVERRIDE;
73
74 virtual const std::string& jid() OVERRIDE;
75
76 virtual const CandidateSessionConfig* candidate_config() OVERRIDE;
77
78 virtual const SessionConfig* config() OVERRIDE;
79 virtual void set_config(const SessionConfig* config) OVERRIDE;
80
81 virtual const std::string& initiator_token() OVERRIDE;
82 virtual void set_initiator_token(const std::string& initiator_token) OVERRIDE;
83 virtual const std::string& receiver_token() OVERRIDE;
84 virtual void set_receiver_token(const std::string& receiver_token) OVERRIDE;
85
86 virtual void set_shared_secret(const std::string& secret) OVERRIDE;
87 virtual const std::string& shared_secret() OVERRIDE;
88
89 virtual void Close() OVERRIDE;
90
91 private:
92 friend class PepperSessionManager;
93 friend class PepperStreamChannel;
94
95 typedef std::map<std::string, PepperChannel*> ChannelsMap;
96
97 PepperSession(PepperSessionManager* session_manager);
98
99 void StartConnection(const std::string& host_jid,
100 const std::string& host_public_key,
101 const std::string& client_token,
102 CandidateSessionConfig* config,
103 Session::StateChangeCallback* state_change_callback);
104 void OnSessionInitiateResponse(const buzz::XmlElement* response);
105
106 void OnError(Error error);
107
108 // Called by PepperSessionManager on incoming |message|. Must fill
109 // in |reply|.
110 void OnIncomingMessage(const JingleMessage& message,
111 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
112
113 void OnAccept(const JingleMessage& message, JingleMessageReply* reply);
114 void OnReject(const JingleMessage& message, JingleMessageReply* reply);
115 void OnTerminate(const JingleMessage& message, JingleMessageReply* reply);
116 void ProcessTransportInfo(const JingleMessage& message);
117
118 bool InitializeConfigFromDescription(const ContentDescription* description);
119
120 // Called by PepperChannel.
121 void AddLocalCandidate(const cricket::Candidate& candidate);
122 void OnDeleteChannel(PepperChannel* channel);
123
124 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
125
126 void CreateChannels();
127 void OnChannelConnected(scoped_ptr<net::Socket>* socket_container,
128 net::StreamSocket* socket);
129
130 // Close all the channels and terminate the session.
131 void CloseInternal(bool failed);
132
133 void SetState(State new_state);
134
135 PepperSessionManager* session_manager_;
136 std::string host_jid_;
137 std::string host_public_key_;
138 scoped_ptr<CandidateSessionConfig> candidate_config_;
139 scoped_ptr<StateChangeCallback> state_change_callback_;
140
141 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_
142 State state_;
143 Error error_;
144
145 std::string remote_cert_;
146 scoped_ptr<SessionConfig> config_;
147
148 std::string shared_secret_;
149 std::string initiator_token_;
150 std::string receiver_token_;
151
152 scoped_ptr<IqRequest> initiate_request_;
153
154 ChannelsMap channels_;
155
156 scoped_ptr<net::Socket> control_channel_socket_;
157 scoped_ptr<net::Socket> event_channel_socket_;
158
159 base::OneShotTimer<PepperSession> transport_infos_timer_;
160 std::list<cricket::Candidate> pending_candidates_;
161
162 DISALLOW_COPY_AND_ASSIGN(PepperSession);
163 };
164
165 } // namespace protocol
166 } // namespace remoting
167
168 #endif // REMOTING_PROTOCOL_PEPPER_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698