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

Unified Diff: remoting/host/remoting_me2me_host.cc

Issue 10106013: Chromoting: stopping the service if the host ID is permanently not recognized by the could. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cr feedback. Created 8 years, 8 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
Index: remoting/host/remoting_me2me_host.cc
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index f380056afb27e437f1d868d7faff9107857b3db9..3d800bc8c4f908c0d412843b61b61f6a1486ec63 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -25,6 +25,7 @@
#include "net/base/network_change_notifier.h"
#include "remoting/base/constants.h"
#include "remoting/host/branding.h"
+#include "remoting/host/constants.h"
#include "remoting/host/capturer.h"
#include "remoting/host/chromoting_host.h"
#include "remoting/host/chromoting_host_context.h"
@@ -50,9 +51,6 @@
namespace {
-const int kSuccessExitCode = 0;
-const int kInvalidHostConfigurationExitCode = 1;
-
// This is used for tagging system event logs.
const char kApplicationName[] = "chromoting";
@@ -73,13 +71,16 @@ const int kMaxPortNumber = 12409;
namespace remoting {
-class HostProcess : public OAuthClient::Delegate {
+class HostProcess
+ : public OAuthClient::Delegate,
+ public HeartbeatSender::Delegate {
public:
HostProcess()
: message_loop_(MessageLoop::TYPE_UI),
file_io_thread_("FileIO"),
allow_nat_traversal_(true),
- restarting_(false) {
+ restarting_(false),
+ exit_code_(kSuccessExitCode) {
file_io_thread_.StartWithOptions(
base::Thread::Options(MessageLoop::TYPE_IO, 0));
@@ -164,7 +165,7 @@ class HostProcess : public OAuthClient::Delegate {
#endif
message_loop_.Run();
- return kSuccessExitCode;
+ return exit_code_;
}
// Overridden from OAuthClient::Delegate
@@ -187,6 +188,13 @@ class HostProcess : public OAuthClient::Delegate {
virtual void OnOAuthError() OVERRIDE {
LOG(ERROR) << "OAuth: invalid credentials.";
+ Shutdown(kInvalidOauthCredentialsExitCode);
+ }
+
+ // Overridden from HeartbeatSender::Delegate
+ virtual void OnUnknownHostIdError() OVERRIDE {
+ LOG(ERROR) << "Host ID not found.";
+ Shutdown(kInvalidHostIdExitCode);
}
private:
@@ -306,8 +314,8 @@ class HostProcess : public OAuthClient::Delegate {
context_.get(), signal_strategy_.get(), desktop_environment_.get(),
network_settings);
- heartbeat_sender_.reset(
- new HeartbeatSender(host_id_, signal_strategy_.get(), &key_pair_));
+ heartbeat_sender_.reset(new HeartbeatSender(
+ this, host_id_, signal_strategy_.get(), &key_pair_));
log_to_server_.reset(
new LogToServer(host_, ServerLogEntry::ME2ME, signal_strategy_.get()));
@@ -342,6 +350,11 @@ class HostProcess : public OAuthClient::Delegate {
StartHost();
}
+ void Shutdown(int exit_code) {
+ exit_code_ = exit_code;
+ message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure());
+ }
+
MessageLoop message_loop_;
base::Thread file_io_thread_;
scoped_ptr<ChromotingHostContext> context_;
@@ -372,6 +385,8 @@ class HostProcess : public OAuthClient::Delegate {
scoped_ptr<LogToServer> log_to_server_;
scoped_ptr<HostEventLogger> host_event_logger_;
scoped_refptr<ChromotingHost> host_;
+
+ int exit_code_;
};
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698