| 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" |
| 52 #include "remoting/host/ipc_desktop_environment_factory.h" |
| 51 #include "remoting/host/json_host_config.h" | 53 #include "remoting/host/json_host_config.h" |
| 52 #include "remoting/host/log_to_server.h" | 54 #include "remoting/host/log_to_server.h" |
| 53 #include "remoting/host/network_settings.h" | 55 #include "remoting/host/network_settings.h" |
| 54 #include "remoting/host/policy_hack/policy_watcher.h" | 56 #include "remoting/host/policy_hack/policy_watcher.h" |
| 55 #include "remoting/host/resizing_host_observer.h" | 57 #include "remoting/host/resizing_host_observer.h" |
| 56 #include "remoting/host/session_manager_factory.h" | 58 #include "remoting/host/session_manager_factory.h" |
| 57 #include "remoting/host/signaling_connector.h" | 59 #include "remoting/host/signaling_connector.h" |
| 58 #include "remoting/host/usage_stats_consent.h" | 60 #include "remoting/host/usage_stats_consent.h" |
| 59 #include "remoting/host/video_frame_capturer.h" | 61 #include "remoting/host/video_frame_capturer.h" |
| 60 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 62 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 107 |
| 106 void QuitMessageLoop(MessageLoop* message_loop) { | 108 void QuitMessageLoop(MessageLoop* message_loop) { |
| 107 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 109 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 108 } | 110 } |
| 109 | 111 |
| 110 } // namespace | 112 } // namespace |
| 111 | 113 |
| 112 namespace remoting { | 114 namespace remoting { |
| 113 | 115 |
| 114 class HostProcess | 116 class HostProcess |
| 115 : public HeartbeatSender::Listener, | 117 : public ConfigFileWatcher::Delegate, |
| 116 public IPC::Listener, | 118 public HeartbeatSender::Listener, |
| 117 public ConfigFileWatcher::Delegate { | 119 public IPC::Listener { |
| 118 public: | 120 public: |
| 119 explicit HostProcess(scoped_ptr<ChromotingHostContext> context) | 121 explicit HostProcess(scoped_ptr<ChromotingHostContext> context) |
| 120 : context_(context.Pass()), | 122 : context_(context.Pass()), |
| 121 config_(FilePath()), | 123 config_(FilePath()), |
| 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()), |
| 133 exit_code_(kSuccessExitCode) { | 128 exit_code_(kSuccessExitCode), |
| 129 desktop_session_connector_(NULL) { |
| 134 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 130 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
| 135 curtain_ = CurtainMode::Create( | 131 curtain_ = CurtainMode::Create( |
| 136 base::Bind(&HostProcess::OnDisconnectRequested, | 132 base::Bind(&HostProcess::OnDisconnectRequested, |
| 137 base::Unretained(this)), | 133 base::Unretained(this)), |
| 138 base::Bind(&HostProcess::OnDisconnectRequested, | 134 base::Bind(&HostProcess::OnDisconnectRequested, |
| 139 base::Unretained(this))); | 135 base::Unretained(this))); |
| 140 } | 136 } |
| 141 | 137 |
| 142 bool InitWithCommandLine(const CommandLine* cmd_line) { | 138 bool InitWithCommandLine(const CommandLine* cmd_line) { |
| 143 // Connect to the daemon process. | 139 // Connect to the daemon process. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 270 |
| 275 // IPC::Listener implementation. | 271 // IPC::Listener implementation. |
| 276 virtual bool OnMessageReceived(const IPC::Message& message) { | 272 virtual bool OnMessageReceived(const IPC::Message& message) { |
| 277 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); | 273 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); |
| 278 | 274 |
| 279 #if defined(REMOTING_MULTI_PROCESS) | 275 #if defined(REMOTING_MULTI_PROCESS) |
| 280 bool handled = true; | 276 bool handled = true; |
| 281 IPC_BEGIN_MESSAGE_MAP(HostProcess, message) | 277 IPC_BEGIN_MESSAGE_MAP(HostProcess, message) |
| 282 IPC_MESSAGE_HANDLER(ChromotingDaemonNetworkMsg_Configuration, | 278 IPC_MESSAGE_HANDLER(ChromotingDaemonNetworkMsg_Configuration, |
| 283 OnConfigUpdated) | 279 OnConfigUpdated) |
| 280 IPC_MESSAGE_FORWARD(ChromotingDaemonNetworkMsg_TerminalDisconnected, |
| 281 desktop_session_connector_, |
| 282 DesktopSessionConnector::OnTerminalDisconnected) |
| 284 IPC_MESSAGE_UNHANDLED(handled = false) | 283 IPC_MESSAGE_UNHANDLED(handled = false) |
| 285 IPC_END_MESSAGE_MAP() | 284 IPC_END_MESSAGE_MAP() |
| 286 return handled; | 285 return handled; |
| 287 #else // !defined(REMOTING_MULTI_PROCESS) | 286 #else // !defined(REMOTING_MULTI_PROCESS) |
| 288 return false; | 287 return false; |
| 289 #endif // !defined(REMOTING_MULTI_PROCESS) | 288 #endif // !defined(REMOTING_MULTI_PROCESS) |
| 290 } | 289 } |
| 291 | 290 |
| 292 void StartHostProcess() { | 291 void StartHostProcess() { |
| 293 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); | 292 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); |
| 294 | 293 |
| 295 if (!InitWithCommandLine(CommandLine::ForCurrentProcess())) { | 294 if (!InitWithCommandLine(CommandLine::ForCurrentProcess())) { |
| 296 OnConfigWatcherError(); | 295 OnConfigWatcherError(); |
| 297 return; | 296 return; |
| 298 } | 297 } |
| 299 | 298 |
| 299 // Create a desktop environment factory appropriate to the build type & |
| 300 // platform. |
| 301 #if defined(OS_WIN) |
| 302 |
| 303 #if defined(REMOTING_MULTI_PROCESS) |
| 304 IpcDesktopEnvironmentFactory* desktop_environment_factory = |
| 305 new IpcDesktopEnvironmentFactory( |
| 306 daemon_channel_.get(), |
| 307 context_->input_task_runner(), |
| 308 context_->network_task_runner(), |
| 309 context_->ui_task_runner()); |
| 310 desktop_session_connector_ = desktop_environment_factory; |
| 311 #else // !defined(REMOTING_MULTI_PROCESS) |
| 312 DesktopEnvironmentFactory* desktop_environment_factory = |
| 313 new SessionDesktopEnvironmentFactory( |
| 314 context_->input_task_runner(), context_->ui_task_runner()); |
| 315 #endif // !defined(REMOTING_MULTI_PROCESS) |
| 316 |
| 317 #else // !defined(OS_WIN) |
| 318 DesktopEnvironmentFactory* desktop_environment_factory = |
| 319 new DesktopEnvironmentFactory( |
| 320 context_->input_task_runner(), context_->ui_task_runner()); |
| 321 #endif // !defined(OS_WIN) |
| 322 |
| 323 desktop_environment_factory_.reset(desktop_environment_factory); |
| 324 |
| 300 context_->network_task_runner()->PostTask( | 325 context_->network_task_runner()->PostTask( |
| 301 FROM_HERE, | 326 FROM_HERE, |
| 302 base::Bind(&HostProcess::ListenForShutdownSignal, | 327 base::Bind(&HostProcess::ListenForShutdownSignal, |
| 303 base::Unretained(this))); | 328 base::Unretained(this))); |
| 304 | 329 |
| 305 StartWatchingConfigChanges(); | 330 StartWatchingConfigChanges(); |
| 306 } | 331 } |
| 307 | 332 |
| 308 int get_exit_code() const { return exit_code_; } | 333 int get_exit_code() const { return exit_code_; } |
| 309 | 334 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 scoped_ptr<SignalingConnector> signaling_connector_; | 710 scoped_ptr<SignalingConnector> signaling_connector_; |
| 686 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 711 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
| 687 scoped_ptr<LogToServer> log_to_server_; | 712 scoped_ptr<LogToServer> log_to_server_; |
| 688 scoped_ptr<HostEventLogger> host_event_logger_; | 713 scoped_ptr<HostEventLogger> host_event_logger_; |
| 689 | 714 |
| 690 scoped_ptr<HostUserInterface> host_user_interface_; | 715 scoped_ptr<HostUserInterface> host_user_interface_; |
| 691 | 716 |
| 692 scoped_refptr<ChromotingHost> host_; | 717 scoped_refptr<ChromotingHost> host_; |
| 693 | 718 |
| 694 int exit_code_; | 719 int exit_code_; |
| 720 |
| 721 DesktopSessionConnector* desktop_session_connector_; |
| 695 }; | 722 }; |
| 696 | 723 |
| 697 } // namespace remoting | 724 } // namespace remoting |
| 698 | 725 |
| 699 int main(int argc, char** argv) { | 726 int main(int argc, char** argv) { |
| 700 #if defined(OS_MACOSX) | 727 #if defined(OS_MACOSX) |
| 701 // Needed so we don't leak objects when threads are created. | 728 // Needed so we don't leak objects when threads are created. |
| 702 base::mac::ScopedNSAutoreleasePool pool; | 729 base::mac::ScopedNSAutoreleasePool pool; |
| 703 #endif | 730 #endif |
| 704 | 731 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 user32.GetFunctionPointer("SetProcessDPIAware")); | 826 user32.GetFunctionPointer("SetProcessDPIAware")); |
| 800 set_process_dpi_aware(); | 827 set_process_dpi_aware(); |
| 801 } | 828 } |
| 802 | 829 |
| 803 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting | 830 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting |
| 804 // the command line from GetCommandLineW(), so we can safely pass NULL here. | 831 // the command line from GetCommandLineW(), so we can safely pass NULL here. |
| 805 return main(0, NULL); | 832 return main(0, NULL); |
| 806 } | 833 } |
| 807 | 834 |
| 808 #endif // defined(OS_WIN) | 835 #endif // defined(OS_WIN) |
| OLD | NEW |