summaryrefslogtreecommitdiffstats
path: root/remoting/host/plugin/host_script_object.cc
diff options
context:
space:
mode:
authortimurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-29 10:23:55 +0000
committertimurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-29 10:23:55 +0000
commitf6caf151551030c83dbc635879d89d28f486d0d5 (patch)
treec3c3c460be8cafd8f74de932b4af7102d496eb3d /remoting/host/plugin/host_script_object.cc
parent945d760ecb2aea40a9591447ffa42f3c9cadf84b (diff)
downloadchromium_src-f6caf151551030c83dbc635879d89d28f486d0d5.zip
chromium_src-f6caf151551030c83dbc635879d89d28f486d0d5.tar.gz
chromium_src-f6caf151551030c83dbc635879d89d28f486d0d5.tar.bz2
Revert 170150 - Use AutoThread in ChromotingHostContext & NPAPI plugin.
This has caused leak and data race reports on the MFYI waterfall, i.e. still needs work. BUG=163320 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. BUG=145856 Review URL: https://chromiumcodereview.appspot.com/11094056 TBR=wez@chromium.org Review URL: https://codereview.chromium.org/11316242 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170156 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/plugin/host_script_object.cc')
-rw-r--r--remoting/host/plugin/host_script_object.cc18
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;