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

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

Issue 1530523002: More cleanups in JingleSessionManager interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@transport_context
Patch Set: Created 5 years 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
« no previous file with comments | « remoting/protocol/protocol_mock_objects.h ('k') | remoting/test/protocol_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // The purpose 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
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // configuration sent in the session-intiate staza is available via 48 // configuration sent in the session-intiate staza is available via
49 // ChromotocolConnnection::candidate_config(). If an incoming session is 49 // ChromotocolConnnection::candidate_config(). If an incoming session is
50 // being accepted then the IncomingSessionCallback callback function must 50 // being accepted then the IncomingSessionCallback callback function must
51 // select session configuration and then set it with Session::set_config(). 51 // select session configuration and then set it with Session::set_config().
52 52
53 #ifndef REMOTING_PROTOCOL_SESSION_MANAGER_H_ 53 #ifndef REMOTING_PROTOCOL_SESSION_MANAGER_H_
54 #define REMOTING_PROTOCOL_SESSION_MANAGER_H_ 54 #define REMOTING_PROTOCOL_SESSION_MANAGER_H_
55 55
56 #include <string> 56 #include <string>
57 57
58 #include "base/callback.h"
58 #include "base/threading/non_thread_safe.h" 59 #include "base/threading/non_thread_safe.h"
59 #include "remoting/protocol/session.h" 60 #include "remoting/protocol/session.h"
60 61
61 namespace remoting { 62 namespace remoting {
62 63
63 class SignalStrategy; 64 class SignalStrategy;
64 65
65 namespace protocol { 66 namespace protocol {
66 67
67 class Authenticator; 68 class Authenticator;
68 class AuthenticatorFactory; 69 class AuthenticatorFactory;
69 70
70 // Generic interface for Chromoting session manager. 71 // Generic interface for Chromoting session manager.
71 //
72 // TODO(sergeyu): Split this into two separate interfaces: one for the
73 // client side and one for the host side.
74 class SessionManager : public base::NonThreadSafe { 72 class SessionManager : public base::NonThreadSafe {
75 public: 73 public:
76 SessionManager() {}
77 virtual ~SessionManager() {}
78
79 enum IncomingSessionResponse { 74 enum IncomingSessionResponse {
80 // Accept the session. 75 // Accept the session.
81 ACCEPT, 76 ACCEPT,
82 77
83 // Reject the session because the host is currently disabled due 78 // Reject the session because the host is currently disabled due
84 // to previous login attempts. 79 // to previous login attempts.
85 OVERLOAD, 80 OVERLOAD,
86 81
87 // Reject the session because the client is not allowed to connect 82 // Reject the session because the client is not allowed to connect
88 // to the host. 83 // to the host.
89 DECLINE, 84 DECLINE,
90 }; 85 };
91 86
92 class Listener { 87 // Callback used to accept incoming connections. If the host decides to accept
93 public: 88 // the session it should set the |response| to ACCEPT. Otherwise it should set
94 Listener() {} 89 // it to DECLINE, or INCOMPATIBLE. INCOMPATIBLE indicates that the session has
90 // incompatible configuration, and cannot be accepted. If the callback accepts
91 // the |session| then it must also set configuration for the |session| using
92 // Session::set_config(). The callback must take ownership of the |session| if
93 // it ACCEPTs it.
94 typedef base::Callback<void(Session* session,
95 IncomingSessionResponse* response)>
96 IncomingSessionCallback;
95 97
96 // Called when a new session is received. If the host decides to 98 SessionManager() {}
97 // accept the session it should set the |response| to 99 virtual ~SessionManager() {}
98 // ACCEPT. Otherwise it should set it to DECLINE, or
99 // INCOMPATIBLE. INCOMPATIBLE indicates that the session has
100 // incompatible configuration, and cannot be accepted. If the
101 // callback accepts the |session| then it must also set
102 // configuration for the |session| using Session::set_config().
103 // The callback must take ownership of the |session| if it ACCEPTs it.
104 virtual void OnIncomingSession(Session* session,
105 IncomingSessionResponse* response) = 0;
106 100
107 protected: 101 // Starts accepting incoming connections.
108 ~Listener() {} 102 virtual void AcceptIncoming(
109 }; 103 const IncomingSessionCallback& incoming_session_callback) = 0;
110
111 // Initializes the SessionManager. Caller retains ownership of the
112 // |signal_strategy| and |listener|.
113 virtual void Init(SignalStrategy* signal_strategy,
114 Listener* listener) = 0;
115 104
116 // Sets local protocol configuration to be used when negotiating outgoing and 105 // Sets local protocol configuration to be used when negotiating outgoing and
117 // incoming connections. 106 // incoming connections.
118 virtual void set_protocol_config( 107 virtual void set_protocol_config(
119 scoped_ptr<CandidateSessionConfig> config) = 0; 108 scoped_ptr<CandidateSessionConfig> config) = 0;
120 109
121 // Tries to create a session to the host |jid|. Must be called only 110 // Tries to create a session to the host |jid|.
122 // after initialization has finished successfully, i.e. after
123 // Listener::OnInitialized() has been called.
124 // 111 //
125 // |host_jid| is the full jid of the host to connect to. 112 // |host_jid| is the full jid of the host to connect to.
126 // |authenticator| is a client authenticator for the session. 113 // |authenticator| is a client authenticator for the session.
127 virtual scoped_ptr<Session> Connect( 114 virtual scoped_ptr<Session> Connect(
128 const std::string& host_jid, 115 const std::string& host_jid,
129 scoped_ptr<Authenticator> authenticator) = 0; 116 scoped_ptr<Authenticator> authenticator) = 0;
130 117
131 // Close session manager. Can be called only after all corresponding
132 // sessions are destroyed. No callbacks are called after this method
133 // returns.
134 virtual void Close() = 0;
135
136 // Set authenticator factory that should be used to authenticate 118 // Set authenticator factory that should be used to authenticate
137 // incoming connection. No connections will be accepted if 119 // incoming connection. No connections will be accepted if
138 // authenticator factory isn't set. Must not be called more than 120 // authenticator factory isn't set. Must not be called more than
139 // once per SessionManager because it may not be safe to delete 121 // once per SessionManager because it may not be safe to delete
140 // factory before all authenticators it created are deleted. 122 // factory before all authenticators it created are deleted.
141 virtual void set_authenticator_factory( 123 virtual void set_authenticator_factory(
142 scoped_ptr<AuthenticatorFactory> authenticator_factory) = 0; 124 scoped_ptr<AuthenticatorFactory> authenticator_factory) = 0;
143 125
144 private: 126 private:
145 DISALLOW_COPY_AND_ASSIGN(SessionManager); 127 DISALLOW_COPY_AND_ASSIGN(SessionManager);
146 }; 128 };
147 129
148 } // namespace protocol 130 } // namespace protocol
149 } // namespace remoting 131 } // namespace remoting
150 132
151 #endif // REMOTING_PROTOCOL_SESSION_MANAGER_H_ 133 #endif // REMOTING_PROTOCOL_SESSION_MANAGER_H_
OLDNEW
« no previous file with comments | « remoting/protocol/protocol_mock_objects.h ('k') | remoting/test/protocol_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698