| 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 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 13 #include "remoting/base/encoder.h" | 13 #include "remoting/base/encoder.h" |
| 14 #include "remoting/host/access_verifier.h" | |
| 15 #include "remoting/host/capturer.h" | 14 #include "remoting/host/capturer.h" |
| 16 #include "remoting/host/client_session.h" | 15 #include "remoting/host/client_session.h" |
| 17 #include "remoting/host/desktop_environment.h" | 16 #include "remoting/host/desktop_environment.h" |
| 18 #include "remoting/host/host_status_observer.h" | 17 #include "remoting/host/host_status_observer.h" |
| 19 #include "remoting/host/ui_strings.h" | 18 #include "remoting/host/ui_strings.h" |
| 20 #include "remoting/jingle_glue/jingle_thread.h" | 19 #include "remoting/jingle_glue/jingle_thread.h" |
| 21 #include "remoting/jingle_glue/signal_strategy.h" | 20 #include "remoting/jingle_glue/signal_strategy.h" |
| 22 #include "remoting/protocol/session_manager.h" | 21 #include "remoting/protocol/session_manager.h" |
| 23 #include "remoting/protocol/connection_to_client.h" | 22 #include "remoting/protocol/connection_to_client.h" |
| 24 | 23 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // and try to terminate the threads we have created. This will allow | 58 // and try to terminate the threads we have created. This will allow |
| 60 // all pending tasks to complete. After all of that completed we | 59 // 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 | 60 // return to the idle state. We then go to step (2) if there a new |
| 62 // incoming connection. | 61 // incoming connection. |
| 63 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, | 62 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| 64 public ClientSession::EventHandler, | 63 public ClientSession::EventHandler, |
| 65 public SignalStrategy::StatusObserver, | 64 public SignalStrategy::StatusObserver, |
| 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 // Factory methods that must be used to create ChromotingHost |
| 69 // instances. Returned instance takes ownership of | 68 // instances. It does NOT take ownership of |context|, and |
| 70 // |access_verifier|. It does NOT take ownership of |context|, | 69 // |environment|, but they should not be deleted until returned host |
| 71 // and |environment|, but they should not be deleted until | 70 // is destroyed. |
| 72 // returned host is destroyed. | |
| 73 static ChromotingHost* Create(ChromotingHostContext* context, | 71 static ChromotingHost* Create(ChromotingHostContext* context, |
| 74 MutableHostConfig* config, | 72 MutableHostConfig* config, |
| 75 DesktopEnvironment* environment, | 73 DesktopEnvironment* environment, |
| 76 AccessVerifier* access_verifier, | |
| 77 bool allow_nat_traversal); | 74 bool allow_nat_traversal); |
| 78 | 75 |
| 79 // Asynchronously start the host process. | 76 // Asynchronously start the host process. |
| 80 // | 77 // |
| 81 // After this is invoked, the host process will connect to the talk | 78 // After this is invoked, the host process will connect to the talk |
| 82 // network and start listening for incoming connections. | 79 // network and start listening for incoming connections. |
| 83 // | 80 // |
| 84 // This method can only be called once during the lifetime of this object. | 81 // This method can only be called once during the lifetime of this object. |
| 85 void Start(); | 82 void Start(); |
| 86 | 83 |
| 87 // Asynchronously shutdown the host process. |shutdown_task| is | 84 // Asynchronously shutdown the host process. |shutdown_task| is |
| 88 // called after shutdown is completed. | 85 // called after shutdown is completed. |
| 89 void Shutdown(const base::Closure& shutdown_task); | 86 void Shutdown(const base::Closure& shutdown_task); |
| 90 | 87 |
| 91 // Adds |observer| to the list of status observers. Doesn't take | 88 // Adds |observer| to the list of status observers. Doesn't take |
| 92 // ownership of |observer|, so |observer| must outlive this | 89 // ownership of |observer|, so |observer| must outlive this |
| 93 // object. All status observers must be added before the host is | 90 // object. All status observers must be added before the host is |
| 94 // started. | 91 // started. |
| 95 void AddStatusObserver(HostStatusObserver* observer); | 92 void AddStatusObserver(HostStatusObserver* observer); |
| 96 | 93 |
| 97 //////////////////////////////////////////////////////////////////////////// | 94 //////////////////////////////////////////////////////////////////////////// |
| 98 // SignalStrategy::StatusObserver implementation. | 95 // SignalStrategy::StatusObserver implementation. |
| 99 virtual void OnStateChange( | 96 virtual void OnStateChange( |
| 100 SignalStrategy::StatusObserver::State state) OVERRIDE; | 97 SignalStrategy::StatusObserver::State state) OVERRIDE; |
| 101 virtual void OnJidChange(const std::string& full_jid) OVERRIDE; | 98 virtual void OnJidChange(const std::string& full_jid) OVERRIDE; |
| 102 | 99 |
| 103 //////////////////////////////////////////////////////////////////////////// | 100 //////////////////////////////////////////////////////////////////////////// |
| 104 // ClientSession::EventHandler implementation. | 101 // ClientSession::EventHandler implementation. |
| 105 virtual void OnSessionAuthenticated(ClientSession* client) OVERRIDE; | 102 virtual void OnSessionAuthenticated(ClientSession* client) OVERRIDE; |
| 103 virtual void OnSessionAuthenticationFailed(ClientSession* client) OVERRIDE; |
| 106 virtual void OnSessionClosed(ClientSession* session) OVERRIDE; | 104 virtual void OnSessionClosed(ClientSession* session) OVERRIDE; |
| 107 virtual void OnSessionSequenceNumber(ClientSession* session, | 105 virtual void OnSessionSequenceNumber(ClientSession* session, |
| 108 int64 sequence_number) OVERRIDE; | 106 int64 sequence_number) OVERRIDE; |
| 109 | 107 |
| 110 // SessionManager::Listener implementation. | 108 // SessionManager::Listener implementation. |
| 111 virtual void OnSessionManagerInitialized() OVERRIDE; | 109 virtual void OnSessionManagerInitialized() OVERRIDE; |
| 112 virtual void OnIncomingSession( | 110 virtual void OnIncomingSession( |
| 113 protocol::Session* session, | 111 protocol::Session* session, |
| 114 protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE; | 112 protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE; |
| 115 | 113 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 145 typedef std::vector<HostStatusObserver*> StatusObserverList; | 143 typedef std::vector<HostStatusObserver*> StatusObserverList; |
| 146 typedef std::vector<ClientSession*> ClientList; | 144 typedef std::vector<ClientSession*> ClientList; |
| 147 | 145 |
| 148 enum State { | 146 enum State { |
| 149 kInitial, | 147 kInitial, |
| 150 kStarted, | 148 kStarted, |
| 151 kStopping, | 149 kStopping, |
| 152 kStopped, | 150 kStopped, |
| 153 }; | 151 }; |
| 154 | 152 |
| 155 // Takes ownership of |access_verifier|, and adds a reference to | 153 // Caller keeps ownership of |context| and |environment|. |
| 156 // |config|. Caller keeps ownership of |context| and |environment|. | |
| 157 ChromotingHost(ChromotingHostContext* context, | 154 ChromotingHost(ChromotingHostContext* context, |
| 158 MutableHostConfig* config, | 155 MutableHostConfig* config, |
| 159 DesktopEnvironment* environment, | 156 DesktopEnvironment* environment, |
| 160 AccessVerifier* access_verifier, | |
| 161 bool allow_nat_traversal); | 157 bool allow_nat_traversal); |
| 162 virtual ~ChromotingHost(); | 158 virtual ~ChromotingHost(); |
| 163 | 159 |
| 164 // Creates encoder for the specified configuration. | 160 // Creates encoder for the specified configuration. |
| 165 Encoder* CreateEncoder(const protocol::SessionConfig& config); | 161 Encoder* CreateEncoder(const protocol::SessionConfig& config); |
| 166 | 162 |
| 167 std::string GenerateHostAuthToken(const std::string& encoded_client_token); | 163 std::string GenerateHostAuthToken(const std::string& encoded_client_token); |
| 168 | 164 |
| 169 void AddAuthenticatedClient(ClientSession* client, | 165 void AddAuthenticatedClient(ClientSession* client, |
| 170 const protocol::SessionConfig& config, | 166 const protocol::SessionConfig& config, |
| 171 const std::string& jid); | 167 const std::string& jid); |
| 172 | 168 |
| 173 int AuthenticatedClientsCount() const; | 169 int AuthenticatedClientsCount() const; |
| 174 | 170 |
| 175 void EnableCurtainMode(bool enable); | 171 void EnableCurtainMode(bool enable); |
| 176 | 172 |
| 177 void StopScreenRecorder(); | 173 void StopScreenRecorder(); |
| 178 void OnScreenRecorderStopped(); | 174 void OnScreenRecorderStopped(); |
| 179 | 175 |
| 180 // Called from Shutdown() or OnScreenRecorderStopped() to finish shutdown. | 176 // Called from Shutdown() or OnScreenRecorderStopped() to finish shutdown. |
| 181 void ShutdownFinish(); | 177 void ShutdownFinish(); |
| 182 | 178 |
| 183 // Unless specified otherwise all members of this class must be | 179 // Unless specified otherwise all members of this class must be |
| 184 // used on the network thread only. | 180 // used on the network thread only. |
| 185 | 181 |
| 186 // Parameters specified when the host was created. | 182 // Parameters specified when the host was created. |
| 187 ChromotingHostContext* context_; | 183 ChromotingHostContext* context_; |
| 188 DesktopEnvironment* desktop_environment_; | 184 DesktopEnvironment* desktop_environment_; |
| 189 scoped_refptr<MutableHostConfig> config_; | 185 scoped_refptr<MutableHostConfig> config_; |
| 190 scoped_ptr<AccessVerifier> access_verifier_; | |
| 191 bool allow_nat_traversal_; | 186 bool allow_nat_traversal_; |
| 192 | 187 |
| 193 // Connection objects. | 188 // Connection objects. |
| 194 scoped_ptr<SignalStrategy> signal_strategy_; | 189 scoped_ptr<SignalStrategy> signal_strategy_; |
| 195 std::string local_jid_; | 190 std::string local_jid_; |
| 196 scoped_ptr<protocol::SessionManager> session_manager_; | 191 scoped_ptr<protocol::SessionManager> session_manager_; |
| 197 | 192 |
| 198 // StatusObserverList is thread-safe and can be used on any thread. | 193 // StatusObserverList is thread-safe and can be used on any thread. |
| 199 StatusObserverList status_observers_; | 194 StatusObserverList status_observers_; |
| 200 | 195 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 226 bool is_it2me_; | 221 bool is_it2me_; |
| 227 std::string access_code_; | 222 std::string access_code_; |
| 228 UiStrings ui_strings_; | 223 UiStrings ui_strings_; |
| 229 | 224 |
| 230 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 225 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
| 231 }; | 226 }; |
| 232 | 227 |
| 233 } // namespace remoting | 228 } // namespace remoting |
| 234 | 229 |
| 235 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 230 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
| OLD | NEW |