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

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, 1 month 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
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 30 matching lines...) Expand all
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
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
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
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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 // If an audio pipe is specific on the command-line then initialize 495 // If an audio pipe is specific on the command-line then initialize
487 // AudioCapturerLinux to capture from it. 496 // AudioCapturerLinux to capture from it.
488 FilePath audio_pipe_name = CommandLine::ForCurrentProcess()-> 497 FilePath audio_pipe_name = CommandLine::ForCurrentProcess()->
489 GetSwitchValuePath(kAudioPipeSwitchName); 498 GetSwitchValuePath(kAudioPipeSwitchName);
490 if (!audio_pipe_name.empty()) { 499 if (!audio_pipe_name.empty()) {
491 remoting::AudioCapturerLinux::InitializePipeReader( 500 remoting::AudioCapturerLinux::InitializePipeReader(
492 context_->audio_task_runner(), audio_pipe_name); 501 context_->audio_task_runner(), audio_pipe_name);
493 } 502 }
494 #endif // defined(OS_LINUX) 503 #endif // defined(OS_LINUX)
495 504
505 if (CommandLine::ForCurrentProcess()->HasSwitch(
506 kEnableStatusServiceSwitchName)) {
507 context_->network_task_runner()->PostTask(
508 FROM_HERE,
509 base::Bind(&HostProcess::StartHostStatusService,
510 base::Unretained(this)));
511 }
512
496 // Create a desktop environment factory appropriate to the build type & 513 // Create a desktop environment factory appropriate to the build type &
497 // platform. 514 // platform.
498 #if defined(OS_WIN) 515 #if defined(OS_WIN)
499 516
500 #if defined(REMOTING_MULTI_PROCESS) 517 #if defined(REMOTING_MULTI_PROCESS)
501 IpcDesktopEnvironmentFactory* desktop_environment_factory = 518 IpcDesktopEnvironmentFactory* desktop_environment_factory =
502 new IpcDesktopEnvironmentFactory( 519 new IpcDesktopEnvironmentFactory(
503 daemon_channel_.get(), 520 daemon_channel_.get(),
504 context_->input_task_runner(), 521 context_->input_task_runner(),
505 context_->network_task_runner(), 522 context_->network_task_runner(),
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 756 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
740 757
741 if (talkgadget_prefix != talkgadget_prefix_) { 758 if (talkgadget_prefix != talkgadget_prefix_) {
742 LOG(INFO) << "Updated talkgadget policy."; 759 LOG(INFO) << "Updated talkgadget policy.";
743 talkgadget_prefix_ = talkgadget_prefix; 760 talkgadget_prefix_ = talkgadget_prefix;
744 return true; 761 return true;
745 } 762 }
746 return false; 763 return false;
747 } 764 }
748 765
766 void HostProcess::StartHostStatusService() {
767 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
768 status_service_.reset(new HostStatusService());
769 }
770
749 void HostProcess::StartHost() { 771 void HostProcess::StartHost() {
750 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 772 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
751 DCHECK(!host_); 773 DCHECK(!host_);
752 DCHECK(!signal_strategy_.get()); 774 DCHECK(!signal_strategy_.get());
753 775
754 if (shutting_down_) 776 if (shutting_down_)
755 return; 777 return;
756 778
757 signal_strategy_.reset( 779 signal_strategy_.reset(
758 new XmppSignalStrategy(context_->url_request_context_getter(), 780 new XmppSignalStrategy(context_->url_request_context_getter(),
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 // so it's disabled until we've had time to fully investigate. 841 // so it's disabled until we've had time to fully investigate.
820 // curtaining_host_observer_.reset(new CurtainingHostObserver( 842 // curtaining_host_observer_.reset(new CurtainingHostObserver(
821 // curtain_.get(), host_)); 843 // curtain_.get(), host_));
822 844
823 if (host_user_interface_.get()) { 845 if (host_user_interface_.get()) {
824 host_user_interface_->Start( 846 host_user_interface_->Start(
825 host_, base::Bind(&HostProcess::OnDisconnectRequested, 847 host_, base::Bind(&HostProcess::OnDisconnectRequested,
826 base::Unretained(this))); 848 base::Unretained(this)));
827 } 849 }
828 850
851 if (status_service_)
852 status_service_->SetState(true, host_id_);
853
829 host_->Start(xmpp_login_); 854 host_->Start(xmpp_login_);
830 855
831 CreateAuthenticatorFactory(); 856 CreateAuthenticatorFactory();
832 } 857 }
833 858
834 void HostProcess::OnAuthFailed() { 859 void HostProcess::OnAuthFailed() {
835 Shutdown(kInvalidOauthCredentialsExitCode); 860 Shutdown(kInvalidOauthCredentialsExitCode);
836 } 861 }
837 862
838 void HostProcess::RejectAuthenticatingClient() { 863 void HostProcess::RejectAuthenticatingClient() {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 902
878 StartHost(); 903 StartHost();
879 } 904 }
880 905
881 void HostProcess::Shutdown(int exit_code) { 906 void HostProcess::Shutdown(int exit_code) {
882 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 907 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
883 908
884 if (shutting_down_) 909 if (shutting_down_)
885 return; 910 return;
886 911
912 if (status_service_)
913 status_service_->SetState(false, "");
alexeypa (please no reviews) 2012/11/15 19:45:56 nit: It may be worth splitting SetState into two s
Sergey Ulanov 2012/11/16 00:52:10 Done.
914
887 shutting_down_ = true; 915 shutting_down_ = true;
888 exit_code_ = exit_code; 916 exit_code_ = exit_code;
889 if (host_) { 917 if (host_) {
890 host_->Shutdown(base::Bind( 918 host_->Shutdown(base::Bind(
891 &HostProcess::OnShutdownFinished, base::Unretained(this))); 919 &HostProcess::OnShutdownFinished, base::Unretained(this)));
892 } else { 920 } else {
893 OnShutdownFinished(); 921 OnShutdownFinished();
894 } 922 }
895 } 923 }
896 924
897 void HostProcess::OnShutdownFinished() { 925 void HostProcess::OnShutdownFinished() {
898 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 926 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
899 927
900 // Destroy networking objects while we are on the network thread. 928 // Destroy networking objects while we are on the network thread.
901 host_ = NULL; 929 host_ = NULL;
902 ResetHost(); 930 ResetHost();
903 931
904 if (policy_watcher_.get()) { 932 if (policy_watcher_.get()) {
905 base::WaitableEvent done_event(true, false); 933 base::WaitableEvent done_event(true, false);
906 policy_watcher_->StopWatching(&done_event); 934 policy_watcher_->StopWatching(&done_event);
907 done_event.Wait(); 935 done_event.Wait();
908 policy_watcher_.reset(); 936 policy_watcher_.reset();
909 } 937 }
910 938
939 status_service_.reset();
940
911 // Complete the rest of shutdown on the main thread. 941 // Complete the rest of shutdown on the main thread.
912 context_->ui_task_runner()->PostTask( 942 context_->ui_task_runner()->PostTask(
913 FROM_HERE, 943 FROM_HERE,
914 base::Bind(&HostProcess::ShutdownHostProcess, 944 base::Bind(&HostProcess::ShutdownHostProcess,
915 base::Unretained(this))); 945 base::Unretained(this)));
916 } 946 }
917 947
918 void HostProcess::ResetHost() { 948 void HostProcess::ResetHost() {
919 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 949 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
920 950
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 user32.GetFunctionPointer("SetProcessDPIAware")); 1048 user32.GetFunctionPointer("SetProcessDPIAware"));
1019 set_process_dpi_aware(); 1049 set_process_dpi_aware();
1020 } 1050 }
1021 1051
1022 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting 1052 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
1023 // the command line from GetCommandLineW(), so we can safely pass NULL here. 1053 // the command line from GetCommandLineW(), so we can safely pass NULL here.
1024 return main(0, NULL); 1054 return main(0, NULL);
1025 } 1055 }
1026 1056
1027 #endif // defined(OS_WIN) 1057 #endif // defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698