diff options
author | weitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-04 05:35:55 +0000 |
---|---|---|
committer | weitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-04 05:35:55 +0000 |
commit | 06e6fc566ae16c4414a30658e8e2f758dab0596c (patch) | |
tree | 261265c08639cd02b31839c9ac603593539ebf83 /remoting | |
parent | a2f654b714e904cda66db41430d36084dd6b6a81 (diff) | |
download | chromium_src-06e6fc566ae16c4414a30658e8e2f758dab0596c.zip chromium_src-06e6fc566ae16c4414a30658e8e2f758dab0596c.tar.gz chromium_src-06e6fc566ae16c4414a30658e8e2f758dab0596c.tar.bz2 |
Shut down the elevated native messaging host process after 5 minutes.
BUG=347784
Review URL: https://codereview.chromium.org/184893004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254673 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/setup/me2me_native_messaging_host.cc | 12 | ||||
-rw-r--r-- | remoting/host/setup/me2me_native_messaging_host.h | 7 |
2 files changed, 19 insertions, 0 deletions
diff --git a/remoting/host/setup/me2me_native_messaging_host.cc b/remoting/host/setup/me2me_native_messaging_host.cc index 02374ef..c248aef 100644 --- a/remoting/host/setup/me2me_native_messaging_host.cc +++ b/remoting/host/setup/me2me_native_messaging_host.cc @@ -38,6 +38,7 @@ namespace { const DWORD kBufferSize = 0; const int kTimeOutMilliseconds = 2000; const char kChromePipeNamePrefix[] = "\\\\.\\pipe\\chrome_remote_desktop."; +const int kElevatedHostTimeoutSeconds = 300; #endif // defined(OS_WIN) // redirect_uri to use when authenticating service accounts (service account @@ -662,6 +663,10 @@ void Me2MeNativeMessagingHost::EnsureElevatedHostCreated() { elevated_channel_->Start( base::Bind(&Me2MeNativeMessagingHost::ProcessDelegateResponse, weak_ptr_), base::Bind(&Me2MeNativeMessagingHost::Stop, weak_ptr_)); + + elevated_host_timer_.Start( + FROM_HERE, base::TimeDelta::FromSeconds(kElevatedHostTimeoutSeconds), + this, &Me2MeNativeMessagingHost::DisconnectElevatedHost); } void Me2MeNativeMessagingHost::ProcessDelegateResponse( @@ -672,6 +677,13 @@ void Me2MeNativeMessagingHost::ProcessDelegateResponse( channel_->SendMessage(message.Pass()); } +void Me2MeNativeMessagingHost::DisconnectElevatedHost() { + DCHECK(thread_checker_.CalledOnValidThread()); + + // This will send an EOF to the elevated host, triggering its shutdown. + elevated_channel_.reset(); +} + #else // defined(OS_WIN) bool Me2MeNativeMessagingHost::DelegateToElevatedHost( diff --git a/remoting/host/setup/me2me_native_messaging_host.h b/remoting/host/setup/me2me_native_messaging_host.h index 8f242c2..1a7ac45 100644 --- a/remoting/host/setup/me2me_native_messaging_host.h +++ b/remoting/host/setup/me2me_native_messaging_host.h @@ -9,6 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/threading/thread_checker.h" +#include "base/timer/timer.h" #include "remoting/host/native_messaging/native_messaging_channel.h" #include "remoting/host/setup/daemon_controller.h" #include "remoting/host/setup/oauth_client.h" @@ -138,8 +139,14 @@ class Me2MeNativeMessagingHost { // |elevated_channel_|. void ProcessDelegateResponse(scoped_ptr<base::DictionaryValue> message); + // Disconnect and shut down the elevated host. + void DisconnectElevatedHost(); + // Native messaging channel used to communicate with the elevated host. scoped_ptr<NativeMessagingChannel> elevated_channel_; + + // Timer to control the lifetime of the elevated host. + base::OneShotTimer<Me2MeNativeMessagingHost> elevated_host_timer_; #endif // defined(OS_WIN) bool needs_elevation_; |