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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 scoped_ptr<CurtainingHostObserver> curtaining_host_observer_; | 268 scoped_ptr<CurtainingHostObserver> curtaining_host_observer_; |
269 bool curtain_required_; | 269 bool curtain_required_; |
270 | 270 |
271 scoped_ptr<XmppSignalStrategy> signal_strategy_; | 271 scoped_ptr<XmppSignalStrategy> signal_strategy_; |
272 scoped_ptr<SignalingConnector> signaling_connector_; | 272 scoped_ptr<SignalingConnector> signaling_connector_; |
273 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 273 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
274 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; | 274 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; |
275 scoped_ptr<LogToServer> log_to_server_; | 275 scoped_ptr<LogToServer> log_to_server_; |
276 scoped_ptr<HostEventLogger> host_event_logger_; | 276 scoped_ptr<HostEventLogger> host_event_logger_; |
277 | 277 |
278 scoped_refptr<ChromotingHost> host_; | 278 scoped_ptr<ChromotingHost> host_; |
279 | 279 |
280 // Used to keep this HostProcess alive until it is shutdown. | 280 // Used to keep this HostProcess alive until it is shutdown. |
281 scoped_refptr<HostProcess> self_; | 281 scoped_refptr<HostProcess> self_; |
282 | 282 |
283 #if defined(REMOTING_MULTI_PROCESS) | 283 #if defined(REMOTING_MULTI_PROCESS) |
284 DesktopSessionConnector* desktop_session_connector_; | 284 DesktopSessionConnector* desktop_session_connector_; |
285 #endif // defined(REMOTING_MULTI_PROCESS) | 285 #endif // defined(REMOTING_MULTI_PROCESS) |
286 | 286 |
287 int* exit_code_out_; | 287 int* exit_code_out_; |
288 }; | 288 }; |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 | 876 |
877 NetworkSettings network_settings( | 877 NetworkSettings network_settings( |
878 allow_nat_traversal_ ? | 878 allow_nat_traversal_ ? |
879 NetworkSettings::NAT_TRAVERSAL_ENABLED : | 879 NetworkSettings::NAT_TRAVERSAL_ENABLED : |
880 NetworkSettings::NAT_TRAVERSAL_DISABLED); | 880 NetworkSettings::NAT_TRAVERSAL_DISABLED); |
881 if (!allow_nat_traversal_) { | 881 if (!allow_nat_traversal_) { |
882 network_settings.min_port = NetworkSettings::kDefaultMinPort; | 882 network_settings.min_port = NetworkSettings::kDefaultMinPort; |
883 network_settings.max_port = NetworkSettings::kDefaultMaxPort; | 883 network_settings.max_port = NetworkSettings::kDefaultMaxPort; |
884 } | 884 } |
885 | 885 |
886 host_ = new ChromotingHost( | 886 host_.reset(new ChromotingHost( |
887 signal_strategy_.get(), | 887 signal_strategy_.get(), |
888 desktop_environment_factory_.get(), | 888 desktop_environment_factory_.get(), |
889 CreateHostSessionManager(network_settings, | 889 CreateHostSessionManager(network_settings, |
890 context_->url_request_context_getter()), | 890 context_->url_request_context_getter()), |
891 context_->audio_task_runner(), | 891 context_->audio_task_runner(), |
892 context_->input_task_runner(), | 892 context_->input_task_runner(), |
893 context_->video_capture_task_runner(), | 893 context_->video_capture_task_runner(), |
894 context_->video_encode_task_runner(), | 894 context_->video_encode_task_runner(), |
895 context_->network_task_runner(), | 895 context_->network_task_runner(), |
896 context_->ui_task_runner()); | 896 context_->ui_task_runner())); |
897 | 897 |
898 // TODO(simonmorris): Get the maximum session duration from a policy. | 898 // TODO(simonmorris): Get the maximum session duration from a policy. |
899 #if defined(OS_LINUX) | 899 #if defined(OS_LINUX) |
900 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); | 900 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); |
901 #endif | 901 #endif |
902 | 902 |
903 heartbeat_sender_.reset(new HeartbeatSender( | 903 heartbeat_sender_.reset(new HeartbeatSender( |
904 this, host_id_, signal_strategy_.get(), key_pair_, | 904 this, host_id_, signal_strategy_.get(), key_pair_, |
905 directory_bot_jid_)); | 905 directory_bot_jid_)); |
906 | 906 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 if (host_) { | 967 if (host_) { |
968 host_->DisconnectAllClients(); | 968 host_->DisconnectAllClients(); |
969 } | 969 } |
970 } | 970 } |
971 | 971 |
972 void HostProcess::RestartHost() { | 972 void HostProcess::RestartHost() { |
973 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 973 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
974 DCHECK_EQ(state_, HOST_STARTED); | 974 DCHECK_EQ(state_, HOST_STARTED); |
975 | 975 |
976 state_ = HOST_STOPPING_TO_RESTART; | 976 state_ = HOST_STOPPING_TO_RESTART; |
977 host_->Shutdown(base::Bind(&HostProcess::ShutdownOnNetworkThread, this)); | 977 ShutdownOnNetworkThread(); |
978 } | 978 } |
979 | 979 |
980 void HostProcess::ShutdownHost(int exit_code) { | 980 void HostProcess::ShutdownHost(int exit_code) { |
981 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 981 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
982 | 982 |
983 *exit_code_out_ = exit_code; | 983 *exit_code_out_ = exit_code; |
984 | 984 |
985 switch (state_) { | 985 switch (state_) { |
986 case HOST_INITIALIZING: | 986 case HOST_INITIALIZING: |
987 state_ = HOST_STOPPING; | 987 state_ = HOST_STOPPING; |
988 ShutdownOnNetworkThread(); | 988 ShutdownOnNetworkThread(); |
989 break; | 989 break; |
990 | 990 |
991 case HOST_STARTED: | 991 case HOST_STARTED: |
992 state_ = HOST_STOPPING; | 992 state_ = HOST_STOPPING; |
993 host_->Shutdown(base::Bind(&HostProcess::ShutdownOnNetworkThread, this)); | 993 ShutdownOnNetworkThread(); |
994 break; | 994 break; |
995 | 995 |
996 case HOST_STOPPING_TO_RESTART: | 996 case HOST_STOPPING_TO_RESTART: |
997 state_ = HOST_STOPPING; | 997 state_ = HOST_STOPPING; |
998 break; | 998 break; |
999 | 999 |
1000 case HOST_STOPPING: | 1000 case HOST_STOPPING: |
1001 case HOST_STOPPED: | 1001 case HOST_STOPPED: |
1002 // Host is already stopped or being stopped. No action is required. | 1002 // Host is already stopped or being stopped. No action is required. |
1003 break; | 1003 break; |
1004 } | 1004 } |
1005 } | 1005 } |
1006 | 1006 |
1007 void HostProcess::ShutdownOnNetworkThread() { | 1007 void HostProcess::ShutdownOnNetworkThread() { |
1008 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 1008 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
1009 | 1009 |
1010 host_ = NULL; | 1010 if (host_) { |
| 1011 host_->Shutdown(); |
| 1012 host_.reset(); |
| 1013 } |
| 1014 |
1011 curtaining_host_observer_.reset(); | 1015 curtaining_host_observer_.reset(); |
1012 host_event_logger_.reset(); | 1016 host_event_logger_.reset(); |
1013 log_to_server_.reset(); | 1017 log_to_server_.reset(); |
1014 heartbeat_sender_.reset(); | 1018 heartbeat_sender_.reset(); |
1015 host_change_notification_listener_.reset(); | 1019 host_change_notification_listener_.reset(); |
1016 signaling_connector_.reset(); | 1020 signaling_connector_.reset(); |
1017 signal_strategy_.reset(); | 1021 signal_strategy_.reset(); |
1018 network_change_notifier_.reset(); | 1022 network_change_notifier_.reset(); |
1019 | 1023 |
1020 if (state_ == HOST_STOPPING_TO_RESTART) { | 1024 if (state_ == HOST_STOPPING_TO_RESTART) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 return exit_code; | 1092 return exit_code; |
1089 } | 1093 } |
1090 | 1094 |
1091 } // namespace remoting | 1095 } // namespace remoting |
1092 | 1096 |
1093 #if !defined(OS_WIN) | 1097 #if !defined(OS_WIN) |
1094 int main(int argc, char** argv) { | 1098 int main(int argc, char** argv) { |
1095 return remoting::HostMain(argc, argv); | 1099 return remoting::HostMain(argc, argv); |
1096 } | 1100 } |
1097 #endif // !defined(OS_WIN) | 1101 #endif // !defined(OS_WIN) |
OLD | NEW |