Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(867)

Unified Diff: content/utility/utility_thread_impl.cc

Issue 18119009: Make utility process run in-process when running in single-process mode. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: undo unnecessary changes Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/utility/utility_thread_impl.h ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/utility/utility_thread_impl.cc
===================================================================
--- content/utility/utility_thread_impl.cc (revision 210446)
+++ content/utility/utility_thread_impl.cc (working copy)
@@ -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 @@
} // 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 @@
}
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 @@
#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))
« no previous file with comments | « content/utility/utility_thread_impl.h ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698