summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/setup/me2me_native_messaging_host.cc12
-rw-r--r--remoting/host/setup/me2me_native_messaging_host.h7
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_;