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

Unified Diff: remoting/host/remoting_me2me_host.cc

Issue 18075003: Host offline status reporting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/host_status_sender_unittest.cc ('k') | remoting/host/server_log_entry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..91b4606a32fc2e7c92bd2d1ac19f0ef68925c778 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"
@@ -221,7 +222,9 @@ class HostProcess
void RestartHost();
// Stops the host and shuts down the process with the specified |exit_code|.
- void ShutdownHost(int exit_code);
+ void ShutdownHost(HostExitCodes exit_code);
+
+ void ScheduleHostShutdown();
void ShutdownOnNetworkThread();
@@ -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_));
@@ -990,7 +997,7 @@ void HostProcess::RestartHost() {
ShutdownOnNetworkThread();
}
-void HostProcess::ShutdownHost(int exit_code) {
+void HostProcess::ShutdownHost(HostExitCodes exit_code) {
DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
*exit_code_out_ = exit_code;
@@ -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();
« no previous file with comments | « remoting/host/host_status_sender_unittest.cc ('k') | remoting/host/server_log_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698