diff options
author | Andras Becsi <andras.becsi@digia.com> | 2013-12-11 21:33:03 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@digia.com> | 2013-12-13 12:34:07 +0100 |
commit | f2a33ff9cbc6d19943f1c7fbddd1f23d23975577 (patch) | |
tree | 0586a32aa390ade8557dfd6b4897f43a07449578 /chromium/content/utility | |
parent | 5362912cdb5eea702b68ebe23702468d17c3017a (diff) | |
download | qtwebengine-chromium-f2a33ff9cbc6d19943f1c7fbddd1f23d23975577.tar.gz |
Update Chromium to branch 1650 (31.0.1650.63)
Change-Id: I57d8c832eaec1eb2364e0a8e7352a6dd354db99f
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'chromium/content/utility')
-rw-r--r-- | chromium/content/utility/in_process_utility_thread.cc | 51 | ||||
-rw-r--r-- | chromium/content/utility/in_process_utility_thread.h | 40 |
2 files changed, 91 insertions, 0 deletions
diff --git a/chromium/content/utility/in_process_utility_thread.cc b/chromium/content/utility/in_process_utility_thread.cc new file mode 100644 index 00000000000..8859e518216 --- /dev/null +++ b/chromium/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 diff --git a/chromium/content/utility/in_process_utility_thread.h b/chromium/content/utility/in_process_utility_thread.h new file mode 100644 index 00000000000..7f4c732667b --- /dev/null +++ b/chromium/content/utility/in_process_utility_thread.h @@ -0,0 +1,40 @@ +// 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. + +#ifndef CONTENT_UTILITY_IN_PROCESS_UTILITY_THREAD_H_ +#define CONTENT_UTILITY_IN_PROCESS_UTILITY_THREAD_H_ + +#include <string> + +#include "base/threading/thread.h" +#include "content/common/content_export.h" + +namespace content { + +class ChildProcess; + +class InProcessUtilityThread : public base::Thread { + public: + InProcessUtilityThread(const std::string& channel_id); + virtual ~InProcessUtilityThread(); + + private: + // base::Thread implementation: + virtual void Init() OVERRIDE; + virtual void CleanUp() OVERRIDE; + + void InitInternal(); + + std::string channel_id_; + scoped_ptr<ChildProcess> child_process_; + + DISALLOW_COPY_AND_ASSIGN(InProcessUtilityThread); +}; + +CONTENT_EXPORT base::Thread* CreateInProcessUtilityThread( + const std::string& channel_id); + +} // namespace content + +#endif // CONTENT_UTILITY_IN_PROCESS_UTILITY_THREAD_H_ |