diff options
author | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-30 23:28:10 +0000 |
---|---|---|
committer | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-30 23:28:10 +0000 |
commit | 15955ba79d13c089afa37ff255e031574a8150e9 (patch) | |
tree | 60784a1016ff31b3906d263251ced5270780a717 /remoting/host/plugin/host_script_object.cc | |
parent | 97e3f850ea57773864ed85b4e7e2c71fa8a90c45 (diff) | |
download | chromium_src-15955ba79d13c089afa37ff255e031574a8150e9.zip chromium_src-15955ba79d13c089afa37ff255e031574a8150e9.tar.gz chromium_src-15955ba79d13c089afa37ff255e031574a8150e9.tar.bz2 |
Revert 170360
> Use AutoThread in ChromotingHostContext & NPAPI plugin.
>
> Callers now create ChromotingHostContext to create a set of threads
> for host tasks to run on, and pass the threads' TaskRunners to each
> host component explicitly. The ChromotingHostContext can then be
> torn down as soon as the caller no longer needs to create new
> components using the threads, and the threads themselves will exit
> only when the created components no longer require them.
>
> This is a re-land of 11094056, which failed on the valgrind & Windows TSan bots due to ChromotingHostContext.StartAndStop not running its message loop to allow the context's threads join tasks to execute.
>
> TBR=alexeypa
>
> Review URL: https://chromiumcodereview.appspot.com/11316247
TBR=wez@chromium.org
Review URL: https://codereview.chromium.org/11419265
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170591 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/plugin/host_script_object.cc')
-rw-r--r-- | remoting/host/plugin/host_script_object.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc index f7d84e7..7b82603 100644 --- a/remoting/host/plugin/host_script_object.cc +++ b/remoting/host/plugin/host_script_object.cc @@ -15,8 +15,8 @@ #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/base/auto_thread.h" #include "remoting/host/chromoting_host.h" #include "remoting/host/chromoting_host_context.h" #include "remoting/host/desktop_environment_factory.h" @@ -666,13 +666,12 @@ HostNPScriptObject::HostNPScriptObject( am_currently_logging_(false), state_(kDisconnected), daemon_controller_(DaemonController::Create()), + worker_thread_("RemotingHostPlugin"), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), weak_ptr_(weak_factory_.GetWeakPtr()) { DCHECK(plugin_task_runner_->BelongsToCurrentThread()); - // Create worker thread for encryption key generation. - worker_thread_ = AutoThread::Create("ChromotingWorkerThread", - plugin_task_runner_); + worker_thread_.Start(); } HostNPScriptObject::~HostNPScriptObject() { @@ -685,6 +684,9 @@ HostNPScriptObject::~HostNPScriptObject() { it2me_impl_->Disconnect(); it2me_impl_ = NULL; } + + // Stop the worker thread. + worker_thread_.Stop(); } bool HostNPScriptObject::HasMethod(const std::string& method_name) { @@ -953,9 +955,9 @@ bool HostNPScriptObject::Connect(const NPVariant* args, } // Create threads for the Chromoting host & desktop environment to use. - scoped_ptr<ChromotingHostContext> host_context = - ChromotingHostContext::Create(plugin_task_runner_); - if (host_context) { + scoped_ptr<ChromotingHostContext> host_context( + new ChromotingHostContext(plugin_task_runner_)); + if (!host_context->Start()) { SetException("connect: failed to start threads"); return false; } @@ -1058,7 +1060,7 @@ bool HostNPScriptObject::GenerateKeyPair(const NPVariant* args, // TODO(wez): HostNPScriptObject needn't be touched on worker // thread, so make DoGenerateKeyPair static and pass it a callback // to run (crbug.com/156257). - worker_thread_->PostTask( + worker_thread_.message_loop_proxy()->PostTask( FROM_HERE, base::Bind(&HostNPScriptObject::DoGenerateKeyPair, base::Unretained(this), callback_obj)); return true; |