Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "remoting/host/it2me/it2me_host.h" | 5 #include "remoting/host/it2me/it2me_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/synchronization/waitable_event.h" | |
| 10 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
| 11 #include "net/socket/client_socket_factory.h" | 10 #include "net/socket/client_socket_factory.h" |
| 12 #include "remoting/base/auto_thread.h" | 11 #include "remoting/base/auto_thread.h" |
| 13 #include "remoting/base/logging.h" | 12 #include "remoting/base/logging.h" |
| 14 #include "remoting/base/rsa_key_pair.h" | 13 #include "remoting/base/rsa_key_pair.h" |
| 15 #include "remoting/host/chromoting_host.h" | 14 #include "remoting/host/chromoting_host.h" |
| 16 #include "remoting/host/chromoting_host_context.h" | 15 #include "remoting/host/chromoting_host_context.h" |
| 17 #include "remoting/host/host_event_logger.h" | 16 #include "remoting/host/host_event_logger.h" |
| 18 #include "remoting/host/host_secret.h" | 17 #include "remoting/host/host_secret.h" |
| 19 #include "remoting/host/host_status_logger.h" | 18 #include "remoting/host/host_status_logger.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 36 } // namespace | 35 } // namespace |
| 37 | 36 |
| 38 It2MeHost::It2MeHost( | 37 It2MeHost::It2MeHost( |
| 39 ChromotingHostContext* host_context, | 38 ChromotingHostContext* host_context, |
| 40 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 39 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 41 base::WeakPtr<It2MeHost::Observer> observer, | 40 base::WeakPtr<It2MeHost::Observer> observer, |
| 42 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 41 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
| 43 const std::string& directory_bot_jid) | 42 const std::string& directory_bot_jid) |
| 44 : host_context_(host_context), | 43 : host_context_(host_context), |
| 45 task_runner_(task_runner), | 44 task_runner_(task_runner), |
| 45 network_task_runner_(host_context_->network_task_runner()), | |
| 46 observer_(observer), | 46 observer_(observer), |
| 47 xmpp_server_config_(xmpp_server_config), | 47 xmpp_server_config_(xmpp_server_config), |
| 48 directory_bot_jid_(directory_bot_jid), | 48 directory_bot_jid_(directory_bot_jid), |
| 49 state_(kDisconnected), | 49 state_(kDisconnected), |
| 50 failed_login_attempts_(0), | 50 failed_login_attempts_(0), |
| 51 nat_traversal_enabled_(false), | 51 nat_traversal_enabled_(false), |
| 52 policy_received_(false) { | 52 policy_received_(false) { |
| 53 DCHECK(task_runner_->BelongsToCurrentThread()); | 53 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void It2MeHost::Connect() { | 56 void It2MeHost::Connect() { |
| 57 if (!host_context_->ui_task_runner()->BelongsToCurrentThread()) { | 57 if (!host_context_->ui_task_runner()->BelongsToCurrentThread()) { |
| 58 DCHECK(task_runner_->BelongsToCurrentThread()); | 58 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 59 host_context_->ui_task_runner()->PostTask( | 59 host_context_->ui_task_runner()->PostTask( |
| 60 FROM_HERE, base::Bind(&It2MeHost::Connect, this)); | 60 FROM_HERE, base::Bind(&It2MeHost::Connect, this)); |
| 61 return; | 61 return; |
| 62 } | 62 } |
| 63 | 63 |
| 64 desktop_environment_factory_.reset(new It2MeDesktopEnvironmentFactory( | 64 desktop_environment_factory_.reset(new It2MeDesktopEnvironmentFactory( |
| 65 host_context_->network_task_runner(), | 65 network_task_runner_, |
| 66 host_context_->input_task_runner(), | 66 host_context_->input_task_runner(), |
| 67 host_context_->ui_task_runner())); | 67 host_context_->ui_task_runner())); |
| 68 | 68 |
| 69 // Start monitoring configured policies. | 69 // Start monitoring configured policies. |
| 70 policy_watcher_.reset( | 70 policy_watcher_.reset( |
| 71 policy_hack::PolicyWatcher::Create(host_context_->network_task_runner())); | 71 policy_hack::PolicyWatcher::Create(host_context_, network_task_runner_)); |
| 72 policy_watcher_->StartWatching( | 72 policy_watcher_->StartWatching( |
| 73 base::Bind(&It2MeHost::OnPolicyUpdate, this)); | 73 base::Bind(&It2MeHost::OnPolicyUpdate, this)); |
| 74 | 74 |
| 75 // Switch to the network thread to start the actual connection. | 75 // Switch to the network thread to start the actual connection. |
| 76 host_context_->network_task_runner()->PostTask( | 76 network_task_runner_->PostTask( |
| 77 FROM_HERE, base::Bind(&It2MeHost::ReadPolicyAndConnect, this)); | 77 FROM_HERE, base::Bind(&It2MeHost::ReadPolicyAndConnect, this)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void It2MeHost::Disconnect() { | 80 void It2MeHost::Disconnect() { |
| 81 if (!host_context_->network_task_runner()->BelongsToCurrentThread()) { | 81 if (!network_task_runner_->BelongsToCurrentThread()) { |
| 82 DCHECK(task_runner_->BelongsToCurrentThread()); | 82 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 83 host_context_->network_task_runner()->PostTask( | 83 network_task_runner_->PostTask( |
| 84 FROM_HERE, base::Bind(&It2MeHost::Disconnect, this)); | 84 FROM_HERE, base::Bind(&It2MeHost::Disconnect, this)); |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 | 87 |
| 88 switch (state_) { | 88 switch (state_) { |
| 89 case kDisconnected: | 89 case kDisconnected: |
| 90 ShutdownOnNetworkThread(); | 90 ShutdownOnNetworkThread(); |
| 91 return; | 91 return; |
| 92 | 92 |
| 93 case kStarting: | 93 case kStarting: |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 104 | 104 |
| 105 if (!host_) { | 105 if (!host_) { |
| 106 SetState(kDisconnected); | 106 SetState(kDisconnected); |
| 107 ShutdownOnNetworkThread(); | 107 ShutdownOnNetworkThread(); |
| 108 return; | 108 return; |
| 109 } | 109 } |
| 110 | 110 |
| 111 // Deleting the host destroys SignalStrategy synchronously, but | 111 // Deleting the host destroys SignalStrategy synchronously, but |
| 112 // SignalStrategy::Listener handlers are not allowed to destroy | 112 // SignalStrategy::Listener handlers are not allowed to destroy |
| 113 // SignalStrategy, so post task to destroy the host later. | 113 // SignalStrategy, so post task to destroy the host later. |
| 114 host_context_->network_task_runner()->PostTask( | 114 network_task_runner_->PostTask( |
| 115 FROM_HERE, base::Bind(&It2MeHost::ShutdownOnNetworkThread, this)); | 115 FROM_HERE, base::Bind(&It2MeHost::ShutdownOnNetworkThread, this)); |
| 116 return; | 116 return; |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 void It2MeHost::RequestNatPolicy() { | 120 void It2MeHost::RequestNatPolicy() { |
| 121 if (!host_context_->network_task_runner()->BelongsToCurrentThread()) { | 121 if (!network_task_runner_->BelongsToCurrentThread()) { |
| 122 DCHECK(task_runner_->BelongsToCurrentThread()); | 122 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 123 host_context_->network_task_runner()->PostTask( | 123 network_task_runner_->PostTask( |
| 124 FROM_HERE, base::Bind(&It2MeHost::RequestNatPolicy, this)); | 124 FROM_HERE, base::Bind(&It2MeHost::RequestNatPolicy, this)); |
| 125 return; | 125 return; |
| 126 } | 126 } |
| 127 | 127 |
| 128 if (policy_received_) | 128 if (policy_received_) |
| 129 UpdateNatPolicy(nat_traversal_enabled_); | 129 UpdateNatPolicy(nat_traversal_enabled_); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void It2MeHost::ReadPolicyAndConnect() { | 132 void It2MeHost::ReadPolicyAndConnect() { |
| 133 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 133 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 134 | 134 |
| 135 SetState(kStarting); | 135 SetState(kStarting); |
| 136 | 136 |
| 137 // Only proceed to FinishConnect() if at least one policy update has been | 137 // Only proceed to FinishConnect() if at least one policy update has been |
| 138 // received. | 138 // received. |
| 139 if (policy_received_) { | 139 if (policy_received_) { |
| 140 FinishConnect(); | 140 FinishConnect(); |
| 141 } else { | 141 } else { |
| 142 // Otherwise, create the policy watcher, and thunk the connect. | 142 // Otherwise, create the policy watcher, and thunk the connect. |
| 143 pending_connect_ = | 143 pending_connect_ = |
| 144 base::Bind(&It2MeHost::FinishConnect, this); | 144 base::Bind(&It2MeHost::FinishConnect, this); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 void It2MeHost::FinishConnect() { | 148 void It2MeHost::FinishConnect() { |
| 149 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 149 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 150 | 150 |
| 151 if (state_ != kStarting) { | 151 if (state_ != kStarting) { |
| 152 // Host has been stopped while we were fetching policy. | 152 // Host has been stopped while we were fetching policy. |
| 153 return; | 153 return; |
| 154 } | 154 } |
| 155 | 155 |
| 156 // Check the host domain policy. | 156 // Check the host domain policy. |
| 157 if (!required_host_domain_.empty() && | 157 if (!required_host_domain_.empty() && |
| 158 !EndsWith(xmpp_server_config_.username, | 158 !EndsWith(xmpp_server_config_.username, |
| 159 std::string("@") + required_host_domain_, false)) { | 159 std::string("@") + required_host_domain_, false)) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 // Create the host. | 196 // Create the host. |
| 197 host_.reset(new ChromotingHost( | 197 host_.reset(new ChromotingHost( |
| 198 signal_strategy_.get(), | 198 signal_strategy_.get(), |
| 199 desktop_environment_factory_.get(), | 199 desktop_environment_factory_.get(), |
| 200 CreateHostSessionManager(signal_strategy_.get(), network_settings, | 200 CreateHostSessionManager(signal_strategy_.get(), network_settings, |
| 201 host_context_->url_request_context_getter()), | 201 host_context_->url_request_context_getter()), |
| 202 host_context_->audio_task_runner(), | 202 host_context_->audio_task_runner(), |
| 203 host_context_->input_task_runner(), | 203 host_context_->input_task_runner(), |
| 204 host_context_->video_capture_task_runner(), | 204 host_context_->video_capture_task_runner(), |
| 205 host_context_->video_encode_task_runner(), | 205 host_context_->video_encode_task_runner(), |
| 206 host_context_->network_task_runner(), | 206 network_task_runner_, |
| 207 host_context_->ui_task_runner())); | 207 host_context_->ui_task_runner())); |
| 208 host_->AddStatusObserver(this); | 208 host_->AddStatusObserver(this); |
| 209 host_status_logger_.reset( | 209 host_status_logger_.reset( |
| 210 new HostStatusLogger(host_->AsWeakPtr(), ServerLogEntry::IT2ME, | 210 new HostStatusLogger(host_->AsWeakPtr(), ServerLogEntry::IT2ME, |
| 211 signal_strategy_.get(), directory_bot_jid_)); | 211 signal_strategy_.get(), directory_bot_jid_)); |
| 212 | 212 |
| 213 // Disable audio by default. | 213 // Disable audio by default. |
| 214 // TODO(sergeyu): Add UI to enable it. | 214 // TODO(sergeyu): Add UI to enable it. |
| 215 scoped_ptr<protocol::CandidateSessionConfig> protocol_config = | 215 scoped_ptr<protocol::CandidateSessionConfig> protocol_config = |
| 216 protocol::CandidateSessionConfig::CreateDefault(); | 216 protocol::CandidateSessionConfig::CreateDefault(); |
| 217 protocol_config->DisableAudioChannel(); | 217 protocol_config->DisableAudioChannel(); |
| 218 | 218 |
| 219 host_->set_protocol_config(protocol_config.Pass()); | 219 host_->set_protocol_config(protocol_config.Pass()); |
| 220 | 220 |
| 221 // Create event logger. | 221 // Create event logger. |
| 222 host_event_logger_ = | 222 host_event_logger_ = |
| 223 HostEventLogger::Create(host_->AsWeakPtr(), kApplicationName); | 223 HostEventLogger::Create(host_->AsWeakPtr(), kApplicationName); |
| 224 | 224 |
| 225 // Connect signaling and start the host. | 225 // Connect signaling and start the host. |
| 226 signal_strategy_->Connect(); | 226 signal_strategy_->Connect(); |
| 227 host_->Start(xmpp_server_config_.username); | 227 host_->Start(xmpp_server_config_.username); |
| 228 | 228 |
| 229 SetState(kRequestedAccessCode); | 229 SetState(kRequestedAccessCode); |
| 230 return; | 230 return; |
| 231 } | 231 } |
| 232 | 232 |
| 233 void It2MeHost::ShutdownOnNetworkThread() { | 233 void It2MeHost::ShutdownOnNetworkThread() { |
| 234 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 234 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 235 DCHECK(state_ == kDisconnecting || state_ == kDisconnected); | 235 DCHECK(state_ == kDisconnecting || state_ == kDisconnected); |
| 236 | 236 |
| 237 if (state_ == kDisconnecting) { | 237 if (state_ == kDisconnecting) { |
| 238 host_event_logger_.reset(); | 238 host_event_logger_.reset(); |
| 239 host_->RemoveStatusObserver(this); | 239 host_->RemoveStatusObserver(this); |
| 240 host_.reset(); | 240 host_.reset(); |
| 241 | 241 |
| 242 register_request_.reset(); | 242 register_request_.reset(); |
| 243 host_status_logger_.reset(); | 243 host_status_logger_.reset(); |
| 244 signal_strategy_.reset(); | 244 signal_strategy_.reset(); |
| 245 SetState(kDisconnected); | 245 SetState(kDisconnected); |
| 246 } | 246 } |
| 247 | 247 |
| 248 host_context_->ui_task_runner()->PostTask( | 248 task_runner_->PostTask(FROM_HERE, |
|
Jamie
2014/10/14 01:18:42
Why has this changed?
kelvinp
2014/10/15 23:03:10
As per wez, comment, we are trying to take referen
| |
| 249 FROM_HERE, base::Bind(&It2MeHost::ShutdownOnUiThread, this)); | 249 base::Bind(&It2MeHost::ShutdownOnUiThread, this)); |
| 250 } | 250 } |
| 251 | 251 |
| 252 void It2MeHost::ShutdownOnUiThread() { | 252 void It2MeHost::ShutdownOnUiThread() { |
| 253 DCHECK(host_context_->ui_task_runner()->BelongsToCurrentThread()); | 253 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 254 | 254 |
| 255 // Destroy the DesktopEnvironmentFactory, to free thread references. | 255 // Destroy the DesktopEnvironmentFactory, to free thread references. |
| 256 desktop_environment_factory_.reset(); | 256 desktop_environment_factory_.reset(); |
| 257 | 257 |
| 258 // Stop listening for policy updates. | 258 // Stop listening for policy updates. |
| 259 if (policy_watcher_.get()) { | 259 if (policy_watcher_.get()) { |
| 260 base::WaitableEvent policy_watcher_stopped_(true, false); | 260 policy_watcher_->StopWatching( |
| 261 policy_watcher_->StopWatching(&policy_watcher_stopped_); | 261 base::Bind(&It2MeHost::OnPolicyWatcherShutdown, this)); |
| 262 policy_watcher_stopped_.Wait(); | 262 return; |
| 263 policy_watcher_.reset(); | |
| 264 } | 263 } |
| 265 } | 264 } |
| 266 | 265 |
| 266 void It2MeHost::OnPolicyWatcherShutdown() { | |
| 267 policy_watcher_.reset(); | |
| 268 } | |
| 269 | |
| 267 void It2MeHost::OnAccessDenied(const std::string& jid) { | 270 void It2MeHost::OnAccessDenied(const std::string& jid) { |
| 268 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 271 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 269 | 272 |
| 270 ++failed_login_attempts_; | 273 ++failed_login_attempts_; |
| 271 if (failed_login_attempts_ == kMaxLoginAttempts) { | 274 if (failed_login_attempts_ == kMaxLoginAttempts) { |
| 272 Disconnect(); | 275 Disconnect(); |
| 273 } | 276 } |
| 274 } | 277 } |
| 275 | 278 |
| 276 void It2MeHost::OnClientAuthenticated(const std::string& jid) { | 279 void It2MeHost::OnClientAuthenticated(const std::string& jid) { |
| 277 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 280 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 278 | 281 |
| 279 if (state_ == kDisconnecting) { | 282 if (state_ == kDisconnecting) { |
| 280 // Ignore the new connection if we are disconnecting. | 283 // Ignore the new connection if we are disconnecting. |
| 281 return; | 284 return; |
| 282 } | 285 } |
| 283 if (state_ == kConnected) { | 286 if (state_ == kConnected) { |
| 284 // If we already connected another client then one of the connections may be | 287 // If we already connected another client then one of the connections may be |
| 285 // an attacker, so both are suspect and we have to reject the second | 288 // an attacker, so both are suspect and we have to reject the second |
| 286 // connection and shutdown the host. | 289 // connection and shutdown the host. |
| 287 host_->RejectAuthenticatingClient(); | 290 host_->RejectAuthenticatingClient(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 298 | 301 |
| 299 // Pass the client user name to the script object before changing state. | 302 // Pass the client user name to the script object before changing state. |
| 300 task_runner_->PostTask( | 303 task_runner_->PostTask( |
| 301 FROM_HERE, base::Bind(&It2MeHost::Observer::OnClientAuthenticated, | 304 FROM_HERE, base::Bind(&It2MeHost::Observer::OnClientAuthenticated, |
| 302 observer_, client_username)); | 305 observer_, client_username)); |
| 303 | 306 |
| 304 SetState(kConnected); | 307 SetState(kConnected); |
| 305 } | 308 } |
| 306 | 309 |
| 307 void It2MeHost::OnClientDisconnected(const std::string& jid) { | 310 void It2MeHost::OnClientDisconnected(const std::string& jid) { |
| 308 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 311 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 309 | 312 |
| 310 Disconnect(); | 313 Disconnect(); |
| 311 } | 314 } |
| 312 | 315 |
| 313 void It2MeHost::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) { | 316 void It2MeHost::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) { |
| 314 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 317 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 315 | 318 |
| 316 bool nat_policy; | 319 bool nat_policy; |
| 317 if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName, | 320 if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName, |
| 318 &nat_policy)) { | 321 &nat_policy)) { |
| 319 UpdateNatPolicy(nat_policy); | 322 UpdateNatPolicy(nat_policy); |
| 320 } | 323 } |
| 321 std::string host_domain; | 324 std::string host_domain; |
| 322 if (policies->GetString(policy_hack::PolicyWatcher::kHostDomainPolicyName, | 325 if (policies->GetString(policy_hack::PolicyWatcher::kHostDomainPolicyName, |
| 323 &host_domain)) { | 326 &host_domain)) { |
| 324 UpdateHostDomainPolicy(host_domain); | 327 UpdateHostDomainPolicy(host_domain); |
| 325 } | 328 } |
| 326 | 329 |
| 327 policy_received_ = true; | 330 policy_received_ = true; |
| 328 | 331 |
| 329 if (!pending_connect_.is_null()) { | 332 if (!pending_connect_.is_null()) { |
| 330 pending_connect_.Run(); | 333 pending_connect_.Run(); |
| 331 pending_connect_.Reset(); | 334 pending_connect_.Reset(); |
| 332 } | 335 } |
| 333 } | 336 } |
| 334 | 337 |
| 335 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) { | 338 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) { |
| 336 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 339 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 337 | 340 |
| 338 VLOG(2) << "UpdateNatPolicy: " << nat_traversal_enabled; | 341 VLOG(2) << "UpdateNatPolicy: " << nat_traversal_enabled; |
| 339 | 342 |
| 340 // When transitioning from enabled to disabled, force disconnect any | 343 // When transitioning from enabled to disabled, force disconnect any |
| 341 // existing session. | 344 // existing session. |
| 342 if (nat_traversal_enabled_ && !nat_traversal_enabled && IsConnected()) { | 345 if (nat_traversal_enabled_ && !nat_traversal_enabled && IsConnected()) { |
| 343 Disconnect(); | 346 Disconnect(); |
| 344 } | 347 } |
| 345 | 348 |
| 346 nat_traversal_enabled_ = nat_traversal_enabled; | 349 nat_traversal_enabled_ = nat_traversal_enabled; |
| 347 | 350 |
| 348 // Notify the web-app of the policy setting. | 351 // Notify the web-app of the policy setting. |
| 349 task_runner_->PostTask( | 352 task_runner_->PostTask( |
| 350 FROM_HERE, base::Bind(&It2MeHost::Observer::OnNatPolicyChanged, | 353 FROM_HERE, base::Bind(&It2MeHost::Observer::OnNatPolicyChanged, |
| 351 observer_, nat_traversal_enabled_)); | 354 observer_, nat_traversal_enabled_)); |
| 352 } | 355 } |
| 353 | 356 |
| 354 void It2MeHost::UpdateHostDomainPolicy(const std::string& host_domain) { | 357 void It2MeHost::UpdateHostDomainPolicy(const std::string& host_domain) { |
| 355 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 358 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 356 | 359 |
| 357 VLOG(2) << "UpdateHostDomainPolicy: " << host_domain; | 360 VLOG(2) << "UpdateHostDomainPolicy: " << host_domain; |
| 358 | 361 |
| 359 // When setting a host domain policy, force disconnect any existing session. | 362 // When setting a host domain policy, force disconnect any existing session. |
| 360 if (!host_domain.empty() && IsConnected()) { | 363 if (!host_domain.empty() && IsConnected()) { |
| 361 Disconnect(); | 364 Disconnect(); |
| 362 } | 365 } |
| 363 | 366 |
| 364 required_host_domain_ = host_domain; | 367 required_host_domain_ = host_domain; |
| 365 } | 368 } |
| 366 | 369 |
| 367 It2MeHost::~It2MeHost() { | 370 It2MeHost::~It2MeHost() { |
| 368 // Check that resources that need to be torn down on the UI thread are gone. | 371 // Check that resources that need to be torn down on the UI thread are gone. |
| 369 DCHECK(!desktop_environment_factory_.get()); | 372 DCHECK(!desktop_environment_factory_.get()); |
| 370 DCHECK(!policy_watcher_.get()); | 373 DCHECK(!policy_watcher_.get()); |
| 371 } | 374 } |
| 372 | 375 |
| 373 void It2MeHost::SetState(It2MeHostState state) { | 376 void It2MeHost::SetState(It2MeHostState state) { |
| 374 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 377 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 375 | 378 |
| 376 switch (state_) { | 379 switch (state_) { |
| 377 case kDisconnected: | 380 case kDisconnected: |
| 378 DCHECK(state == kStarting || | 381 DCHECK(state == kStarting || |
| 379 state == kError) << state; | 382 state == kError) << state; |
| 380 break; | 383 break; |
| 381 case kStarting: | 384 case kStarting: |
| 382 DCHECK(state == kRequestedAccessCode || | 385 DCHECK(state == kRequestedAccessCode || |
| 383 state == kDisconnecting || | 386 state == kDisconnecting || |
| 384 state == kError || | 387 state == kError || |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 | 423 |
| 421 bool It2MeHost::IsConnected() const { | 424 bool It2MeHost::IsConnected() const { |
| 422 return state_ == kRequestedAccessCode || state_ == kReceivedAccessCode || | 425 return state_ == kRequestedAccessCode || state_ == kReceivedAccessCode || |
| 423 state_ == kConnected; | 426 state_ == kConnected; |
| 424 } | 427 } |
| 425 | 428 |
| 426 void It2MeHost::OnReceivedSupportID( | 429 void It2MeHost::OnReceivedSupportID( |
| 427 bool success, | 430 bool success, |
| 428 const std::string& support_id, | 431 const std::string& support_id, |
| 429 const base::TimeDelta& lifetime) { | 432 const base::TimeDelta& lifetime) { |
| 430 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 433 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 431 | 434 |
| 432 if (!success) { | 435 if (!success) { |
| 433 SetState(kError); | 436 SetState(kError); |
| 434 Disconnect(); | 437 Disconnect(); |
| 435 return; | 438 return; |
| 436 } | 439 } |
| 437 | 440 |
| 438 std::string host_secret = GenerateSupportHostSecret(); | 441 std::string host_secret = GenerateSupportHostSecret(); |
| 439 std::string access_code = support_id + host_secret; | 442 std::string access_code = support_id + host_secret; |
| 440 | 443 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 467 ChromotingHostContext* context, | 470 ChromotingHostContext* context, |
| 468 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 471 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 469 base::WeakPtr<It2MeHost::Observer> observer, | 472 base::WeakPtr<It2MeHost::Observer> observer, |
| 470 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 473 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
| 471 const std::string& directory_bot_jid) { | 474 const std::string& directory_bot_jid) { |
| 472 return new It2MeHost( | 475 return new It2MeHost( |
| 473 context, task_runner, observer, xmpp_server_config, directory_bot_jid); | 476 context, task_runner, observer, xmpp_server_config, directory_bot_jid); |
| 474 } | 477 } |
| 475 | 478 |
| 476 } // namespace remoting | 479 } // namespace remoting |
| OLD | NEW |