summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/DEPS4
-rw-r--r--content/browser/gpu/gpu_process_host.cc54
-rw-r--r--content/browser/gpu/gpu_process_host.h9
-rw-r--r--content/browser/renderer_host/DEPS4
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc85
-rw-r--r--content/browser/renderer_host/render_process_host_impl.h4
-rw-r--r--content/browser/utility_process_host_impl.cc64
-rw-r--r--content/browser/utility_process_host_impl.h6
8 files changed, 48 insertions, 182 deletions
diff --git a/content/browser/DEPS b/content/browser/DEPS
index 39be989..3a85518 100644
--- a/content/browser/DEPS
+++ b/content/browser/DEPS
@@ -10,10 +10,6 @@ include_rules = [
"+ui/webui",
"+win8/util",
- # For single-process mode.
- "+content/child/child_process.h",
- "+content/utility/utility_thread_impl.h",
-
# TODO(joi): This was misplaced; need to move it somewhere else,
# since //content shouldn't depend on //components, which is a layer
# above.
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
index 8cbb7aa..7839ea7 100644
--- a/content/browser/gpu/gpu_process_host.cc
+++ b/content/browser/gpu/gpu_process_host.cc
@@ -278,43 +278,6 @@ class GpuSandboxedProcessLauncherDelegate
} // anonymous namespace
-// Single process not supported in multiple dll mode currently.
-#if !defined(CHROME_MULTIPLE_DLL)
-// This class creates a GPU thread (instead of a GPU process), when running
-// with --in-process-gpu or --single-process.
-class GpuMainThread : public base::Thread {
- public:
- explicit GpuMainThread(const std::string& channel_id)
- : base::Thread("Chrome_InProcGpuThread"),
- channel_id_(channel_id),
- gpu_process_(NULL) {
- }
-
- virtual ~GpuMainThread() {
- Stop();
- }
-
- protected:
- virtual void Init() OVERRIDE {
- gpu_process_ = new GpuProcess();
- // The process object takes ownership of the thread object, so do not
- // save and delete the pointer.
- gpu_process_->set_main_thread(new GpuChildThread(channel_id_));
- }
-
- virtual void CleanUp() OVERRIDE {
- delete gpu_process_;
- }
-
- private:
- std::string channel_id_;
- // Deleted in CleanUp() on the gpu thread, so don't use smart pointers.
- GpuProcess* gpu_process_;
-
- DISALLOW_COPY_AND_ASSIGN(GpuMainThread);
-};
-#endif // !CHROME_MULTIPLE_DLL
-
// static
bool GpuProcessHost::ValidateHost(GpuProcessHost* host) {
if (!host)
@@ -401,6 +364,13 @@ void GpuProcessHost::SendOnIO(GpuProcessKind kind,
}
}
+GpuMainThreadFactoryFunction g_gpu_main_thread_factory = NULL;
+
+void GpuProcessHost::RegisterGpuMainThreadFactory(
+ GpuMainThreadFactoryFunction create) {
+ g_gpu_main_thread_factory = create;
+}
+
// static
GpuProcessHost* GpuProcessHost::FromID(int host_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -598,19 +568,15 @@ bool GpuProcessHost::Init() {
if (channel_id.empty())
return false;
- // Single process not supported in multiple dll mode currently.
-#if !defined(CHROME_MULTIPLE_DLL)
- if (in_process_) {
+ if (in_process_ && g_gpu_main_thread_factory) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kDisableGpuWatchdog);
- in_process_gpu_thread_.reset(new GpuMainThread(channel_id));
+ in_process_gpu_thread_.reset(g_gpu_main_thread_factory(channel_id));
in_process_gpu_thread_->Start();
OnProcessLaunched(); // Fake a callback that the process is ready.
- } else
-#endif // !CHROME_MULTIPLE_DLL
- if (!LaunchGpuProcess(channel_id)) {
+ } else if (!LaunchGpuProcess(channel_id)) {
return false;
}
diff --git a/content/browser/gpu/gpu_process_host.h b/content/browser/gpu/gpu_process_host.h
index 8908a10..32345b7 100644
--- a/content/browser/gpu/gpu_process_host.h
+++ b/content/browser/gpu/gpu_process_host.h
@@ -44,6 +44,8 @@ class GpuMainThread;
class RenderWidgetHostViewFrameSubscriber;
class ShaderDiskCache;
+typedef base::Thread* (*GpuMainThreadFactoryFunction)(const std::string& id);
+
class GpuProcessHost : public BrowserChildProcessHostDelegate,
public IPC::Sender,
public base::NonThreadSafe {
@@ -82,6 +84,9 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
CauseForGpuLaunch cause,
IPC::Message* message);
+ CONTENT_EXPORT static void RegisterGpuMainThreadFactory(
+ GpuMainThreadFactoryFunction create);
+
// Get the GPU process host for the GPU process with the given ID. Returns
// null if the process no longer exists.
static GpuProcessHost* FromID(int host_id);
@@ -214,9 +219,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
bool swiftshader_rendering_;
GpuProcessKind kind_;
-#if !defined(CHROME_MULTIPLE_DLL)
- scoped_ptr<GpuMainThread> in_process_gpu_thread_;
-#endif
+ scoped_ptr<base::Thread> in_process_gpu_thread_;
// Whether we actually launched a GPU process.
bool process_launched_;
diff --git a/content/browser/renderer_host/DEPS b/content/browser/renderer_host/DEPS
index 34decdb..0848d36 100644
--- a/content/browser/renderer_host/DEPS
+++ b/content/browser/renderer_host/DEPS
@@ -5,10 +5,6 @@ include_rules = [
"+third_party/zlib",
"+third_party/libyuv",
- # For single-process mode.
- "+content/renderer/render_process_impl.h",
- "+content/renderer/render_thread_impl.h",
-
# The renderer_host files should only call upwards in the layering via the
# delegate interfaces.
"-content/browser/web_contents",
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 3b22bc8..25e5a05 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -118,8 +118,6 @@
#include "content/public/common/process_type.h"
#include "content/public/common/result_codes.h"
#include "content/public/common/url_constants.h"
-#include "content/renderer/render_process_impl.h"
-#include "content/renderer/render_thread_impl.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_logging.h"
@@ -157,8 +155,6 @@ static const char* kSiteProcessMapKeyName = "content_site_process_map";
namespace content {
namespace {
-base::MessageLoop* g_in_process_thread;
-
void CacheShaderInfo(int32 id, base::FilePath path) {
ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
}
@@ -167,57 +163,6 @@ void RemoveShaderInfo(int32 id) {
ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id);
}
-} // namespace
-
-#if !defined(CHROME_MULTIPLE_DLL)
-
-// This class creates the IO thread for the renderer when running in
-// single-process mode. It's not used in multi-process mode.
-class RendererMainThread : public base::Thread {
- public:
- explicit RendererMainThread(const std::string& channel_id)
- : Thread("Chrome_InProcRendererThread"),
- channel_id_(channel_id) {
- }
-
- virtual ~RendererMainThread() {
- Stop();
- }
-
- protected:
- virtual void Init() OVERRIDE {
- render_process_.reset(new RenderProcessImpl());
- new RenderThreadImpl(channel_id_);
- g_in_process_thread = message_loop();
- }
-
- virtual void CleanUp() OVERRIDE {
- g_in_process_thread = NULL;
- render_process_.reset();
-
- // It's a little lame to manually set this flag. But the single process
- // RendererThread will receive the WM_QUIT. We don't need to assert on
- // this thread, so just force the flag manually.
- // If we want to avoid this, we could create the InProcRendererThread
- // directly with _beginthreadex() rather than using the Thread class.
- // We used to set this flag in the Init function above. However there
- // other threads like WebThread which are created by this thread
- // which resets this flag. Please see Thread::StartWithOptions. Setting
- // this flag to true in Cleanup works around these problems.
- SetThreadWasQuitProperly(true);
- }
-
- private:
- std::string channel_id_;
- scoped_ptr<RenderProcess> render_process_;
-
- DISALLOW_COPY_AND_ASSIGN(RendererMainThread);
-};
-
-#endif
-
-namespace {
-
// Helper class that we pass to ResourceMessageFilter so that it can find the
// right net::URLRequestContext for a request.
class RendererURLRequestContextSelector
@@ -339,6 +284,20 @@ class RendererSandboxedProcessLauncherDelegate
} // namespace
+RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL;
+
+void RenderProcessHost::RegisterRendererMainThreadFactory(
+ RendererMainThreadFactoryFunction create) {
+ g_renderer_main_thread_factory = create;
+}
+
+base::MessageLoop* g_in_process_thread;
+
+base::MessageLoop*
+ RenderProcessHostImpl::GetInProcessRendererThreadForTesting() {
+ return g_in_process_thread;
+}
+
// Stores the maximum number of renderer processes the content module can
// create.
static size_t g_max_renderer_count_override = 0;
@@ -511,15 +470,14 @@ bool RenderProcessHostImpl::Init() {
CreateMessageFilters();
// Single-process mode not supported in multiple-dll mode currently.
-#if !defined(CHROME_MULTIPLE_DLL)
- if (run_renderer_in_process()) {
+ if (run_renderer_in_process() && g_renderer_main_thread_factory) {
// Crank up a thread and run the initialization there. With the way that
// messages flow between the browser and renderer, this thread is required
// to prevent a deadlock in single-process mode. Since the primordial
// thread in the renderer process runs the WebKit code and can sometimes
// make blocking calls to the UI thread (i.e. this thread), they need to run
// on separate threads.
- in_process_renderer_.reset(new RendererMainThread(channel_id));
+ in_process_renderer_.reset(g_renderer_main_thread_factory(channel_id));
base::Thread::Options options;
#if defined(OS_WIN) && !defined(OS_MACOSX)
@@ -532,10 +490,10 @@ bool RenderProcessHostImpl::Init() {
#endif
in_process_renderer_->StartWithOptions(options);
+ g_in_process_thread = in_process_renderer_->message_loop();
+
OnProcessLaunched(); // Fake a callback that the process is ready.
- } else
-#endif // !CHROME_MULTIPLE_DLL
- {
+ } else {
// Build command line for renderer. We call AppendRendererCommandLine()
// first so the process type argument will appear first.
CommandLine* cmd_line = new CommandLine(renderer_path);
@@ -1617,11 +1575,6 @@ void RenderProcessHostImpl::RegisterProcessHostForSite(
map->RegisterProcess(site, process);
}
-base::MessageLoop*
- RenderProcessHostImpl::GetInProcessRendererThreadForTesting() {
- return g_in_process_thread;
-}
-
void RenderProcessHostImpl::ProcessDied(bool already_dead) {
// Our child process has died. If we didn't expect it, it's a crash.
// In any case, we need to let everyone know it's gone.
diff --git a/content/browser/renderer_host/render_process_host_impl.h b/content/browser/renderer_host/render_process_host_impl.h
index 72ec846..9d195f5 100644
--- a/content/browser/renderer_host/render_process_host_impl.h
+++ b/content/browser/renderer_host/render_process_host_impl.h
@@ -264,10 +264,8 @@ class CONTENT_EXPORT RenderProcessHostImpl
// This is used to clear our cache five seconds after the last use.
base::DelayTimer<RenderProcessHostImpl> cached_dibs_cleaner_;
-#if !defined(CHROME_MULTIPLE_DLL)
// Used in single-process mode.
- scoped_ptr<RendererMainThread> in_process_renderer_;
-#endif
+ scoped_ptr<base::Thread> in_process_renderer_;
// True after Init() has been called. We can't just check channel_ because we
// also reset that in the case of process termination.
diff --git a/content/browser/utility_process_host_impl.cc b/content/browser/utility_process_host_impl.cc
index 2e56218..766b82e 100644
--- a/content/browser/utility_process_host_impl.cc
+++ b/content/browser/utility_process_host_impl.cc
@@ -16,7 +16,6 @@
#include "base/synchronization/waitable_event.h"
#include "content/browser/browser_child_process_host_impl.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
-#include "content/child/child_process.h"
#include "content/common/child_process_host_impl.h"
#include "content/common/utility_messages.h"
#include "content/public/browser/browser_thread.h"
@@ -24,7 +23,6 @@
#include "content/public/browser/utility_process_host_client.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/process_type.h"
-#include "content/utility/utility_thread_impl.h"
#include "ipc/ipc_switches.h"
#include "ui/base/ui_base_switches.h"
@@ -53,53 +51,8 @@ private:
};
#endif
-// 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;
-// Single process not supported in multiple dll mode currently.
-#if !defined(CHROME_MULTIPLE_DLL)
-class UtilityMainThread : public base::Thread {
- public:
- UtilityMainThread(const std::string& channel_id)
- : Thread("Chrome_InProcUtilityThread"),
- channel_id_(channel_id) {
- }
-
- virtual ~UtilityMainThread() {
- Stop();
- }
-
- private:
- // base::Thread implementation:
- virtual void Init() OVERRIDE {
- // We need to return right away or else the main thread that started us will
- // hang.
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&UtilityMainThread::InitInternal, base::Unretained(this)));
- }
-
- virtual void CleanUp() OVERRIDE {
- child_process_.reset();
-
- // See comment in RendererMainThread.
- SetThreadWasQuitProperly(true);
- g_one_utility_thread_lock.Get().Release();
- }
-
- void InitInternal() {
- g_one_utility_thread_lock.Get().Acquire();
- child_process_.reset(new ChildProcess());
- child_process_->set_main_thread(new UtilityThreadImpl(channel_id_));
- }
-
- std::string channel_id_;
- scoped_ptr<ChildProcess> child_process_;
-
- DISALLOW_COPY_AND_ASSIGN(UtilityMainThread);
-};
-#endif // !CHROME_MULTIPLE_DLL
+UtilityMainThreadFactoryFunction g_utility_main_thread_factory = NULL;
UtilityProcessHost* UtilityProcessHost::Create(
UtilityProcessHostClient* client,
@@ -107,6 +60,11 @@ UtilityProcessHost* UtilityProcessHost::Create(
return new UtilityProcessHostImpl(client, client_task_runner);
}
+void UtilityProcessHost::RegisterUtilityMainThreadFactory(
+ UtilityMainThreadFactoryFunction create) {
+ g_utility_main_thread_factory = create;
+}
+
UtilityProcessHostImpl::UtilityProcessHostImpl(
UtilityProcessHostClient* client,
base::SequencedTaskRunner* client_task_runner)
@@ -196,15 +154,13 @@ bool UtilityProcessHostImpl::StartProcess() {
return false;
// Single process not supported in multiple dll mode currently.
-#if !defined(CHROME_MULTIPLE_DLL)
- if (RenderProcessHost::run_renderer_in_process()) {
+ if (RenderProcessHost::run_renderer_in_process() &&
+ g_utility_main_thread_factory) {
// See comment in RenderProcessHostImpl::Init() for the background on why we
// support single process mode this way.
- in_process_thread_.reset(new UtilityMainThread(channel_id));
+ in_process_thread_.reset(g_utility_main_thread_factory(channel_id));
in_process_thread_->Start();
- } else
-#endif // !CHROME_MULTIPLE_DLL
- {
+ } else {
const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
int child_flags = child_flags_;
diff --git a/content/browser/utility_process_host_impl.h b/content/browser/utility_process_host_impl.h
index 6eecd3d..5443e09 100644
--- a/content/browser/utility_process_host_impl.h
+++ b/content/browser/utility_process_host_impl.h
@@ -18,11 +18,11 @@
namespace base {
class SequencedTaskRunner;
+class Thread;
}
namespace content {
class BrowserChildProcessHostImpl;
-class UtilityMainThread;
class CONTENT_EXPORT UtilityProcessHostImpl
: public NON_EXPORTED_BASE(UtilityProcessHost),
@@ -83,10 +83,8 @@ class CONTENT_EXPORT UtilityProcessHostImpl
scoped_ptr<BrowserChildProcessHostImpl> process_;
-#if !defined(CHROME_MULTIPLE_DLL)
// Used in single-process mode instead of process_.
- scoped_ptr<UtilityMainThread> in_process_thread_;
-#endif
+ scoped_ptr<base::Thread> in_process_thread_;
DISALLOW_COPY_AND_ASSIGN(UtilityProcessHostImpl);
};