summaryrefslogtreecommitdiffstats
path: root/content/utility/in_process_utility_thread.cc
diff options
context:
space:
mode:
authorscottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-04 16:41:30 +0000
committerscottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-04 16:41:30 +0000
commit8707caab1cf84a32152b86a955b536a46cb6cdd1 (patch)
tree8b49b2f963802e1ac4719437556cfa69d0f697cc /content/utility/in_process_utility_thread.cc
parent70f5332e3042f489cb19e77e232a2cf347202b31 (diff)
downloadchromium_src-8707caab1cf84a32152b86a955b536a46cb6cdd1.zip
chromium_src-8707caab1cf84a32152b86a955b536a46cb6cdd1.tar.gz
chromium_src-8707caab1cf84a32152b86a955b536a46cb6cdd1.tar.bz2
Fix names of in-process threads, tidy gpu DEPS
Follow-up after http://crrev.com/217968 per comments on https://chromiumcodereview.appspot.com/23235002/ R=jam@chromium.org BUG=237249 Review URL: https://chromiumcodereview.appspot.com/23452016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221199 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/utility/in_process_utility_thread.cc')
-rw-r--r--content/utility/in_process_utility_thread.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/content/utility/in_process_utility_thread.cc b/content/utility/in_process_utility_thread.cc
new file mode 100644
index 0000000..8859e51
--- /dev/null
+++ b/content/utility/in_process_utility_thread.cc
@@ -0,0 +1,51 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/utility/in_process_utility_thread.h"
+
+#include "content/child/child_process.h"
+#include "content/utility/utility_thread_impl.h"
+
+namespace content {
+
+// We want to ensure there's only one utility thread running at a time, as there
+// are many globals used in the utility process.
+static base::LazyInstance<base::Lock> g_one_utility_thread_lock;
+
+InProcessUtilityThread::InProcessUtilityThread(const std::string& channel_id)
+ : Thread("Chrome_InProcUtilityThread"), channel_id_(channel_id) {
+}
+
+InProcessUtilityThread::~InProcessUtilityThread() {
+ Stop();
+}
+
+void InProcessUtilityThread::Init() {
+ // We need to return right away or else the main thread that started us will
+ // hang.
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&InProcessUtilityThread::InitInternal,
+ base::Unretained(this)));
+}
+
+void InProcessUtilityThread::CleanUp() {
+ child_process_.reset();
+
+ // See comment in RendererMainThread.
+ SetThreadWasQuitProperly(true);
+ g_one_utility_thread_lock.Get().Release();
+}
+
+void InProcessUtilityThread::InitInternal() {
+ g_one_utility_thread_lock.Get().Acquire();
+ child_process_.reset(new ChildProcess());
+ child_process_->set_main_thread(new UtilityThreadImpl(channel_id_));
+}
+
+base::Thread* CreateInProcessUtilityThread(const std::string& channel_id) {
+ return new InProcessUtilityThread(channel_id);
+}
+
+} // namespace content