| 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" |
| 20 #include "remoting/host/it2me_desktop_environment.h" | 19 #include "remoting/host/it2me_desktop_environment.h" |
| 21 #include "remoting/host/policy_hack/policy_watcher.h" | 20 #include "remoting/host/policy_hack/policy_watcher.h" |
| 22 #include "remoting/host/register_support_host_request.h" | 21 #include "remoting/host/register_support_host_request.h" |
| 23 #include "remoting/host/session_manager_factory.h" | 22 #include "remoting/host/session_manager_factory.h" |
| 24 #include "remoting/protocol/it2me_host_authenticator_factory.h" | 23 #include "remoting/protocol/it2me_host_authenticator_factory.h" |
| 25 #include "remoting/protocol/network_settings.h" | 24 #include "remoting/protocol/network_settings.h" |
| 26 #include "remoting/signaling/server_log_entry.h" | 25 #include "remoting/signaling/server_log_entry.h" |
| 27 | 26 |
| 28 namespace remoting { | 27 namespace remoting { |
| 29 | 28 |
| 30 namespace { | 29 namespace { |
| 31 | 30 |
| 32 // This is used for tagging system event logs. | 31 // This is used for tagging system event logs. |
| 33 const char kApplicationName[] = "chromoting"; | 32 const char kApplicationName[] = "chromoting"; |
| 34 const int kMaxLoginAttempts = 5; | 33 const int kMaxLoginAttempts = 5; |
| 35 | 34 |
| 36 } // namespace | 35 } // namespace |
| 37 | 36 |
| 38 It2MeHost::It2MeHost( | 37 It2MeHost::It2MeHost( |
| 39 ChromotingHostContext* host_context, | 38 scoped_refptr<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), |
| 46 observer_(observer), | 45 observer_(observer), |
| 47 xmpp_server_config_(xmpp_server_config), | 46 xmpp_server_config_(xmpp_server_config), |
| 48 directory_bot_jid_(directory_bot_jid), | 47 directory_bot_jid_(directory_bot_jid), |
| 49 state_(kDisconnected), | 48 state_(kDisconnected), |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 249 } |
| 251 | 250 |
| 252 void It2MeHost::ShutdownOnUiThread() { | 251 void It2MeHost::ShutdownOnUiThread() { |
| 253 DCHECK(host_context_->ui_task_runner()->BelongsToCurrentThread()); | 252 DCHECK(host_context_->ui_task_runner()->BelongsToCurrentThread()); |
| 254 | 253 |
| 255 // Destroy the DesktopEnvironmentFactory, to free thread references. | 254 // Destroy the DesktopEnvironmentFactory, to free thread references. |
| 256 desktop_environment_factory_.reset(); | 255 desktop_environment_factory_.reset(); |
| 257 | 256 |
| 258 // Stop listening for policy updates. | 257 // Stop listening for policy updates. |
| 259 if (policy_watcher_.get()) { | 258 if (policy_watcher_.get()) { |
| 260 base::WaitableEvent policy_watcher_stopped_(true, false); | 259 policy_watcher_->StopWatching( |
| 261 policy_watcher_->StopWatching(&policy_watcher_stopped_); | 260 base::Bind(&It2MeHost::OnPolicyWatcherShutdown, this)); |
| 262 policy_watcher_stopped_.Wait(); | 261 return; |
| 263 policy_watcher_.reset(); | |
| 264 } | 262 } |
| 265 } | 263 } |
| 266 | 264 |
| 265 void It2MeHost::OnPolicyWatcherShutdown() { |
| 266 policy_watcher_.reset(); |
| 267 } |
| 268 |
| 267 void It2MeHost::OnAccessDenied(const std::string& jid) { | 269 void It2MeHost::OnAccessDenied(const std::string& jid) { |
| 268 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 270 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
| 269 | 271 |
| 270 ++failed_login_attempts_; | 272 ++failed_login_attempts_; |
| 271 if (failed_login_attempts_ == kMaxLoginAttempts) { | 273 if (failed_login_attempts_ == kMaxLoginAttempts) { |
| 272 Disconnect(); | 274 Disconnect(); |
| 273 } | 275 } |
| 274 } | 276 } |
| 275 | 277 |
| 276 void It2MeHost::OnClientAuthenticated(const std::string& jid) { | 278 void It2MeHost::OnClientAuthenticated(const std::string& jid) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 observer_, access_code, lifetime)); | 459 observer_, access_code, lifetime)); |
| 458 | 460 |
| 459 SetState(kReceivedAccessCode); | 461 SetState(kReceivedAccessCode); |
| 460 } | 462 } |
| 461 | 463 |
| 462 It2MeHostFactory::It2MeHostFactory() {} | 464 It2MeHostFactory::It2MeHostFactory() {} |
| 463 | 465 |
| 464 It2MeHostFactory::~It2MeHostFactory() {} | 466 It2MeHostFactory::~It2MeHostFactory() {} |
| 465 | 467 |
| 466 scoped_refptr<It2MeHost> It2MeHostFactory::CreateIt2MeHost( | 468 scoped_refptr<It2MeHost> It2MeHostFactory::CreateIt2MeHost( |
| 467 ChromotingHostContext* context, | 469 scoped_refptr<ChromotingHostContext> context, |
| 468 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 470 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 469 base::WeakPtr<It2MeHost::Observer> observer, | 471 base::WeakPtr<It2MeHost::Observer> observer, |
| 470 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 472 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
| 471 const std::string& directory_bot_jid) { | 473 const std::string& directory_bot_jid) { |
| 472 return new It2MeHost( | 474 return new It2MeHost(context, |
| 473 context, task_runner, observer, xmpp_server_config, directory_bot_jid); | 475 task_runner, |
| 476 observer, |
| 477 xmpp_server_config, |
| 478 directory_bot_jid); |
| 474 } | 479 } |
| 475 | 480 |
| 476 } // namespace remoting | 481 } // namespace remoting |
| OLD | NEW |