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

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

Issue 7312013: Minor cleanups in JingleSession and JingleSessionManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments. Created 9 years, 5 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
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 // The purprose of SessionManager is to facilitate creation of chromotocol 5 // The purpose of SessionManager is to facilitate creation of chromotocol
6 // sessions. Both host and client use it to establish chromotocol 6 // sessions. Both host and client use it to establish chromotocol
7 // sessions. JingleChromotocolServer implements this inteface using 7 // sessions. JingleChromotocolServer implements this inteface using
8 // libjingle. 8 // libjingle.
9 // 9 //
10 // OUTGOING SESSIONS 10 // OUTGOING SESSIONS
11 // Connect() must be used to create new session to a remote host. The 11 // Connect() must be used to create new session to a remote host. The
12 // returned sessionion is initially in INITIALIZING state. Later state is 12 // returned sessionion is initially in INITIALIZING state. Later state is
Wez 2011/07/06 23:26:55 nit: Old typo: "sessionion"
Sergey Ulanov 2011/07/07 00:50:30 Done.
13 // changed to CONNECTED if the session is accepted by the host or CLOSED 13 // changed to CONNECTED if the session is accepted by the host or CLOSED
14 // if the session is rejected. 14 // if the session is rejected.
15 // 15 //
16 // INCOMING SESSIONS 16 // INCOMING SESSIONS
17 // The IncomingSessionCallback is called when a client attempts to connect. 17 // The IncomingSessionCallback is called when a client attempts to connect.
18 // The callback function decides whether the session should be accepted or 18 // The callback function decides whether the session should be accepted or
19 // rejected. 19 // rejected.
20 // 20 //
21 // SESSION OWNERSHIP AND SHUTDOWN 21 // SESSION OWNERSHIP AND SHUTDOWN
22 // SessionManager owns all Chromotocol Session it creates. The server 22 // SessionManager owns all Sessions it creates. The manager must not
23 // must not be closed while sessions created by the server are still in use. 23 // be closed while sessions created by the server are still in
24 // When shutting down the Close() method for the sessionion and the server 24 // use. Caller owns Sessions created by a SessionManager (except
Wez 2011/07/06 23:26:55 The comment about closing makes the presence of a
Sergey Ulanov 2011/07/07 00:50:30 Done.
25 // objects must be called in the following order: Session, 25 // rejected sessions). Sessions must outlive SessionManager, and
26 // SessionManager, JingleClient. The same order must be followed in the case 26 // SessionManager must outlive SignalStrategy.
Wez 2011/07/06 23:26:55 The last comment is exactly the opposite of what's
Sergey Ulanov 2011/07/07 00:50:30 Done.
27 // of rejected and failed sessions.
28 // 27 //
29 // PROTOCOL VERSION NEGOTIATION 28 // PROTOCOL VERSION NEGOTIATION
30 // When client connects to a host it sends a session-initiate stanza with list 29 // When client connects to a host it sends a session-initiate stanza with list
31 // of supported configurations for each channel. If the host decides to accept 30 // of supported configurations for each channel. If the host decides to accept
32 // session, then it selects configuration that is supported by both sides 31 // session, then it selects configuration that is supported by both sides
33 // and then replies with the session-accept stanza that contans selected 32 // and then replies with the session-accept stanza that contans selected
34 // configuration. The configuration specified in the session-accept is used 33 // configuration. The configuration specified in the session-accept is used
35 // for the session. 34 // for the session.
36 // 35 //
37 // The CandidateSessionConfig class represents list of configurations 36 // The CandidateSessionConfig class represents list of configurations
(...skipping 25 matching lines...) Expand all
63 class X509Certificate; 62 class X509Certificate;
64 } // namespace net 63 } // namespace net
65 64
66 namespace remoting { 65 namespace remoting {
67 66
68 class SignalStrategy; 67 class SignalStrategy;
69 68
70 namespace protocol { 69 namespace protocol {
71 70
72 // Generic interface for Chromoting session manager. 71 // Generic interface for Chromoting session manager.
72 //
73 // TODO(sergeyu): Split this into two separate interfaces: one for the
74 // client side and one for the host side.
73 class SessionManager : public base::NonThreadSafe { 75 class SessionManager : public base::NonThreadSafe {
74 public: 76 public:
75 SessionManager() { } 77 SessionManager() { }
76 virtual ~SessionManager() { } 78 virtual ~SessionManager() { }
77 79
78 enum IncomingSessionResponse { 80 enum IncomingSessionResponse {
79 ACCEPT, 81 ACCEPT,
80 INCOMPATIBLE, 82 INCOMPATIBLE,
81 DECLINE, 83 DECLINE,
82 }; 84 };
83 85
84 // IncomingSessionCallback is called when a new session is 86 // IncomingSessionCallback is called when a new session is
85 // received. If the callback decides to accept the session it should 87 // received. If the callback decides to accept the session it should
86 // set the second argument to ACCEPT. Otherwise it should set it to 88 // set the second argument to ACCEPT. Otherwise it should set it to
87 // DECLINE, or INCOMPATIBLE. INCOMPATIBLE indicates that the session 89 // DECLINE, or INCOMPATIBLE. INCOMPATIBLE indicates that the session
88 // has incompatible configuration, and cannot be accepted. If the 90 // has incompatible configuration, and cannot be accepted. If the
89 // callback accepts session then it must also set configuration for 91 // callback accepts session then it must also set configuration for
90 // the new session using Session::set_config(). The callback must 92 // the new session using Session::set_config(). The callback must
91 // take ownership of the session if it accepts connection. 93 // take ownership of the session if it ACCEPTs it.
92 typedef Callback2<Session*, IncomingSessionResponse*>::Type 94 typedef Callback2<Session*, IncomingSessionResponse*>::Type
93 IncomingSessionCallback; 95 IncomingSessionCallback;
94 96
95 // Initializes the session client. Doesn't accept ownership of the 97 // Initializes the session client. Caller retains ownership of the
96 // |signal_strategy|. Close() must be called _before_ the |session_manager| 98 // |signal_strategy|. If this object is used in server mode, then
97 // is destroyed. 99 // |private_key| and |certificate| are used to establish a secured
98 // If this object is used in server mode, then |private_key| and 100 // communication with the client. It will also take ownership of
99 // |certificate| are used to establish a secured communication with the 101 // these objects. In case this is used in client mode, pass in NULL
100 // client. It will also take ownership of these objects. 102 // for both private key and certificate.
101 // In case this is used in client mode, pass in NULL for both private key and
102 // certificate.
103 virtual void Init(const std::string& local_jid, 103 virtual void Init(const std::string& local_jid,
104 SignalStrategy* signal_strategy, 104 SignalStrategy* signal_strategy,
105 IncomingSessionCallback* incoming_session_callback, 105 IncomingSessionCallback* incoming_session_callback,
106 crypto::RSAPrivateKey* private_key, 106 crypto::RSAPrivateKey* private_key,
107 scoped_refptr<net::X509Certificate> certificate) = 0; 107 scoped_refptr<net::X509Certificate> certificate) = 0;
108 108
109 // Tries to create a session to the host |jid|. 109 // Tries to create a session to the host |jid|.
110 // 110 //
111 // |host_jid| is the full jid of the host to connect to. 111 // |host_jid| is the full jid of the host to connect to.
112 // |host_public_key| is used to for authentication. 112 // |host_public_key| is used to for authentication.
113 // |client_oauth_token| is a short-lived OAuth token identify the client. 113 // |client_oauth_token| is a short-lived OAuth token identify the client.
114 // |config| contains the session configurations that the client supports. 114 // |config| contains the session configurations that the client supports.
115 // |state_change_callback| is called when the connection state changes. 115 // |state_change_callback| is called when the connection state changes.
116 // 116 //
117 // This function may be called from any thread. The |state_change_callback|
118 // is invoked on the network thread.
119 //
120 // Ownership of the |config| is passed to the new session. 117 // Ownership of the |config| is passed to the new session.
121 virtual Session* Connect( 118 virtual Session* Connect(
122 const std::string& host_jid, 119 const std::string& host_jid,
123 const std::string& host_public_key, 120 const std::string& host_public_key,
124 const std::string& client_token, 121 const std::string& client_token,
125 CandidateSessionConfig* config, 122 CandidateSessionConfig* config,
126 Session::StateChangeCallback* state_change_callback) = 0; 123 Session::StateChangeCallback* state_change_callback) = 0;
127 124
128 // Close session manager and all current sessions. No callbacks are 125 // Close session manager and all current sessions. No callbacks are
129 // called after this method returns. 126 // called after this method returns.
130 virtual void Close() = 0; 127 virtual void Close() = 0;
131 128
132 private: 129 private:
133 DISALLOW_COPY_AND_ASSIGN(SessionManager); 130 DISALLOW_COPY_AND_ASSIGN(SessionManager);
134 }; 131 };
135 132
136 } // namespace protocol 133 } // namespace protocol
137 } // namespace remoting 134 } // namespace remoting
138 135
139 #endif // REMOTING_PROTOCOL_SESSION_MANAGER_H_ 136 #endif // REMOTING_PROTOCOL_SESSION_MANAGER_H_
OLDNEW
« remoting/jingle_glue/jingle_thread.cc ('K') | « remoting/protocol/protocol_test_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698