Chromium Code Reviews| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 host_->SetAuthenticatorFactory(factory.Pass()); | 268 host_->SetAuthenticatorFactory(factory.Pass()); |
| 273 } | 269 } |
| 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, |
|
Wez
2012/10/17 17:51:57
nit: Two spaces, plz.
alexeypa (please no reviews)
2012/10/17 21:35:53
I have two on my machine. It is code review bugs,
| |
| 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 the proper kind of the desktop environment factory. | |
|
Wez
2012/10/17 17:51:57
nit: Create a desktop environment factory appropri
alexeypa (please no reviews)
2012/10/17 21:35:53
Done.
| |
| 300 #if defined(OS_WIN) | |
| 301 | |
| 302 #if defined(REMOTING_MULTI_PROCESS) | |
|
Wez
2012/10/17 17:51:57
nit: Unless we define REMOTING_MULTI_PROCESS on ot
alexeypa (please no reviews)
2012/10/17 21:35:53
Currently we don't but I assume we might one day.
| |
| 303 IpcDesktopEnvironmentFactory* desktop_environment_factory = | |
| 304 new IpcDesktopEnvironmentFactory( | |
| 305 daemon_channel_.get(), | |
| 306 context_->input_task_runner(), | |
| 307 context_->network_task_runner(), | |
| 308 context_->ui_task_runner()); | |
| 309 desktop_session_connector_ = desktop_environment_factory; | |
| 310 #else // !defined(REMOTING_MULTI_PROCESS) | |
| 311 DesktopEnvironmentFactory* desktop_environment_factory = | |
| 312 new SessionDesktopEnvironmentFactory( | |
| 313 context_->input_task_runner(), context_->ui_task_runner()); | |
| 314 #endif // !defined(REMOTING_MULTI_PROCESS) | |
| 315 | |
| 316 #else // !defined(OS_WIN) | |
| 317 DesktopEnvironmentFactory* desktop_environment_factory = | |
| 318 new DesktopEnvironmentFactory( | |
| 319 context_->input_task_runner(), context_->ui_task_runner()); | |
| 320 #endif // !defined(OS_WIN) | |
| 321 | |
| 322 desktop_environment_factory_.reset(desktop_environment_factory); | |
| 323 | |
| 300 context_->network_task_runner()->PostTask( | 324 context_->network_task_runner()->PostTask( |
| 301 FROM_HERE, | 325 FROM_HERE, |
| 302 base::Bind(&HostProcess::ListenForShutdownSignal, | 326 base::Bind(&HostProcess::ListenForShutdownSignal, |
| 303 base::Unretained(this))); | 327 base::Unretained(this))); |
| 304 | 328 |
| 305 StartWatchingConfigChanges(); | 329 StartWatchingConfigChanges(); |
| 306 } | 330 } |
| 307 | 331 |
| 308 int get_exit_code() const { return exit_code_; } | 332 int get_exit_code() const { return exit_code_; } |
| 309 | 333 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 685 scoped_ptr<SignalingConnector> signaling_connector_; | 709 scoped_ptr<SignalingConnector> signaling_connector_; |
| 686 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 710 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
| 687 scoped_ptr<LogToServer> log_to_server_; | 711 scoped_ptr<LogToServer> log_to_server_; |
| 688 scoped_ptr<HostEventLogger> host_event_logger_; | 712 scoped_ptr<HostEventLogger> host_event_logger_; |
| 689 | 713 |
| 690 scoped_ptr<HostUserInterface> host_user_interface_; | 714 scoped_ptr<HostUserInterface> host_user_interface_; |
| 691 | 715 |
| 692 scoped_refptr<ChromotingHost> host_; | 716 scoped_refptr<ChromotingHost> host_; |
| 693 | 717 |
| 694 int exit_code_; | 718 int exit_code_; |
| 719 | |
| 720 DesktopSessionConnector* desktop_session_connector_; | |
| 695 }; | 721 }; |
| 696 | 722 |
| 697 } // namespace remoting | 723 } // namespace remoting |
| 698 | 724 |
| 699 int main(int argc, char** argv) { | 725 int main(int argc, char** argv) { |
| 700 #if defined(OS_MACOSX) | 726 #if defined(OS_MACOSX) |
| 701 // Needed so we don't leak objects when threads are created. | 727 // Needed so we don't leak objects when threads are created. |
| 702 base::mac::ScopedNSAutoreleasePool pool; | 728 base::mac::ScopedNSAutoreleasePool pool; |
| 703 #endif | 729 #endif |
| 704 | 730 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 799 user32.GetFunctionPointer("SetProcessDPIAware")); | 825 user32.GetFunctionPointer("SetProcessDPIAware")); |
| 800 set_process_dpi_aware(); | 826 set_process_dpi_aware(); |
| 801 } | 827 } |
| 802 | 828 |
| 803 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting | 829 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting |
| 804 // the command line from GetCommandLineW(), so we can safely pass NULL here. | 830 // the command line from GetCommandLineW(), so we can safely pass NULL here. |
| 805 return main(0, NULL); | 831 return main(0, NULL); |
| 806 } | 832 } |
| 807 | 833 |
| 808 #endif // defined(OS_WIN) | 834 #endif // defined(OS_WIN) |
| OLD | NEW |