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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 | 69 |
| 70 class Authenticator; | 70 class Authenticator; |
| 71 class AuthenticatorFactory; | 71 class AuthenticatorFactory; |
| 72 | 72 |
| 73 // Generic interface for Chromoting session manager. | 73 // Generic interface for Chromoting session manager. |
| 74 // | 74 // |
| 75 // TODO(sergeyu): Split this into two separate interfaces: one for the | 75 // TODO(sergeyu): Split this into two separate interfaces: one for the |
| 76 // client side and one for the host side. | 76 // client side and one for the host side. |
| 77 class SessionManager : public base::NonThreadSafe { | 77 class SessionManager : public base::NonThreadSafe { |
| 78 public: | 78 public: |
| 79 SessionManager() { } | 79 SessionManager() {} |
| 80 virtual ~SessionManager() { } | 80 virtual ~SessionManager() {} |
| 81 | 81 |
| 82 enum IncomingSessionResponse { | 82 enum IncomingSessionResponse { |
| 83 // Accept the session. | 83 // Accept the session. |
| 84 ACCEPT, | 84 ACCEPT, |
| 85 | 85 |
| 86 // Reject the session due to incompatible session configuration. | 86 // Reject the session due to incompatible session configuration. |
| 87 INCOMPATIBLE, | 87 INCOMPATIBLE, |
| 88 | 88 |
| 89 // Reject the session because the host is currently disabled due | 89 // Reject the session because the host is currently disabled due |
| 90 // to previous login attempts. | 90 // to previous login attempts. |
| 91 OVERLOAD, | 91 OVERLOAD, |
| 92 | 92 |
| 93 // Reject the session because the client is not allowed to connect | 93 // Reject the session because the client is not allowed to connect |
| 94 // to the host. | 94 // to the host. |
| 95 DECLINE, | 95 DECLINE, |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 class Listener { | 98 class Listener { |
| 99 public: | 99 public: |
| 100 Listener() { } | 100 Listener() {} |
| 101 ~Listener() { } | |
| 102 | 101 |
| 103 // Called when the session manager is ready to create outgoing | 102 // Called when the session manager is ready to create outgoing |
| 104 // sessions. May be called from Init() or after Init() | 103 // sessions. May be called from Init() or after Init() |
| 105 // returns. | 104 // returns. |
| 106 virtual void OnSessionManagerReady() = 0; | 105 virtual void OnSessionManagerReady() = 0; |
| 107 | 106 |
| 108 // Called when a new session is received. If the host decides to | 107 // Called when a new session is received. If the host decides to |
| 109 // accept the session it should set the |response| to | 108 // accept the session it should set the |response| to |
| 110 // ACCEPT. Otherwise it should set it to DECLINE, or | 109 // ACCEPT. Otherwise it should set it to DECLINE, or |
| 111 // INCOMPATIBLE. INCOMPATIBLE indicates that the session has | 110 // INCOMPATIBLE. INCOMPATIBLE indicates that the session has |
| 112 // incompatible configuration, and cannot be accepted. If the | 111 // incompatible configuration, and cannot be accepted. If the |
| 113 // callback accepts the |session| then it must also set | 112 // callback accepts the |session| then it must also set |
| 114 // configuration for the |session| using Session::set_config(). | 113 // configuration for the |session| using Session::set_config(). |
| 115 // The callback must take ownership of the |session| if it ACCEPTs it. | 114 // The callback must take ownership of the |session| if it ACCEPTs it. |
| 116 virtual void OnIncomingSession(Session* session, | 115 virtual void OnIncomingSession(Session* session, |
| 117 IncomingSessionResponse* response) = 0; | 116 IncomingSessionResponse* response) = 0; |
| 117 | |
| 118 protected: | |
| 119 ~Listener() {} | |
|
Sergey Ulanov
2012/05/21 19:13:50
add virtual please
| |
| 118 }; | 120 }; |
| 119 | 121 |
| 120 // Initializes the session client. Caller retains ownership of the | 122 // Initializes the session client. Caller retains ownership of the |
| 121 // |signal_strategy| and |listener|. | 123 // |signal_strategy| and |listener|. |
| 122 virtual void Init(SignalStrategy* signal_strategy, | 124 virtual void Init(SignalStrategy* signal_strategy, |
| 123 Listener* listener) = 0; | 125 Listener* listener) = 0; |
| 124 | 126 |
| 125 // Tries to create a session to the host |jid|. Must be called only | 127 // Tries to create a session to the host |jid|. Must be called only |
| 126 // after initialization has finished successfully, i.e. after | 128 // after initialization has finished successfully, i.e. after |
| 127 // Listener::OnInitialized() has been called. | 129 // Listener::OnInitialized() has been called. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 150 scoped_ptr<AuthenticatorFactory> authenticator_factory) = 0; | 152 scoped_ptr<AuthenticatorFactory> authenticator_factory) = 0; |
| 151 | 153 |
| 152 private: | 154 private: |
| 153 DISALLOW_COPY_AND_ASSIGN(SessionManager); | 155 DISALLOW_COPY_AND_ASSIGN(SessionManager); |
| 154 }; | 156 }; |
| 155 | 157 |
| 156 } // namespace protocol | 158 } // namespace protocol |
| 157 } // namespace remoting | 159 } // namespace remoting |
| 158 | 160 |
| 159 #endif // REMOTING_PROTOCOL_SESSION_MANAGER_H_ | 161 #endif // REMOTING_PROTOCOL_SESSION_MANAGER_H_ |
| OLD | NEW |