Chromium Code Reviews| Index: remoting/host/remoting_me2me_host.cc |
| diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc |
| index 65daa1260e1e6acf705b6c44eb5b6595aa26fdf7..86acb0110d5ed91a95c3905f9e42532b5f2c0a8a 100644 |
| --- a/remoting/host/remoting_me2me_host.cc |
| +++ b/remoting/host/remoting_me2me_host.cc |
| @@ -54,6 +54,11 @@ |
| #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
| #include "remoting/protocol/me2me_host_authenticator_factory.h" |
| +#if defined(OS_POSIX) |
| +#include <signal.h> |
|
alexeypa (please no reviews)
2012/09/05 21:41:25
This one is needed on Mac only.
Jamie
2012/09/06 00:18:50
I don't think that's true. <signal.h> is needed fo
|
| +#include "remoting/host/posix/signal_handler.h" |
|
alexeypa (please no reviews)
2012/09/05 21:41:25
This is used only on Linux.
Jamie
2012/09/06 00:18:50
Ditto.
|
| +#endif // defined(OS_POSIX) |
| + |
| #if defined(OS_MACOSX) |
| #include "base/mac/scoped_cftyperef.h" |
| #include "base/mac/scoped_nsautorelease_pool.h" |
| @@ -151,6 +156,17 @@ class HostProcess |
| return true; |
| } |
| +#if defined(OS_POSIX) |
| + void SigTermHandler(int signum) { |
|
alexeypa (please no reviews)
2012/09/05 21:41:25
This will blow up, if SIGTERM is received when shu
Jamie
2012/09/06 00:18:50
As of the latest revision, this will be called on
Lambros
2012/09/06 00:47:19
nit: signal or signal_number ?
Jamie
2012/09/06 17:31:01
Done.
|
| + DCHECK(signum == SIGTERM); |
| + LOG(INFO) << "Caught SIGTERM: Shutting down..."; |
| + // base::Unretained is safe here because |this| is owned by the thread |
|
alexeypa (please no reviews)
2012/09/05 21:41:25
nit: This comment is not really true. The network
Jamie
2012/09/06 00:18:50
This is no longer an issue with the latest revisio
|
| + // to which we're posting the task. |
| + context_->network_task_runner()->PostTask(FROM_HERE, base::Bind( |
| + &HostProcess::Shutdown, base::Unretained(this), kSuccessExitCode)); |
| + } |
| +#endif |
| + |
| virtual void OnConfigUpdated(const std::string& serialized_config) OVERRIDE { |
| DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); |
| @@ -217,7 +233,7 @@ class HostProcess |
| #if defined(OS_POSIX) |
|
alexeypa (please no reviews)
2012/09/05 21:41:25
Shouldn't it be #if defined(OS_MAC)?
Jamie
2012/09/06 00:18:50
Arguably, it isn't needed on either platform since
alexeypa (please no reviews)
2012/09/06 18:21:09
As per our discussion: either remove this code if
Jamie
2012/09/06 18:32:33
SIGHUP will never be sent to the host process by a
|
| // Ignore SIGHUP sent by the daemon controller since we use |
| - // |ConfigFileWatcher| instead. |
| + // |ConfigFileWatcher| on Mac and read the config from stdin on UNIX. |
|
alexeypa (please no reviews)
2012/09/05 21:41:25
nit: ...on Mac and Windows...
Jamie
2012/09/06 00:18:50
Done.
|
| signal(SIGHUP, SIG_IGN); |
| #endif // defined(OS_POSIX) |
| @@ -229,6 +245,14 @@ class HostProcess |
| #endif // !defined(REMOTING_MULTI_PROCESS) |
| } |
| +#if defined(OS_POSIX) |
| + void ListenForShutdownSignal() { |
| + remoting::RegisterSignalHandler( |
| + SIGTERM, |
| + base::Bind(&HostProcess::SigTermHandler, base::Unretained(this))); |
| + } |
| +#endif // OS_POSIX |
| + |
| void CreateAuthenticatorFactory() { |
| DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| scoped_ptr<protocol::AuthenticatorFactory> factory( |
| @@ -278,6 +302,13 @@ class HostProcess |
| daemon_channel_.reset(); |
| +#if defined(OS_POSIX) |
| + context_->file_task_runner()->PostTask( |
|
alexeypa (please no reviews)
2012/09/05 21:41:25
Why are we doing it in ShutdownHostProcess()? cont
Jamie
2012/09/06 00:18:50
Arguably, it isn't needed on either platform since
|
| + FROM_HERE, |
| + base::Bind(&HostProcess::ListenForShutdownSignal, |
| + base::Unretained(this))); |
| +#endif // OS_POSIX |
| + |
| #if defined(OS_MACOSX) || defined(OS_WIN) |
| host_user_interface_.reset(); |
| #endif |