| Index: remoting/host/plugin/host_script_object.cc
|
| diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc
|
| index 1f83dcde3c6b5cac3e911324757c444b62f31c6a..b905d3d2e7ba7a9314d486843ccb9ad98b64d8c5 100644
|
| --- a/remoting/host/plugin/host_script_object.cc
|
| +++ b/remoting/host/plugin/host_script_object.cc
|
| @@ -15,6 +15,7 @@
|
| #include "base/utf_string_conversions.h"
|
| #include "base/values.h"
|
| #include "net/base/net_util.h"
|
| +#include "remoting/base/auto_thread_task_runner.h"
|
| #include "remoting/base/auth_token_util.h"
|
| #include "remoting/host/chromoting_host.h"
|
| #include "remoting/host/chromoting_host_context.h"
|
| @@ -121,9 +122,7 @@ HostNPScriptObject::~HostNPScriptObject() {
|
| // here because |host_context_| needs to be stopped on the plugin
|
| // thread, but the plugin thread may not exist after the instance
|
| // is destroyed.
|
| - disconnected_event_.Reset();
|
| DisconnectInternal();
|
| - disconnected_event_.Wait();
|
|
|
| // UI needs to be shut down on the UI thread before we destroy the
|
| // host context (because it depends on the context object), but
|
| @@ -134,6 +133,10 @@ HostNPScriptObject::~HostNPScriptObject() {
|
|
|
| // Stops all threads.
|
| host_context_.reset();
|
| +
|
| + // |disconnected_event_| is signalled when the last reference to the plugin
|
| + // thread is dropped.
|
| + disconnected_event_.Wait();
|
| }
|
|
|
| worker_thread_.Stop();
|
| @@ -143,7 +146,10 @@ bool HostNPScriptObject::Init() {
|
| DCHECK(plugin_task_runner_->BelongsToCurrentThread());
|
| VLOG(2) << "Init";
|
|
|
| - host_context_.reset(new ChromotingHostContext(plugin_task_runner_));
|
| + host_context_.reset(new ChromotingHostContext(new AutoThreadTaskRunner(
|
| + plugin_task_runner_,
|
| + base::Bind(&base::WaitableEvent::Signal,
|
| + base::Unretained(&disconnected_event_)))));
|
| if (!host_context_->Start()) {
|
| host_context_.reset();
|
| return false;
|
| @@ -871,13 +877,12 @@ void HostNPScriptObject::DisconnectInternal() {
|
|
|
| switch (state_) {
|
| case kDisconnected:
|
| - disconnected_event_.Signal();
|
| return;
|
|
|
| case kStarting:
|
| + desktop_environment_.reset();
|
| SetState(kDisconnecting);
|
| SetState(kDisconnected);
|
| - disconnected_event_.Signal();
|
| return;
|
|
|
| case kDisconnecting:
|
| @@ -906,7 +911,7 @@ void HostNPScriptObject::DisconnectInternal() {
|
| void HostNPScriptObject::OnShutdownFinished() {
|
| DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread());
|
|
|
| - disconnected_event_.Signal();
|
| + desktop_environment_.reset();
|
| }
|
|
|
| void HostNPScriptObject::OnPolicyUpdate(
|
|
|