Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: remoting/host/remoting_me2me_host.cc

Issue 11362267: Add status service for remoting host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/host_status_service.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "remoting/host/curtaining_host_observer.h" 42 #include "remoting/host/curtaining_host_observer.h"
43 #include "remoting/host/desktop_environment_factory.h" 43 #include "remoting/host/desktop_environment_factory.h"
44 #include "remoting/host/desktop_resizer.h" 44 #include "remoting/host/desktop_resizer.h"
45 #include "remoting/host/desktop_session_connector.h" 45 #include "remoting/host/desktop_session_connector.h"
46 #include "remoting/host/dns_blackhole_checker.h" 46 #include "remoting/host/dns_blackhole_checker.h"
47 #include "remoting/host/event_executor.h" 47 #include "remoting/host/event_executor.h"
48 #include "remoting/host/heartbeat_sender.h" 48 #include "remoting/host/heartbeat_sender.h"
49 #include "remoting/host/host_config.h" 49 #include "remoting/host/host_config.h"
50 #include "remoting/host/host_event_logger.h" 50 #include "remoting/host/host_event_logger.h"
51 #include "remoting/host/host_exit_codes.h" 51 #include "remoting/host/host_exit_codes.h"
52 #include "remoting/host/host_status_service.h"
52 #include "remoting/host/host_user_interface.h" 53 #include "remoting/host/host_user_interface.h"
53 #include "remoting/host/ipc_constants.h" 54 #include "remoting/host/ipc_constants.h"
54 #include "remoting/host/ipc_desktop_environment_factory.h" 55 #include "remoting/host/ipc_desktop_environment_factory.h"
55 #include "remoting/host/json_host_config.h" 56 #include "remoting/host/json_host_config.h"
56 #include "remoting/host/logging.h" 57 #include "remoting/host/logging.h"
57 #include "remoting/host/log_to_server.h" 58 #include "remoting/host/log_to_server.h"
58 #include "remoting/host/network_settings.h" 59 #include "remoting/host/network_settings.h"
59 #include "remoting/host/policy_hack/policy_watcher.h" 60 #include "remoting/host/policy_hack/policy_watcher.h"
60 #include "remoting/host/resizing_host_observer.h" 61 #include "remoting/host/resizing_host_observer.h"
61 #include "remoting/host/session_manager_factory.h" 62 #include "remoting/host/session_manager_factory.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // This is used for tagging system event logs. 99 // This is used for tagging system event logs.
99 const char kApplicationName[] = "chromoting"; 100 const char kApplicationName[] = "chromoting";
100 101
101 // The command line switch used to get version of the daemon. 102 // The command line switch used to get version of the daemon.
102 const char kVersionSwitchName[] = "version"; 103 const char kVersionSwitchName[] = "version";
103 104
104 // The command line switch used to pass name of the pipe to capture audio on 105 // The command line switch used to pass name of the pipe to capture audio on
105 // linux. 106 // linux.
106 const char kAudioPipeSwitchName[] = "audio-pipe-name"; 107 const char kAudioPipeSwitchName[] = "audio-pipe-name";
107 108
109 // The command line switch used to enable host status service.
110 const char kEnableStatusServiceSwitchName[] = "enable-status-service";
111
108 void QuitMessageLoop(MessageLoop* message_loop) { 112 void QuitMessageLoop(MessageLoop* message_loop) {
109 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 113 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure());
110 } 114 }
111 115
112 // Returns true if GetUsername() is implemented on this platform. 116 // Returns true if GetUsername() is implemented on this platform.
113 bool CanGetUsername() { 117 bool CanGetUsername() {
114 #if defined(OS_LINUX) 118 #if defined(OS_LINUX)
115 return true; 119 return true;
116 #else // defined(OS_LINUX) 120 #else // defined(OS_LINUX)
117 return false; 121 return false;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // Applies the host config, returning true if successful. 200 // Applies the host config, returning true if successful.
197 bool ApplyConfig(scoped_ptr<JsonHostConfig> config); 201 bool ApplyConfig(scoped_ptr<JsonHostConfig> config);
198 202
199 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); 203 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies);
200 bool OnHostDomainPolicyUpdate(const std::string& host_domain); 204 bool OnHostDomainPolicyUpdate(const std::string& host_domain);
201 bool OnUsernamePolicyUpdate(bool username_match_required); 205 bool OnUsernamePolicyUpdate(bool username_match_required);
202 bool OnNatPolicyUpdate(bool nat_traversal_enabled); 206 bool OnNatPolicyUpdate(bool nat_traversal_enabled);
203 bool OnCurtainPolicyUpdate(bool curtain_required); 207 bool OnCurtainPolicyUpdate(bool curtain_required);
204 bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix); 208 bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix);
205 209
210 void StartHostStatusService();
211
206 void StartHost(); 212 void StartHost();
207 213
208 void OnAuthFailed(); 214 void OnAuthFailed();
209 215
210 void RejectAuthenticatingClient(); 216 void RejectAuthenticatingClient();
211 217
212 // Invoked when the user uses the Disconnect windows to terminate 218 // Invoked when the user uses the Disconnect windows to terminate
213 // the sessions, or when the local session is activated in curtain mode. 219 // the sessions, or when the local session is activated in curtain mode.
214 void OnDisconnectRequested(); 220 void OnDisconnectRequested();
215 221
(...skipping 19 matching lines...) Expand all
235 // Created on the UI thread but used from the network thread. 241 // Created on the UI thread but used from the network thread.
236 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; 242 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
237 243
238 // Accessed on the UI thread. 244 // Accessed on the UI thread.
239 scoped_ptr<IPC::ChannelProxy> daemon_channel_; 245 scoped_ptr<IPC::ChannelProxy> daemon_channel_;
240 FilePath host_config_path_; 246 FilePath host_config_path_;
241 scoped_ptr<ConfigFileWatcher> config_watcher_; 247 scoped_ptr<ConfigFileWatcher> config_watcher_;
242 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; 248 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_;
243 249
244 // Accessed on the network thread. 250 // Accessed on the network thread.
251
252 scoped_ptr<HostStatusService> status_service_;
253
245 std::string host_id_; 254 std::string host_id_;
246 protocol::SharedSecretHash host_secret_hash_; 255 protocol::SharedSecretHash host_secret_hash_;
247 HostKeyPair key_pair_; 256 HostKeyPair key_pair_;
248 std::string oauth_refresh_token_; 257 std::string oauth_refresh_token_;
249 std::string serialized_config_; 258 std::string serialized_config_;
250 std::string xmpp_login_; 259 std::string xmpp_login_;
251 std::string xmpp_auth_token_; 260 std::string xmpp_auth_token_;
252 std::string xmpp_auth_service_; 261 std::string xmpp_auth_service_;
253 262
254 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; 263 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 // If an audio pipe is specific on the command-line then initialize 538 // If an audio pipe is specific on the command-line then initialize
530 // AudioCapturerLinux to capture from it. 539 // AudioCapturerLinux to capture from it.
531 FilePath audio_pipe_name = CommandLine::ForCurrentProcess()-> 540 FilePath audio_pipe_name = CommandLine::ForCurrentProcess()->
532 GetSwitchValuePath(kAudioPipeSwitchName); 541 GetSwitchValuePath(kAudioPipeSwitchName);
533 if (!audio_pipe_name.empty()) { 542 if (!audio_pipe_name.empty()) {
534 remoting::AudioCapturerLinux::InitializePipeReader( 543 remoting::AudioCapturerLinux::InitializePipeReader(
535 context_->audio_task_runner(), audio_pipe_name); 544 context_->audio_task_runner(), audio_pipe_name);
536 } 545 }
537 #endif // defined(OS_LINUX) 546 #endif // defined(OS_LINUX)
538 547
548 if (CommandLine::ForCurrentProcess()->HasSwitch(
549 kEnableStatusServiceSwitchName)) {
550 context_->network_task_runner()->PostTask(
551 FROM_HERE,
552 base::Bind(&HostProcess::StartHostStatusService,
553 base::Unretained(this)));
554 }
555
539 // Create a desktop environment factory appropriate to the build type & 556 // Create a desktop environment factory appropriate to the build type &
540 // platform. 557 // platform.
541 #if defined(OS_WIN) 558 #if defined(OS_WIN)
542 559
543 #if defined(REMOTING_MULTI_PROCESS) 560 #if defined(REMOTING_MULTI_PROCESS)
544 IpcDesktopEnvironmentFactory* desktop_environment_factory = 561 IpcDesktopEnvironmentFactory* desktop_environment_factory =
545 new IpcDesktopEnvironmentFactory( 562 new IpcDesktopEnvironmentFactory(
546 daemon_channel_.get(), 563 daemon_channel_.get(),
547 context_->input_task_runner(), 564 context_->input_task_runner(),
548 context_->network_task_runner(), 565 context_->network_task_runner(),
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 818 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
802 819
803 if (talkgadget_prefix != talkgadget_prefix_) { 820 if (talkgadget_prefix != talkgadget_prefix_) {
804 LOG(INFO) << "Policy sets talkgadget prefix: " << talkgadget_prefix; 821 LOG(INFO) << "Policy sets talkgadget prefix: " << talkgadget_prefix;
805 talkgadget_prefix_ = talkgadget_prefix; 822 talkgadget_prefix_ = talkgadget_prefix;
806 return true; 823 return true;
807 } 824 }
808 return false; 825 return false;
809 } 826 }
810 827
828 void HostProcess::StartHostStatusService() {
829 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
830 status_service_.reset(new HostStatusService());
831 }
832
811 void HostProcess::StartHost() { 833 void HostProcess::StartHost() {
812 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 834 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
813 DCHECK(!host_); 835 DCHECK(!host_);
814 DCHECK(!signal_strategy_.get()); 836 DCHECK(!signal_strategy_.get());
815 837
816 if (shutting_down_) 838 if (shutting_down_)
817 return; 839 return;
818 840
819 signal_strategy_.reset( 841 signal_strategy_.reset(
820 new XmppSignalStrategy(context_->url_request_context_getter(), 842 new XmppSignalStrategy(context_->url_request_context_getter(),
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 // and disconnect. 903 // and disconnect.
882 curtaining_host_observer_.reset(new CurtainingHostObserver( 904 curtaining_host_observer_.reset(new CurtainingHostObserver(
883 curtain_.get(), host_)); 905 curtain_.get(), host_));
884 curtaining_host_observer_->SetEnableCurtaining(curtain_required_); 906 curtaining_host_observer_->SetEnableCurtaining(curtain_required_);
885 907
886 if (host_user_interface_.get()) { 908 if (host_user_interface_.get()) {
887 host_user_interface_->Start( 909 host_user_interface_->Start(
888 host_, base::Bind(&HostProcess::OnDisconnectRequested, this)); 910 host_, base::Bind(&HostProcess::OnDisconnectRequested, this));
889 } 911 }
890 912
913 if (status_service_)
914 status_service_->SetHostIsUp(host_id_);
915
891 host_->Start(xmpp_login_); 916 host_->Start(xmpp_login_);
892 917
893 CreateAuthenticatorFactory(); 918 CreateAuthenticatorFactory();
894 } 919 }
895 920
896 void HostProcess::OnAuthFailed() { 921 void HostProcess::OnAuthFailed() {
897 Shutdown(kInvalidOauthCredentialsExitCode); 922 Shutdown(kInvalidOauthCredentialsExitCode);
898 } 923 }
899 924
900 void HostProcess::RejectAuthenticatingClient() { 925 void HostProcess::RejectAuthenticatingClient() {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 963
939 StartHost(); 964 StartHost();
940 } 965 }
941 966
942 void HostProcess::Shutdown(int exit_code) { 967 void HostProcess::Shutdown(int exit_code) {
943 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 968 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
944 969
945 if (shutting_down_) 970 if (shutting_down_)
946 return; 971 return;
947 972
973 if (status_service_)
974 status_service_->SetHostIsDown();
975
948 shutting_down_ = true; 976 shutting_down_ = true;
949 *exit_code_out_ = exit_code; 977 *exit_code_out_ = exit_code;
950 if (host_) { 978 if (host_) {
951 host_->Shutdown(base::Bind(&HostProcess::ShutdownOnNetworkThread, this)); 979 host_->Shutdown(base::Bind(&HostProcess::ShutdownOnNetworkThread, this));
952 } else { 980 } else {
953 ShutdownOnNetworkThread(); 981 ShutdownOnNetworkThread();
954 } 982 }
955 } 983 }
956 984
957 void HostProcess::ShutdownOnNetworkThread() { 985 void HostProcess::ShutdownOnNetworkThread() {
958 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 986 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
959 987
960 // Destroy networking objects while we are on the network thread. 988 // Destroy networking objects while we are on the network thread.
961 host_ = NULL; 989 host_ = NULL;
962 ResetHost(); 990 ResetHost();
963 991
964 if (policy_watcher_.get()) { 992 if (policy_watcher_.get()) {
965 base::WaitableEvent done_event(true, false); 993 base::WaitableEvent done_event(true, false);
966 policy_watcher_->StopWatching(&done_event); 994 policy_watcher_->StopWatching(&done_event);
967 done_event.Wait(); 995 done_event.Wait();
968 policy_watcher_.reset(); 996 policy_watcher_.reset();
969 } 997 }
970 998
999 status_service_.reset();
1000
971 // Complete the rest of shutdown on the main thread. 1001 // Complete the rest of shutdown on the main thread.
972 context_->ui_task_runner()->PostTask(FROM_HERE, 1002 context_->ui_task_runner()->PostTask(FROM_HERE,
973 base::Bind(&HostProcess::ShutdownOnUiThread, this)); 1003 base::Bind(&HostProcess::ShutdownOnUiThread, this));
974 } 1004 }
975 1005
976 void HostProcess::ResetHost() { 1006 void HostProcess::ResetHost() {
977 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 1007 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
978 1008
979 curtaining_host_observer_.reset(); 1009 curtaining_host_observer_.reset();
980 host_event_logger_.reset(); 1010 host_event_logger_.reset();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 user32.GetFunctionPointer("SetProcessDPIAware")); 1111 user32.GetFunctionPointer("SetProcessDPIAware"));
1082 set_process_dpi_aware(); 1112 set_process_dpi_aware();
1083 } 1113 }
1084 1114
1085 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting 1115 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
1086 // the command line from GetCommandLineW(), so we can safely pass NULL here. 1116 // the command line from GetCommandLineW(), so we can safely pass NULL here.
1087 return main(0, NULL); 1117 return main(0, NULL);
1088 } 1118 }
1089 1119
1090 #endif // defined(OS_WIN) 1120 #endif // defined(OS_WIN)
OLDNEW
« no previous file with comments | « remoting/host/host_status_service.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698