| 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 23 matching lines...) Expand all Loading... |
| 34 #include "remoting/base/constants.h" | 34 #include "remoting/base/constants.h" |
| 35 #include "remoting/host/branding.h" | 35 #include "remoting/host/branding.h" |
| 36 #include "remoting/host/chromoting_host.h" | 36 #include "remoting/host/chromoting_host.h" |
| 37 #include "remoting/host/chromoting_host_context.h" | 37 #include "remoting/host/chromoting_host_context.h" |
| 38 #include "remoting/host/chromoting_messages.h" | 38 #include "remoting/host/chromoting_messages.h" |
| 39 #include "remoting/host/config_file_watcher.h" | 39 #include "remoting/host/config_file_watcher.h" |
| 40 #include "remoting/host/curtain_mode.h" | 40 #include "remoting/host/curtain_mode.h" |
| 41 #include "remoting/host/curtaining_host_observer.h" | 41 #include "remoting/host/curtaining_host_observer.h" |
| 42 #include "remoting/host/desktop_environment_factory.h" | 42 #include "remoting/host/desktop_environment_factory.h" |
| 43 #include "remoting/host/desktop_resizer.h" | 43 #include "remoting/host/desktop_resizer.h" |
| 44 #include "remoting/host/desktop_session_connector.h" |
| 44 #include "remoting/host/dns_blackhole_checker.h" | 45 #include "remoting/host/dns_blackhole_checker.h" |
| 45 #include "remoting/host/event_executor.h" | 46 #include "remoting/host/event_executor.h" |
| 46 #include "remoting/host/heartbeat_sender.h" | 47 #include "remoting/host/heartbeat_sender.h" |
| 47 #include "remoting/host/host_config.h" | 48 #include "remoting/host/host_config.h" |
| 48 #include "remoting/host/host_event_logger.h" | 49 #include "remoting/host/host_event_logger.h" |
| 49 #include "remoting/host/host_exit_codes.h" | 50 #include "remoting/host/host_exit_codes.h" |
| 50 #include "remoting/host/host_user_interface.h" | 51 #include "remoting/host/host_user_interface.h" |
| 51 #include "remoting/host/ipc_consts.h" | 52 #include "remoting/host/ipc_consts.h" |
| 53 #include "remoting/host/ipc_desktop_environment_factory.h" |
| 52 #include "remoting/host/json_host_config.h" | 54 #include "remoting/host/json_host_config.h" |
| 53 #include "remoting/host/logging.h" | 55 #include "remoting/host/logging.h" |
| 54 #include "remoting/host/log_to_server.h" | 56 #include "remoting/host/log_to_server.h" |
| 55 #include "remoting/host/network_settings.h" | 57 #include "remoting/host/network_settings.h" |
| 56 #include "remoting/host/policy_hack/policy_watcher.h" | 58 #include "remoting/host/policy_hack/policy_watcher.h" |
| 57 #include "remoting/host/resizing_host_observer.h" | 59 #include "remoting/host/resizing_host_observer.h" |
| 58 #include "remoting/host/session_manager_factory.h" | 60 #include "remoting/host/session_manager_factory.h" |
| 59 #include "remoting/host/signaling_connector.h" | 61 #include "remoting/host/signaling_connector.h" |
| 60 #include "remoting/host/usage_stats_consent.h" | 62 #include "remoting/host/usage_stats_consent.h" |
| 61 #include "remoting/host/video_frame_capturer.h" | 63 #include "remoting/host/video_frame_capturer.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 108 |
| 107 void QuitMessageLoop(MessageLoop* message_loop) { | 109 void QuitMessageLoop(MessageLoop* message_loop) { |
| 108 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 110 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 109 } | 111 } |
| 110 | 112 |
| 111 } // namespace | 113 } // namespace |
| 112 | 114 |
| 113 namespace remoting { | 115 namespace remoting { |
| 114 | 116 |
| 115 class HostProcess | 117 class HostProcess |
| 116 : public HeartbeatSender::Listener, | 118 : public ConfigFileWatcher::Delegate, |
| 117 public IPC::Listener, | 119 public HeartbeatSender::Listener, |
| 118 public ConfigFileWatcher::Delegate { | 120 public IPC::Listener { |
| 119 public: | 121 public: |
| 120 explicit HostProcess(scoped_ptr<ChromotingHostContext> context) | 122 explicit HostProcess(scoped_ptr<ChromotingHostContext> context) |
| 121 : context_(context.Pass()), | 123 : context_(context.Pass()), |
| 122 allow_nat_traversal_(true), | 124 allow_nat_traversal_(true), |
| 123 restarting_(false), | 125 restarting_(false), |
| 124 shutting_down_(false), | 126 shutting_down_(false), |
| 125 #if defined(OS_WIN) | |
| 126 desktop_environment_factory_(new SessionDesktopEnvironmentFactory( | |
| 127 context_->input_task_runner(), context_->ui_task_runner())), | |
| 128 #else // !defined(OS_WIN) | |
| 129 desktop_environment_factory_(new DesktopEnvironmentFactory( | |
| 130 context_->input_task_runner(), context_->ui_task_runner())), | |
| 131 #endif // !defined(OS_WIN) | |
| 132 desktop_resizer_(DesktopResizer::Create()), | 127 desktop_resizer_(DesktopResizer::Create()), |
| 128 #if defined(REMOTING_MULTI_PROCESS) |
| 129 desktop_session_connector_(NULL), |
| 130 #endif // defined(REMOTING_MULTI_PROCESS) |
| 133 exit_code_(kSuccessExitCode) { | 131 exit_code_(kSuccessExitCode) { |
| 134 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 132 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
| 135 curtain_ = CurtainMode::Create( | 133 curtain_ = CurtainMode::Create( |
| 136 base::Bind(&HostProcess::OnDisconnectRequested, | 134 base::Bind(&HostProcess::OnDisconnectRequested, |
| 137 base::Unretained(this)), | 135 base::Unretained(this)), |
| 138 base::Bind(&HostProcess::RejectAuthenticatingClient, | 136 base::Bind(&HostProcess::RejectAuthenticatingClient, |
| 139 base::Unretained(this))); | 137 base::Unretained(this))); |
| 140 } | 138 } |
| 141 | 139 |
| 142 #if defined(REMOTING_MULTI_PROCESS) | 140 #if defined(REMOTING_MULTI_PROCESS) |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 291 |
| 294 // IPC::Listener implementation. | 292 // IPC::Listener implementation. |
| 295 virtual bool OnMessageReceived(const IPC::Message& message) { | 293 virtual bool OnMessageReceived(const IPC::Message& message) { |
| 296 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); | 294 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); |
| 297 | 295 |
| 298 #if defined(REMOTING_MULTI_PROCESS) | 296 #if defined(REMOTING_MULTI_PROCESS) |
| 299 bool handled = true; | 297 bool handled = true; |
| 300 IPC_BEGIN_MESSAGE_MAP(HostProcess, message) | 298 IPC_BEGIN_MESSAGE_MAP(HostProcess, message) |
| 301 IPC_MESSAGE_HANDLER(ChromotingDaemonNetworkMsg_Configuration, | 299 IPC_MESSAGE_HANDLER(ChromotingDaemonNetworkMsg_Configuration, |
| 302 OnConfigUpdated) | 300 OnConfigUpdated) |
| 301 IPC_MESSAGE_FORWARD(ChromotingDaemonNetworkMsg_TerminalDisconnected, |
| 302 desktop_session_connector_, |
| 303 DesktopSessionConnector::OnTerminalDisconnected) |
| 303 IPC_MESSAGE_UNHANDLED(handled = false) | 304 IPC_MESSAGE_UNHANDLED(handled = false) |
| 304 IPC_END_MESSAGE_MAP() | 305 IPC_END_MESSAGE_MAP() |
| 305 return handled; | 306 return handled; |
| 306 #else // !defined(REMOTING_MULTI_PROCESS) | 307 #else // !defined(REMOTING_MULTI_PROCESS) |
| 307 return false; | 308 return false; |
| 308 #endif // !defined(REMOTING_MULTI_PROCESS) | 309 #endif // !defined(REMOTING_MULTI_PROCESS) |
| 309 } | 310 } |
| 310 | 311 |
| 311 void StartHostProcess() { | 312 void StartHostProcess() { |
| 312 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); | 313 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); |
| 313 | 314 |
| 314 if (!InitWithCommandLine(CommandLine::ForCurrentProcess())) { | 315 if (!InitWithCommandLine(CommandLine::ForCurrentProcess())) { |
| 315 OnConfigWatcherError(); | 316 OnConfigWatcherError(); |
| 316 return; | 317 return; |
| 317 } | 318 } |
| 318 | 319 |
| 320 // Create a desktop environment factory appropriate to the build type & |
| 321 // platform. |
| 322 #if defined(OS_WIN) |
| 323 |
| 324 #if defined(REMOTING_MULTI_PROCESS) |
| 325 IpcDesktopEnvironmentFactory* desktop_environment_factory = |
| 326 new IpcDesktopEnvironmentFactory( |
| 327 daemon_channel_.get(), |
| 328 context_->input_task_runner(), |
| 329 context_->network_task_runner(), |
| 330 context_->ui_task_runner()); |
| 331 desktop_session_connector_ = desktop_environment_factory; |
| 332 #else // !defined(REMOTING_MULTI_PROCESS) |
| 333 DesktopEnvironmentFactory* desktop_environment_factory = |
| 334 new SessionDesktopEnvironmentFactory( |
| 335 context_->input_task_runner(), context_->ui_task_runner()); |
| 336 #endif // !defined(REMOTING_MULTI_PROCESS) |
| 337 |
| 338 #else // !defined(OS_WIN) |
| 339 DesktopEnvironmentFactory* desktop_environment_factory = |
| 340 new DesktopEnvironmentFactory( |
| 341 context_->input_task_runner(), context_->ui_task_runner()); |
| 342 #endif // !defined(OS_WIN) |
| 343 |
| 344 desktop_environment_factory_.reset(desktop_environment_factory); |
| 345 |
| 319 context_->network_task_runner()->PostTask( | 346 context_->network_task_runner()->PostTask( |
| 320 FROM_HERE, | 347 FROM_HERE, |
| 321 base::Bind(&HostProcess::ListenForShutdownSignal, | 348 base::Bind(&HostProcess::ListenForShutdownSignal, |
| 322 base::Unretained(this))); | 349 base::Unretained(this))); |
| 323 | 350 |
| 324 // The host UI should be created on the UI thread. | 351 // The host UI should be created on the UI thread. |
| 325 bool want_user_interface = true; | 352 bool want_user_interface = true; |
| 326 #if defined(OS_LINUX) | 353 #if defined(OS_LINUX) |
| 327 want_user_interface = false; | 354 want_user_interface = false; |
| 328 #elif defined(OS_MACOSX) | 355 #elif defined(OS_MACOSX) |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 scoped_ptr<XmppSignalStrategy> signal_strategy_; | 750 scoped_ptr<XmppSignalStrategy> signal_strategy_; |
| 724 scoped_ptr<SignalingConnector> signaling_connector_; | 751 scoped_ptr<SignalingConnector> signaling_connector_; |
| 725 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 752 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
| 726 scoped_ptr<LogToServer> log_to_server_; | 753 scoped_ptr<LogToServer> log_to_server_; |
| 727 scoped_ptr<HostEventLogger> host_event_logger_; | 754 scoped_ptr<HostEventLogger> host_event_logger_; |
| 728 | 755 |
| 729 scoped_ptr<HostUserInterface> host_user_interface_; | 756 scoped_ptr<HostUserInterface> host_user_interface_; |
| 730 | 757 |
| 731 scoped_refptr<ChromotingHost> host_; | 758 scoped_refptr<ChromotingHost> host_; |
| 732 | 759 |
| 760 #if defined(REMOTING_MULTI_PROCESS) |
| 761 DesktopSessionConnector* desktop_session_connector_; |
| 762 #endif // defined(REMOTING_MULTI_PROCESS) |
| 763 |
| 733 int exit_code_; | 764 int exit_code_; |
| 734 }; | 765 }; |
| 735 | 766 |
| 736 } // namespace remoting | 767 } // namespace remoting |
| 737 | 768 |
| 738 int main(int argc, char** argv) { | 769 int main(int argc, char** argv) { |
| 739 #if defined(OS_MACOSX) | 770 #if defined(OS_MACOSX) |
| 740 // Needed so we don't leak objects when threads are created. | 771 // Needed so we don't leak objects when threads are created. |
| 741 base::mac::ScopedNSAutoreleasePool pool; | 772 base::mac::ScopedNSAutoreleasePool pool; |
| 742 #endif | 773 #endif |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 user32.GetFunctionPointer("SetProcessDPIAware")); | 857 user32.GetFunctionPointer("SetProcessDPIAware")); |
| 827 set_process_dpi_aware(); | 858 set_process_dpi_aware(); |
| 828 } | 859 } |
| 829 | 860 |
| 830 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting | 861 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting |
| 831 // the command line from GetCommandLineW(), so we can safely pass NULL here. | 862 // the command line from GetCommandLineW(), so we can safely pass NULL here. |
| 832 return main(0, NULL); | 863 return main(0, NULL); |
| 833 } | 864 } |
| 834 | 865 |
| 835 #endif // defined(OS_WIN) | 866 #endif // defined(OS_WIN) |
| OLD | NEW |