| 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
|
|
|