diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-09 21:12:07 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-09 21:12:07 +0000 |
commit | 6d057a0cd2863c334977475881a230b210f6aa95 (patch) | |
tree | c212fb6e0cdb7fcf8d41ceb9a7217338eca5ac36 /content/utility | |
parent | 4b09e654bbd742f0ec070e662de36de441e373ae (diff) | |
download | chromium_src-6d057a0cd2863c334977475881a230b210f6aa95.zip chromium_src-6d057a0cd2863c334977475881a230b210f6aa95.tar.gz chromium_src-6d057a0cd2863c334977475881a230b210f6aa95.tar.bz2 |
Make utility process run in-process when running in single-process mode.
Remove the unit test/single process code path for SandboxedUnpacker as a first step.
BUG=19192
R=asargent@chromium.org, scottmg@chromium.org
Review URL: https://codereview.chromium.org/18119009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210620 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/utility')
-rw-r--r-- | content/utility/utility_thread_impl.cc | 46 | ||||
-rw-r--r-- | content/utility/utility_thread_impl.h | 7 |
2 files changed, 45 insertions, 8 deletions
diff --git a/content/utility/utility_thread_impl.cc b/content/utility/utility_thread_impl.cc index a69c47a..af6db9d 100644 --- a/content/utility/utility_thread_impl.cc +++ b/content/utility/utility_thread_impl.cc @@ -13,7 +13,9 @@ #include "content/child/webkitplatformsupport_impl.h" #include "content/common/child_process_messages.h" #include "content/common/utility_messages.h" +#include "content/public/common/content_switches.h" #include "content/public/utility/content_utility_client.h" +#include "ipc/ipc_sync_channel.h" #include "third_party/WebKit/public/web/WebKit.h" #include "webkit/plugins/npapi/plugin_list.h" @@ -36,19 +38,22 @@ void ConvertVector(const SRC& src, DEST* dest) { } // namespace -UtilityThreadImpl::UtilityThreadImpl() - : batch_mode_(false) { - ChildProcess::current()->AddRefProcess(); - webkit_platform_support_.reset(new WebKitPlatformSupportImpl); - WebKit::initialize(webkit_platform_support_.get()); - GetContentClient()->utility()->UtilityThreadStarted(); +UtilityThreadImpl::UtilityThreadImpl() : single_process_(false) { + Init(); +} + +UtilityThreadImpl::UtilityThreadImpl(const std::string& channel_name) + : ChildThread(channel_name), + single_process_(true) { + Init(); } UtilityThreadImpl::~UtilityThreadImpl() { } void UtilityThreadImpl::Shutdown() { - WebKit::shutdown(); + if (!single_process_) + WebKit::shutdown(); } bool UtilityThreadImpl::Send(IPC::Message* msg) { @@ -56,8 +61,20 @@ bool UtilityThreadImpl::Send(IPC::Message* msg) { } void UtilityThreadImpl::ReleaseProcessIfNeeded() { - if (!batch_mode_) + if (batch_mode_) + return; + + if (single_process_) { + // Just quit the message loop directly so that unit tests don't need to + // pump the client message loop again. In normal multi-process mode, need + // normal shutdown as the IO thread could still be sending the result IPC. + // Also close the IPC channel manually as normally that's done by the child + // process exiting, which doesn't happen here. + channel()->Close(); + base::MessageLoop::current()->Quit(); + } else { ChildProcess::current()->ReleaseProcess(); + } } #if defined(OS_WIN) @@ -72,6 +89,19 @@ void UtilityThreadImpl::ReleaseCachedFonts() { #endif // OS_WIN +void UtilityThreadImpl::Init() { + batch_mode_ = false; + ChildProcess::current()->AddRefProcess(); + if (!single_process_) { + // We can only initialize WebKit on one thread, and in single process mode + // we run the utility thread on separate thread. This means that if any code + // needs WebKit initialized in the utility process, they need to have + // another path to support single process mode. + webkit_platform_support_.reset(new WebKitPlatformSupportImpl); + WebKit::initialize(webkit_platform_support_.get()); + } + GetContentClient()->utility()->UtilityThreadStarted(); +} bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { if (GetContentClient()->utility()->OnMessageReceived(msg)) diff --git a/content/utility/utility_thread_impl.h b/content/utility/utility_thread_impl.h index 5963370..8c4f79b 100644 --- a/content/utility/utility_thread_impl.h +++ b/content/utility/utility_thread_impl.h @@ -26,6 +26,8 @@ class UtilityThreadImpl : public UtilityThread, public ChildThread { public: UtilityThreadImpl(); + // Constructor that's used when running in single process mode. + explicit UtilityThreadImpl(const std::string& channel_name); virtual ~UtilityThreadImpl(); virtual void Shutdown() OVERRIDE; @@ -37,6 +39,8 @@ class UtilityThreadImpl : public UtilityThread, #endif private: + void Init(); + // ChildThread implementation. virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE; @@ -51,6 +55,9 @@ class UtilityThreadImpl : public UtilityThread, // True when we're running in batch mode. bool batch_mode_; + // True if running in single process mode. + bool single_process_; + scoped_ptr<WebKitPlatformSupportImpl> webkit_platform_support_; DISALLOW_COPY_AND_ASSIGN(UtilityThreadImpl); |