| 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 30 matching lines...) Expand all  Loading... | 
| 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/desktop_session_connector.h" | 
| 45 #include "remoting/host/dns_blackhole_checker.h" | 45 #include "remoting/host/dns_blackhole_checker.h" | 
| 46 #include "remoting/host/event_executor.h" | 46 #include "remoting/host/event_executor.h" | 
| 47 #include "remoting/host/heartbeat_sender.h" | 47 #include "remoting/host/heartbeat_sender.h" | 
| 48 #include "remoting/host/host_config.h" | 48 #include "remoting/host/host_config.h" | 
| 49 #include "remoting/host/host_event_logger.h" | 49 #include "remoting/host/host_event_logger.h" | 
| 50 #include "remoting/host/host_exit_codes.h" | 50 #include "remoting/host/host_exit_codes.h" | 
|  | 51 #include "remoting/host/host_status_service.h" | 
| 51 #include "remoting/host/host_user_interface.h" | 52 #include "remoting/host/host_user_interface.h" | 
| 52 #include "remoting/host/ipc_consts.h" | 53 #include "remoting/host/ipc_consts.h" | 
| 53 #include "remoting/host/ipc_desktop_environment_factory.h" | 54 #include "remoting/host/ipc_desktop_environment_factory.h" | 
| 54 #include "remoting/host/json_host_config.h" | 55 #include "remoting/host/json_host_config.h" | 
| 55 #include "remoting/host/logging.h" | 56 #include "remoting/host/logging.h" | 
| 56 #include "remoting/host/log_to_server.h" | 57 #include "remoting/host/log_to_server.h" | 
| 57 #include "remoting/host/network_settings.h" | 58 #include "remoting/host/network_settings.h" | 
| 58 #include "remoting/host/policy_hack/policy_watcher.h" | 59 #include "remoting/host/policy_hack/policy_watcher.h" | 
| 59 #include "remoting/host/resizing_host_observer.h" | 60 #include "remoting/host/resizing_host_observer.h" | 
| 60 #include "remoting/host/session_manager_factory.h" | 61 #include "remoting/host/session_manager_factory.h" | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 97 // This is used for tagging system event logs. | 98 // This is used for tagging system event logs. | 
| 98 const char kApplicationName[] = "chromoting"; | 99 const char kApplicationName[] = "chromoting"; | 
| 99 | 100 | 
| 100 // The command line switch used to get version of the daemon. | 101 // The command line switch used to get version of the daemon. | 
| 101 const char kVersionSwitchName[] = "version"; | 102 const char kVersionSwitchName[] = "version"; | 
| 102 | 103 | 
| 103 // The command line switch used to pass name of the pipe to capture audio on | 104 // The command line switch used to pass name of the pipe to capture audio on | 
| 104 // linux. | 105 // linux. | 
| 105 const char kAudioPipeSwitchName[] = "audio-pipe-name"; | 106 const char kAudioPipeSwitchName[] = "audio-pipe-name"; | 
| 106 | 107 | 
|  | 108 // The command line switch used to enable host status service. | 
|  | 109 const char kEnableStatusServiceSwitchName[] = "enable-status-service"; | 
|  | 110 | 
| 107 void QuitMessageLoop(MessageLoop* message_loop) { | 111 void QuitMessageLoop(MessageLoop* message_loop) { | 
| 108   message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 112   message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 
| 109 } | 113 } | 
| 110 | 114 | 
| 111 // Returns true if GetUsername() is implemented on this platform. | 115 // Returns true if GetUsername() is implemented on this platform. | 
| 112 bool CanGetUsername() { | 116 bool CanGetUsername() { | 
| 113 #if defined(OS_LINUX) | 117 #if defined(OS_LINUX) | 
| 114   return true; | 118   return true; | 
| 115 #else  // defined(OS_LINUX) | 119 #else  // defined(OS_LINUX) | 
| 116   return false; | 120   return false; | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 186   // Applies the host config, returning true if successful. | 190   // Applies the host config, returning true if successful. | 
| 187   bool ApplyConfig(scoped_ptr<JsonHostConfig> config); | 191   bool ApplyConfig(scoped_ptr<JsonHostConfig> config); | 
| 188 | 192 | 
| 189   void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); | 193   void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); | 
| 190   bool OnHostDomainPolicyUpdate(const std::string& host_domain); | 194   bool OnHostDomainPolicyUpdate(const std::string& host_domain); | 
| 191   bool OnUsernamePolicyUpdate(bool username_match_required); | 195   bool OnUsernamePolicyUpdate(bool username_match_required); | 
| 192   bool OnNatPolicyUpdate(bool nat_traversal_enabled); | 196   bool OnNatPolicyUpdate(bool nat_traversal_enabled); | 
| 193   bool OnCurtainPolicyUpdate(bool curtain_required); | 197   bool OnCurtainPolicyUpdate(bool curtain_required); | 
| 194   bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix); | 198   bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix); | 
| 195 | 199 | 
|  | 200   void StartHostStatusService(); | 
|  | 201 | 
| 196   void StartHost(); | 202   void StartHost(); | 
| 197 | 203 | 
| 198   void OnAuthFailed(); | 204   void OnAuthFailed(); | 
| 199 | 205 | 
| 200   void RejectAuthenticatingClient(); | 206   void RejectAuthenticatingClient(); | 
| 201 | 207 | 
| 202   // Invoked when the user uses the Disconnect windows to terminate | 208   // Invoked when the user uses the Disconnect windows to terminate | 
| 203   // the sessions, or when the local session is activated in curtain mode. | 209   // the sessions, or when the local session is activated in curtain mode. | 
| 204   void OnDisconnectRequested(); | 210   void OnDisconnectRequested(); | 
| 205 | 211 | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 221                const int& line_number); | 227                const int& line_number); | 
| 222 | 228 | 
| 223   scoped_ptr<ChromotingHostContext> context_; | 229   scoped_ptr<ChromotingHostContext> context_; | 
| 224   scoped_ptr<IPC::ChannelProxy> daemon_channel_; | 230   scoped_ptr<IPC::ChannelProxy> daemon_channel_; | 
| 225   scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 231   scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 
| 226 | 232 | 
| 227   FilePath host_config_path_; | 233   FilePath host_config_path_; | 
| 228   scoped_ptr<ConfigFileWatcher> config_watcher_; | 234   scoped_ptr<ConfigFileWatcher> config_watcher_; | 
| 229 | 235 | 
| 230   // Accessed on the network thread. | 236   // Accessed on the network thread. | 
|  | 237 | 
|  | 238   scoped_ptr<HostStatusService> status_service_; | 
|  | 239 | 
| 231   std::string host_id_; | 240   std::string host_id_; | 
| 232   protocol::SharedSecretHash host_secret_hash_; | 241   protocol::SharedSecretHash host_secret_hash_; | 
| 233   HostKeyPair key_pair_; | 242   HostKeyPair key_pair_; | 
| 234   std::string oauth_refresh_token_; | 243   std::string oauth_refresh_token_; | 
| 235   std::string serialized_config_; | 244   std::string serialized_config_; | 
| 236   std::string xmpp_login_; | 245   std::string xmpp_login_; | 
| 237   std::string xmpp_auth_token_; | 246   std::string xmpp_auth_token_; | 
| 238   std::string xmpp_auth_service_; | 247   std::string xmpp_auth_service_; | 
| 239 | 248 | 
| 240   scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; | 249   scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; | 
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 488   // If an audio pipe is specific on the command-line then initialize | 497   // If an audio pipe is specific on the command-line then initialize | 
| 489   // AudioCapturerLinux to capture from it. | 498   // AudioCapturerLinux to capture from it. | 
| 490   FilePath audio_pipe_name = CommandLine::ForCurrentProcess()-> | 499   FilePath audio_pipe_name = CommandLine::ForCurrentProcess()-> | 
| 491       GetSwitchValuePath(kAudioPipeSwitchName); | 500       GetSwitchValuePath(kAudioPipeSwitchName); | 
| 492   if (!audio_pipe_name.empty()) { | 501   if (!audio_pipe_name.empty()) { | 
| 493     remoting::AudioCapturerLinux::InitializePipeReader( | 502     remoting::AudioCapturerLinux::InitializePipeReader( | 
| 494         context_->audio_task_runner(), audio_pipe_name); | 503         context_->audio_task_runner(), audio_pipe_name); | 
| 495   } | 504   } | 
| 496 #endif  // defined(OS_LINUX) | 505 #endif  // defined(OS_LINUX) | 
| 497 | 506 | 
|  | 507   if (CommandLine::ForCurrentProcess()->HasSwitch( | 
|  | 508           kEnableStatusServiceSwitchName)) { | 
|  | 509     context_->network_task_runner()->PostTask( | 
|  | 510         FROM_HERE, | 
|  | 511         base::Bind(&HostProcess::StartHostStatusService, | 
|  | 512                    base::Unretained(this))); | 
|  | 513   } | 
|  | 514 | 
| 498   // Create a desktop environment factory appropriate to the build type & | 515   // Create a desktop environment factory appropriate to the build type & | 
| 499   // platform. | 516   // platform. | 
| 500 #if defined(OS_WIN) | 517 #if defined(OS_WIN) | 
| 501 | 518 | 
| 502 #if defined(REMOTING_MULTI_PROCESS) | 519 #if defined(REMOTING_MULTI_PROCESS) | 
| 503   IpcDesktopEnvironmentFactory* desktop_environment_factory = | 520   IpcDesktopEnvironmentFactory* desktop_environment_factory = | 
| 504       new IpcDesktopEnvironmentFactory( | 521       new IpcDesktopEnvironmentFactory( | 
| 505           daemon_channel_.get(), | 522           daemon_channel_.get(), | 
| 506           context_->input_task_runner(), | 523           context_->input_task_runner(), | 
| 507           context_->network_task_runner(), | 524           context_->network_task_runner(), | 
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 758   DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 775   DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 
| 759 | 776 | 
| 760   if (talkgadget_prefix != talkgadget_prefix_) { | 777   if (talkgadget_prefix != talkgadget_prefix_) { | 
| 761     LOG(INFO) << "Policy sets talkgadget prefix: " << talkgadget_prefix; | 778     LOG(INFO) << "Policy sets talkgadget prefix: " << talkgadget_prefix; | 
| 762     talkgadget_prefix_ = talkgadget_prefix; | 779     talkgadget_prefix_ = talkgadget_prefix; | 
| 763     return true; | 780     return true; | 
| 764   } | 781   } | 
| 765   return false; | 782   return false; | 
| 766 } | 783 } | 
| 767 | 784 | 
|  | 785 void HostProcess::StartHostStatusService() { | 
|  | 786   DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 
|  | 787   status_service_.reset(new HostStatusService()); | 
|  | 788 } | 
|  | 789 | 
| 768 void HostProcess::StartHost() { | 790 void HostProcess::StartHost() { | 
| 769   DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 791   DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 
| 770   DCHECK(!host_); | 792   DCHECK(!host_); | 
| 771   DCHECK(!signal_strategy_.get()); | 793   DCHECK(!signal_strategy_.get()); | 
| 772 | 794 | 
| 773   if (shutting_down_) | 795   if (shutting_down_) | 
| 774     return; | 796     return; | 
| 775 | 797 | 
| 776   signal_strategy_.reset( | 798   signal_strategy_.reset( | 
| 777       new XmppSignalStrategy(context_->url_request_context_getter(), | 799       new XmppSignalStrategy(context_->url_request_context_getter(), | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 839   curtaining_host_observer_.reset(new CurtainingHostObserver( | 861   curtaining_host_observer_.reset(new CurtainingHostObserver( | 
| 840                                   curtain_.get(), host_)); | 862                                   curtain_.get(), host_)); | 
| 841   curtaining_host_observer_->SetEnableCurtaining(curtain_required_); | 863   curtaining_host_observer_->SetEnableCurtaining(curtain_required_); | 
| 842 | 864 | 
| 843   if (host_user_interface_.get()) { | 865   if (host_user_interface_.get()) { | 
| 844     host_user_interface_->Start( | 866     host_user_interface_->Start( | 
| 845         host_, base::Bind(&HostProcess::OnDisconnectRequested, | 867         host_, base::Bind(&HostProcess::OnDisconnectRequested, | 
| 846                           base::Unretained(this))); | 868                           base::Unretained(this))); | 
| 847   } | 869   } | 
| 848 | 870 | 
|  | 871   if (status_service_) | 
|  | 872     status_service_->SetHostIsUp(host_id_); | 
|  | 873 | 
| 849   host_->Start(xmpp_login_); | 874   host_->Start(xmpp_login_); | 
| 850 | 875 | 
| 851   CreateAuthenticatorFactory(); | 876   CreateAuthenticatorFactory(); | 
| 852 } | 877 } | 
| 853 | 878 | 
| 854 void HostProcess::OnAuthFailed() { | 879 void HostProcess::OnAuthFailed() { | 
| 855   Shutdown(kInvalidOauthCredentialsExitCode); | 880   Shutdown(kInvalidOauthCredentialsExitCode); | 
| 856 } | 881 } | 
| 857 | 882 | 
| 858 void HostProcess::RejectAuthenticatingClient() { | 883 void HostProcess::RejectAuthenticatingClient() { | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 897 | 922 | 
| 898   StartHost(); | 923   StartHost(); | 
| 899 } | 924 } | 
| 900 | 925 | 
| 901 void HostProcess::Shutdown(int exit_code) { | 926 void HostProcess::Shutdown(int exit_code) { | 
| 902   DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 927   DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 
| 903 | 928 | 
| 904   if (shutting_down_) | 929   if (shutting_down_) | 
| 905     return; | 930     return; | 
| 906 | 931 | 
|  | 932   if (status_service_) | 
|  | 933     status_service_->SetHostIsDown(); | 
|  | 934 | 
| 907   shutting_down_ = true; | 935   shutting_down_ = true; | 
| 908   exit_code_ = exit_code; | 936   exit_code_ = exit_code; | 
| 909   if (host_) { | 937   if (host_) { | 
| 910     host_->Shutdown(base::Bind( | 938     host_->Shutdown(base::Bind( | 
| 911         &HostProcess::OnShutdownFinished, base::Unretained(this))); | 939         &HostProcess::OnShutdownFinished, base::Unretained(this))); | 
| 912   } else { | 940   } else { | 
| 913     OnShutdownFinished(); | 941     OnShutdownFinished(); | 
| 914   } | 942   } | 
| 915 } | 943 } | 
| 916 | 944 | 
| 917 void HostProcess::OnShutdownFinished() { | 945 void HostProcess::OnShutdownFinished() { | 
| 918   DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 946   DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 
| 919 | 947 | 
| 920   // Destroy networking objects while we are on the network thread. | 948   // Destroy networking objects while we are on the network thread. | 
| 921   host_ = NULL; | 949   host_ = NULL; | 
| 922   ResetHost(); | 950   ResetHost(); | 
| 923 | 951 | 
| 924   if (policy_watcher_.get()) { | 952   if (policy_watcher_.get()) { | 
| 925     base::WaitableEvent done_event(true, false); | 953     base::WaitableEvent done_event(true, false); | 
| 926     policy_watcher_->StopWatching(&done_event); | 954     policy_watcher_->StopWatching(&done_event); | 
| 927     done_event.Wait(); | 955     done_event.Wait(); | 
| 928     policy_watcher_.reset(); | 956     policy_watcher_.reset(); | 
| 929   } | 957   } | 
| 930 | 958 | 
|  | 959   status_service_.reset(); | 
|  | 960 | 
| 931   // Complete the rest of shutdown on the main thread. | 961   // Complete the rest of shutdown on the main thread. | 
| 932   context_->ui_task_runner()->PostTask( | 962   context_->ui_task_runner()->PostTask( | 
| 933       FROM_HERE, | 963       FROM_HERE, | 
| 934       base::Bind(&HostProcess::ShutdownHostProcess, | 964       base::Bind(&HostProcess::ShutdownHostProcess, | 
| 935                  base::Unretained(this))); | 965                  base::Unretained(this))); | 
| 936 } | 966 } | 
| 937 | 967 | 
| 938 void HostProcess::ResetHost() { | 968 void HostProcess::ResetHost() { | 
| 939   DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 969   DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 
| 940 | 970 | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1038             user32.GetFunctionPointer("SetProcessDPIAware")); | 1068             user32.GetFunctionPointer("SetProcessDPIAware")); | 
| 1039     set_process_dpi_aware(); | 1069     set_process_dpi_aware(); | 
| 1040   } | 1070   } | 
| 1041 | 1071 | 
| 1042   // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting | 1072   // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting | 
| 1043   // the command line from GetCommandLineW(), so we can safely pass NULL here. | 1073   // the command line from GetCommandLineW(), so we can safely pass NULL here. | 
| 1044   return main(0, NULL); | 1074   return main(0, NULL); | 
| 1045 } | 1075 } | 
| 1046 | 1076 | 
| 1047 #endif  // defined(OS_WIN) | 1077 #endif  // defined(OS_WIN) | 
| OLD | NEW | 
|---|