| Index: remoting/host/remoting_me2me_host.cc
|
| diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
|
| index 25a4ef1a45290788dbabf8096c78303e11f37b9c..bcbb336196491ecacb1a400c0507c1053e049004 100644
|
| --- a/remoting/host/remoting_me2me_host.cc
|
| +++ b/remoting/host/remoting_me2me_host.cc
|
| @@ -50,6 +50,7 @@
|
| #include "remoting/host/host_event_logger.h"
|
| #include "remoting/host/host_exit_codes.h"
|
| #include "remoting/host/host_main.h"
|
| +#include "remoting/host/host_status_sender.h"
|
| #include "remoting/host/ipc_constants.h"
|
| #include "remoting/host/ipc_desktop_environment.h"
|
| #include "remoting/host/ipc_host_event_logger.h"
|
| @@ -223,6 +224,8 @@ class HostProcess
|
| // Stops the host and shuts down the process with the specified |exit_code|.
|
| void ShutdownHost(int exit_code);
|
|
|
| + void ScheduleHostShutdown();
|
| +
|
| void ShutdownOnNetworkThread();
|
|
|
| // Crashes the process in response to a daemon's request. The daemon passes
|
| @@ -272,6 +275,7 @@ class HostProcess
|
| scoped_ptr<XmppSignalStrategy> signal_strategy_;
|
| scoped_ptr<SignalingConnector> signaling_connector_;
|
| scoped_ptr<HeartbeatSender> heartbeat_sender_;
|
| + scoped_ptr<HostStatusSender> host_status_sender_;
|
| scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_;
|
| scoped_ptr<LogToServer> log_to_server_;
|
| scoped_ptr<HostEventLogger> host_event_logger_;
|
| @@ -956,6 +960,9 @@ void HostProcess::StartHost() {
|
| this, host_id_, signal_strategy_.get(), key_pair_,
|
| directory_bot_jid_));
|
|
|
| + host_status_sender_.reset(new HostStatusSender(
|
| + host_id_, signal_strategy_.get(), key_pair_, directory_bot_jid_));
|
| +
|
| host_change_notification_listener_.reset(new HostChangeNotificationListener(
|
| this, host_id_, signal_strategy_.get(), directory_bot_jid_));
|
|
|
| @@ -999,7 +1006,8 @@ void HostProcess::ShutdownHost(int exit_code) {
|
| case HOST_INITIALIZING:
|
| case HOST_STARTED:
|
| state_ = HOST_STOPPING;
|
| - ShutdownOnNetworkThread();
|
| + host_status_sender_->SendOfflineStatus(exit_code);
|
| + ScheduleHostShutdown();
|
| break;
|
|
|
| case HOST_STOPPING_TO_RESTART:
|
| @@ -1013,6 +1021,16 @@ void HostProcess::ShutdownHost(int exit_code) {
|
| }
|
| }
|
|
|
| +// TODO(weitaosu): shut down the host once we get an ACK for the offline status
|
| +// XMPP message.
|
| +void HostProcess::ScheduleHostShutdown() {
|
| + // Delay the shutdown by 2 second to allow SendOfflineStatus to complete.
|
| + context_->network_task_runner()->PostDelayedTask(
|
| + FROM_HERE,
|
| + base::Bind(&HostProcess::ShutdownOnNetworkThread, base::Unretained(this)),
|
| + base::TimeDelta::FromSeconds(2));
|
| +}
|
| +
|
| void HostProcess::ShutdownOnNetworkThread() {
|
| DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
|
|
|
| @@ -1020,6 +1038,7 @@ void HostProcess::ShutdownOnNetworkThread() {
|
| host_event_logger_.reset();
|
| log_to_server_.reset();
|
| heartbeat_sender_.reset();
|
| + host_status_sender_.reset();
|
| host_change_notification_listener_.reset();
|
| signaling_connector_.reset();
|
| signal_strategy_.reset();
|
|
|