Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // |
| 72 // TODO(sergeyu): Split this into two separate interfaces: one for the | 73 // TODO(sergeyu): Split this into two separate interfaces: one for the |
| 73 // client side and one for the host side. | 74 // client side and one for the host side. |
|
Jamie
2015/12/15 00:32:01
Is this TODO still needed?
Sergey Ulanov
2015/12/16 23:17:39
Done.
| |
| 74 class SessionManager : public base::NonThreadSafe { | 75 class SessionManager : public base::NonThreadSafe { |
| 75 public: | 76 public: |
| 76 SessionManager() {} | |
| 77 virtual ~SessionManager() {} | |
| 78 | |
| 79 enum IncomingSessionResponse { | 77 enum IncomingSessionResponse { |
| 80 // Accept the session. | 78 // Accept the session. |
| 81 ACCEPT, | 79 ACCEPT, |
| 82 | 80 |
| 83 // Reject the session because the host is currently disabled due | 81 // Reject the session because the host is currently disabled due |
| 84 // to previous login attempts. | 82 // to previous login attempts. |
| 85 OVERLOAD, | 83 OVERLOAD, |
| 86 | 84 |
| 87 // Reject the session because the client is not allowed to connect | 85 // Reject the session because the client is not allowed to connect |
| 88 // to the host. | 86 // to the host. |
| 89 DECLINE, | 87 DECLINE, |
| 90 }; | 88 }; |
| 91 | 89 |
| 92 class Listener { | 90 // Callback used to accept incoming connections. If the host decides to accept |
| 93 public: | 91 // the session it should set the |response| to ACCEPT. Otherwise it should set |
| 94 Listener() {} | 92 // it to DECLINE, or INCOMPATIBLE. INCOMPATIBLE indicates that the session has |
| 93 // incompatible configuration, and cannot be accepted. If the callback accepts | |
| 94 // the |session| then it must also set configuration for the |session| using | |
| 95 // Session::set_config(). The callback must take ownership of the |session| if | |
| 96 // it ACCEPTs it. | |
| 97 typedef base::Callback<void(Session* session, | |
| 98 IncomingSessionResponse* response)> | |
| 99 IncomingSessionCallback; | |
| 95 | 100 |
| 96 // Called when a new session is received. If the host decides to | 101 SessionManager() {} |
| 97 // accept the session it should set the |response| to | 102 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 | 103 |
| 107 protected: | 104 // Starts accepting incoming connections. |
| 108 ~Listener() {} | 105 virtual void AcceptIncoming( |
| 109 }; | 106 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 | 107 |
| 116 // Sets local protocol configuration to be used when negotiating outgoing and | 108 // Sets local protocol configuration to be used when negotiating outgoing and |
| 117 // incoming connections. | 109 // incoming connections. |
| 118 virtual void set_protocol_config( | 110 virtual void set_protocol_config( |
| 119 scoped_ptr<CandidateSessionConfig> config) = 0; | 111 scoped_ptr<CandidateSessionConfig> config) = 0; |
| 120 | 112 |
| 121 // Tries to create a session to the host |jid|. Must be called only | 113 // 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 // | 114 // |
| 125 // |host_jid| is the full jid of the host to connect to. | 115 // |host_jid| is the full jid of the host to connect to. |
| 126 // |authenticator| is a client authenticator for the session. | 116 // |authenticator| is a client authenticator for the session. |
| 127 virtual scoped_ptr<Session> Connect( | 117 virtual scoped_ptr<Session> Connect( |
| 128 const std::string& host_jid, | 118 const std::string& host_jid, |
| 129 scoped_ptr<Authenticator> authenticator) = 0; | 119 scoped_ptr<Authenticator> authenticator) = 0; |
| 130 | 120 |
| 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 | 121 // Set authenticator factory that should be used to authenticate |
| 137 // incoming connection. No connections will be accepted if | 122 // incoming connection. No connections will be accepted if |
| 138 // authenticator factory isn't set. Must not be called more than | 123 // authenticator factory isn't set. Must not be called more than |
| 139 // once per SessionManager because it may not be safe to delete | 124 // once per SessionManager because it may not be safe to delete |
| 140 // factory before all authenticators it created are deleted. | 125 // factory before all authenticators it created are deleted. |
| 141 virtual void set_authenticator_factory( | 126 virtual void set_authenticator_factory( |
| 142 scoped_ptr<AuthenticatorFactory> authenticator_factory) = 0; | 127 scoped_ptr<AuthenticatorFactory> authenticator_factory) = 0; |
| 143 | 128 |
| 144 private: | 129 private: |
| 145 DISALLOW_COPY_AND_ASSIGN(SessionManager); | 130 DISALLOW_COPY_AND_ASSIGN(SessionManager); |
| 146 }; | 131 }; |
| 147 | 132 |
| 148 } // namespace protocol | 133 } // namespace protocol |
| 149 } // namespace remoting | 134 } // namespace remoting |
| 150 | 135 |
| 151 #endif // REMOTING_PROTOCOL_SESSION_MANAGER_H_ | 136 #endif // REMOTING_PROTOCOL_SESSION_MANAGER_H_ |
| OLD | NEW |