| 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 // This file implements a standalone host process for Me2Me. | 5 // This file implements a standalone host process for Me2Me. |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 config_(FilePath()), | 121 config_(FilePath()), |
| 122 #ifdef OFFICIAL_BUILD | 122 #ifdef OFFICIAL_BUILD |
| 123 oauth_use_official_client_id_(true), | 123 oauth_use_official_client_id_(true), |
| 124 #else | 124 #else |
| 125 oauth_use_official_client_id_(false), | 125 oauth_use_official_client_id_(false), |
| 126 #endif | 126 #endif |
| 127 allow_nat_traversal_(true), | 127 allow_nat_traversal_(true), |
| 128 restarting_(false), | 128 restarting_(false), |
| 129 shutting_down_(false), | 129 shutting_down_(false), |
| 130 #if defined(OS_WIN) | 130 #if defined(OS_WIN) |
| 131 desktop_environment_factory_(new SessionDesktopEnvironmentFactory()), | 131 desktop_environment_factory_(new SessionDesktopEnvironmentFactory( |
| 132 context_->input_task_runner(), context_->ui_task_runner())), |
| 132 #else // !defined(OS_WIN) | 133 #else // !defined(OS_WIN) |
| 133 desktop_environment_factory_(new DesktopEnvironmentFactory()), | 134 desktop_environment_factory_(new DesktopEnvironmentFactory( |
| 135 context_->input_task_runner(), context_->ui_task_runner())), |
| 134 #endif // !defined(OS_WIN) | 136 #endif // !defined(OS_WIN) |
| 135 desktop_resizer_(DesktopResizer::Create()), | 137 desktop_resizer_(DesktopResizer::Create()), |
| 136 exit_code_(kSuccessExitCode) | 138 exit_code_(kSuccessExitCode) |
| 137 #if defined(OS_MACOSX) | 139 #if defined(OS_MACOSX) |
| 138 , curtain_(base::Bind(&HostProcess::OnDisconnectRequested, | 140 , curtain_(base::Bind(&HostProcess::OnDisconnectRequested, |
| 139 base::Unretained(this)), | 141 base::Unretained(this)), |
| 140 base::Bind(&HostProcess::OnDisconnectRequested, | 142 base::Bind(&HostProcess::OnDisconnectRequested, |
| 141 base::Unretained(this))) | 143 base::Unretained(this))) |
| 142 #endif | 144 #endif |
| 143 { | 145 { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 306 |
| 305 StartWatchingConfigChanges(); | 307 StartWatchingConfigChanges(); |
| 306 } | 308 } |
| 307 | 309 |
| 308 int get_exit_code() const { return exit_code_; } | 310 int get_exit_code() const { return exit_code_; } |
| 309 | 311 |
| 310 private: | 312 private: |
| 311 void ShutdownHostProcess() { | 313 void ShutdownHostProcess() { |
| 312 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); | 314 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); |
| 313 | 315 |
| 316 // Tear down resources that use ChromotingHostContext threads. |
| 314 config_watcher_.reset(); | 317 config_watcher_.reset(); |
| 315 | |
| 316 daemon_channel_.reset(); | 318 daemon_channel_.reset(); |
| 319 desktop_environment_factory_.reset(); |
| 317 host_user_interface_.reset(); | 320 host_user_interface_.reset(); |
| 318 | 321 |
| 319 if (policy_watcher_.get()) { | 322 if (policy_watcher_.get()) { |
| 320 base::WaitableEvent done_event(true, false); | 323 base::WaitableEvent done_event(true, false); |
| 321 policy_watcher_->StopWatching(&done_event); | 324 policy_watcher_->StopWatching(&done_event); |
| 322 done_event.Wait(); | 325 done_event.Wait(); |
| 323 policy_watcher_.reset(); | 326 policy_watcher_.reset(); |
| 324 } | 327 } |
| 325 | 328 |
| 326 context_.reset(); | 329 context_.reset(); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 NetworkSettings network_settings( | 554 NetworkSettings network_settings( |
| 552 allow_nat_traversal_ ? | 555 allow_nat_traversal_ ? |
| 553 NetworkSettings::NAT_TRAVERSAL_ENABLED : | 556 NetworkSettings::NAT_TRAVERSAL_ENABLED : |
| 554 NetworkSettings::NAT_TRAVERSAL_DISABLED); | 557 NetworkSettings::NAT_TRAVERSAL_DISABLED); |
| 555 if (!allow_nat_traversal_) { | 558 if (!allow_nat_traversal_) { |
| 556 network_settings.min_port = NetworkSettings::kDefaultMinPort; | 559 network_settings.min_port = NetworkSettings::kDefaultMinPort; |
| 557 network_settings.max_port = NetworkSettings::kDefaultMaxPort; | 560 network_settings.max_port = NetworkSettings::kDefaultMaxPort; |
| 558 } | 561 } |
| 559 | 562 |
| 560 host_ = new ChromotingHost( | 563 host_ = new ChromotingHost( |
| 561 context_.get(), signal_strategy_.get(), | 564 signal_strategy_.get(), |
| 562 desktop_environment_factory_.get(), | 565 desktop_environment_factory_.get(), |
| 563 CreateHostSessionManager(network_settings, | 566 CreateHostSessionManager(network_settings, |
| 564 context_->url_request_context_getter())); | 567 context_->url_request_context_getter()), |
| 568 context_->capture_task_runner(), |
| 569 context_->encode_task_runner(), |
| 570 context_->network_task_runner()); |
| 565 | 571 |
| 566 // TODO(simonmorris): Get the maximum session duration from a policy. | 572 // TODO(simonmorris): Get the maximum session duration from a policy. |
| 567 #if defined(OS_LINUX) | 573 #if defined(OS_LINUX) |
| 568 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); | 574 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); |
| 569 #endif | 575 #endif |
| 570 | 576 |
| 571 heartbeat_sender_.reset(new HeartbeatSender( | 577 heartbeat_sender_.reset(new HeartbeatSender( |
| 572 this, host_id_, signal_strategy_.get(), &key_pair_)); | 578 this, host_id_, signal_strategy_.get(), &key_pair_)); |
| 573 | 579 |
| 574 log_to_server_.reset( | 580 log_to_server_.reset( |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 user32.GetFunctionPointer("SetProcessDPIAware")); | 827 user32.GetFunctionPointer("SetProcessDPIAware")); |
| 822 set_process_dpi_aware(); | 828 set_process_dpi_aware(); |
| 823 } | 829 } |
| 824 | 830 |
| 825 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting | 831 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting |
| 826 // the command line from GetCommandLineW(), so we can safely pass NULL here. | 832 // the command line from GetCommandLineW(), so we can safely pass NULL here. |
| 827 return main(0, NULL); | 833 return main(0, NULL); |
| 828 } | 834 } |
| 829 | 835 |
| 830 #endif // defined(OS_WIN) | 836 #endif // defined(OS_WIN) |
| OLD | NEW |