| OLD | NEW |
| 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 #ifndef REMOTING_HOST_CHROMOTING_HOST_H_ | 5 #ifndef REMOTING_HOST_CHROMOTING_HOST_H_ |
| 6 #define REMOTING_HOST_CHROMOTING_HOST_H_ | 6 #define REMOTING_HOST_CHROMOTING_HOST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // After we have done all the initialization we'll start the ScreenRecorder. | 55 // After we have done all the initialization we'll start the ScreenRecorder. |
| 56 // We'll then enter the running state of the host process. | 56 // We'll then enter the running state of the host process. |
| 57 // | 57 // |
| 58 // 3. When the user is disconnected, we will pause the ScreenRecorder | 58 // 3. When the user is disconnected, we will pause the ScreenRecorder |
| 59 // and try to terminate the threads we have created. This will allow | 59 // and try to terminate the threads we have created. This will allow |
| 60 // all pending tasks to complete. After all of that completed we | 60 // all pending tasks to complete. After all of that completed we |
| 61 // return to the idle state. We then go to step (2) if there a new | 61 // return to the idle state. We then go to step (2) if there a new |
| 62 // incoming connection. | 62 // incoming connection. |
| 63 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, | 63 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| 64 public ClientSession::EventHandler, | 64 public ClientSession::EventHandler, |
| 65 public SignalStrategy::Listener, | |
| 66 public protocol::SessionManager::Listener { | 65 public protocol::SessionManager::Listener { |
| 67 public: | 66 public: |
| 68 // Factory methods that must be used to create ChromotingHost | 67 // The caller must ensure that |context|, |signal_strategy| and |
| 69 // instances. It does NOT take ownership of |context|, and | 68 // |environment| out-live the host. |
| 70 // |environment|, but they should not be deleted until returned host | 69 ChromotingHost(ChromotingHostContext* context, |
| 71 // is destroyed. | 70 MutableHostConfig* config, |
| 72 static ChromotingHost* Create(ChromotingHostContext* context, | 71 SignalStrategy* signal_strategy, |
| 73 MutableHostConfig* config, | 72 DesktopEnvironment* environment, |
| 74 DesktopEnvironment* environment, | 73 bool allow_nat_traversal); |
| 75 bool allow_nat_traversal); | |
| 76 | 74 |
| 77 // Asynchronously start the host process. | 75 // Asynchronously start the host process. |
| 78 // | 76 // |
| 79 // After this is invoked, the host process will connect to the talk | 77 // After this is invoked, the host process will connect to the talk |
| 80 // network and start listening for incoming connections. | 78 // network and start listening for incoming connections. |
| 81 // | 79 // |
| 82 // This method can only be called once during the lifetime of this object. | 80 // This method can only be called once during the lifetime of this object. |
| 83 void Start(); | 81 void Start(); |
| 84 | 82 |
| 85 // Asynchronously shutdown the host process. |shutdown_task| is | 83 // Asynchronously shutdown the host process. |shutdown_task| is |
| 86 // called after shutdown is completed. | 84 // called after shutdown is completed. |
| 87 void Shutdown(const base::Closure& shutdown_task); | 85 void Shutdown(const base::Closure& shutdown_task); |
| 88 | 86 |
| 89 // Adds |observer| to the list of status observers. Doesn't take | 87 // Adds |observer| to the list of status observers. Doesn't take |
| 90 // ownership of |observer|, so |observer| must outlive this | 88 // ownership of |observer|, so |observer| must outlive this |
| 91 // object. All status observers must be added before the host is | 89 // object. All status observers must be added before the host is |
| 92 // started. | 90 // started. |
| 93 void AddStatusObserver(HostStatusObserver* observer); | 91 void AddStatusObserver(HostStatusObserver* observer); |
| 94 | 92 |
| 95 // Sets shared secret for the host. All incoming connections are | 93 // Sets shared secret for the host. All incoming connections are |
| 96 // rejected if shared secret isn't set. Must be called on the | 94 // rejected if shared secret isn't set. Must be called on the |
| 97 // network thread after the host is started. | 95 // network thread after the host is started. |
| 98 void SetSharedSecret(const std::string& shared_secret); | 96 void SetSharedSecret(const std::string& shared_secret); |
| 99 | 97 |
| 100 //////////////////////////////////////////////////////////////////////////// | 98 //////////////////////////////////////////////////////////////////////////// |
| 101 // SignalStrategy::Listener interface. | |
| 102 virtual void OnSignalStrategyStateChange( | |
| 103 SignalStrategy::State state) OVERRIDE; | |
| 104 | |
| 105 //////////////////////////////////////////////////////////////////////////// | |
| 106 // ClientSession::EventHandler implementation. | 99 // ClientSession::EventHandler implementation. |
| 107 virtual void OnSessionAuthenticated(ClientSession* client) OVERRIDE; | 100 virtual void OnSessionAuthenticated(ClientSession* client) OVERRIDE; |
| 108 virtual void OnSessionAuthenticationFailed(ClientSession* client) OVERRIDE; | 101 virtual void OnSessionAuthenticationFailed(ClientSession* client) OVERRIDE; |
| 109 virtual void OnSessionClosed(ClientSession* session) OVERRIDE; | 102 virtual void OnSessionClosed(ClientSession* session) OVERRIDE; |
| 110 virtual void OnSessionSequenceNumber(ClientSession* session, | 103 virtual void OnSessionSequenceNumber(ClientSession* session, |
| 111 int64 sequence_number) OVERRIDE; | 104 int64 sequence_number) OVERRIDE; |
| 112 | 105 |
| 113 // SessionManager::Listener implementation. | 106 // SessionManager::Listener implementation. |
| 114 virtual void OnSessionManagerReady() OVERRIDE; | 107 virtual void OnSessionManagerReady() OVERRIDE; |
| 115 virtual void OnIncomingSession( | 108 virtual void OnIncomingSession( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 145 typedef std::vector<HostStatusObserver*> StatusObserverList; | 138 typedef std::vector<HostStatusObserver*> StatusObserverList; |
| 146 typedef std::vector<ClientSession*> ClientList; | 139 typedef std::vector<ClientSession*> ClientList; |
| 147 | 140 |
| 148 enum State { | 141 enum State { |
| 149 kInitial, | 142 kInitial, |
| 150 kStarted, | 143 kStarted, |
| 151 kStopping, | 144 kStopping, |
| 152 kStopped, | 145 kStopped, |
| 153 }; | 146 }; |
| 154 | 147 |
| 155 // Caller keeps ownership of |context| and |environment|. | |
| 156 ChromotingHost(ChromotingHostContext* context, | |
| 157 MutableHostConfig* config, | |
| 158 DesktopEnvironment* environment, | |
| 159 bool allow_nat_traversal); | |
| 160 virtual ~ChromotingHost(); | 148 virtual ~ChromotingHost(); |
| 161 | 149 |
| 162 // Creates encoder for the specified configuration. | 150 // Creates encoder for the specified configuration. |
| 163 Encoder* CreateEncoder(const protocol::SessionConfig& config); | 151 Encoder* CreateEncoder(const protocol::SessionConfig& config); |
| 164 | 152 |
| 165 std::string GenerateHostAuthToken(const std::string& encoded_client_token); | 153 std::string GenerateHostAuthToken(const std::string& encoded_client_token); |
| 166 | 154 |
| 167 void AddAuthenticatedClient(ClientSession* client, | 155 void AddAuthenticatedClient(ClientSession* client, |
| 168 const protocol::SessionConfig& config, | 156 const protocol::SessionConfig& config, |
| 169 const std::string& jid); | 157 const std::string& jid); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 189 // TODO(lambroslambrou): The following is a temporary fix for Me2Me | 177 // TODO(lambroslambrou): The following is a temporary fix for Me2Me |
| 190 // (crbug.com/105995), pending the AuthenticatorFactory work. | 178 // (crbug.com/105995), pending the AuthenticatorFactory work. |
| 191 // Cache the shared secret, in case SetSharedSecret() is called before the | 179 // Cache the shared secret, in case SetSharedSecret() is called before the |
| 192 // session manager has been created. | 180 // session manager has been created. |
| 193 // The |have_shared_secret_| flag is to distinguish SetSharedSecret() not | 181 // The |have_shared_secret_| flag is to distinguish SetSharedSecret() not |
| 194 // being called at all, from being called with an empty string. | 182 // being called at all, from being called with an empty string. |
| 195 std::string shared_secret_; | 183 std::string shared_secret_; |
| 196 bool have_shared_secret_; | 184 bool have_shared_secret_; |
| 197 | 185 |
| 198 // Connection objects. | 186 // Connection objects. |
| 199 scoped_ptr<SignalStrategy> signal_strategy_; | 187 SignalStrategy* signal_strategy_; |
| 200 std::string local_jid_; | |
| 201 scoped_ptr<protocol::SessionManager> session_manager_; | 188 scoped_ptr<protocol::SessionManager> session_manager_; |
| 202 | 189 |
| 203 // StatusObserverList is thread-safe and can be used on any thread. | 190 // StatusObserverList is thread-safe and can be used on any thread. |
| 204 StatusObserverList status_observers_; | 191 StatusObserverList status_observers_; |
| 205 | 192 |
| 206 // The connections to remote clients. | 193 // The connections to remote clients. |
| 207 ClientList clients_; | 194 ClientList clients_; |
| 208 | 195 |
| 209 // Session manager for the host process. | 196 // Session manager for the host process. |
| 210 scoped_refptr<ScreenRecorder> recorder_; | 197 scoped_refptr<ScreenRecorder> recorder_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 230 bool is_it2me_; | 217 bool is_it2me_; |
| 231 std::string access_code_; | 218 std::string access_code_; |
| 232 UiStrings ui_strings_; | 219 UiStrings ui_strings_; |
| 233 | 220 |
| 234 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 221 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
| 235 }; | 222 }; |
| 236 | 223 |
| 237 } // namespace remoting | 224 } // namespace remoting |
| 238 | 225 |
| 239 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 226 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
| OLD | NEW |