summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_process.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-20 07:15:17 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-20 07:15:17 +0000
commitea51de3307a6a5947ca047fa9d0e20359fdcf658 (patch)
treec1a49c1d41c4bfbf74ddbc28c371f840dd2848fa /chrome/renderer/render_process.cc
parentb6aedfff89cd93f07c1c38a13062801e81bf26e4 (diff)
downloadchromium_src-ea51de3307a6a5947ca047fa9d0e20359fdcf658.zip
chromium_src-ea51de3307a6a5947ca047fa9d0e20359fdcf658.tar.gz
chromium_src-ea51de3307a6a5947ca047fa9d0e20359fdcf658.tar.bz2
Reverting 10080.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10082 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_process.cc')
-rw-r--r--chrome/renderer/render_process.cc78
1 files changed, 42 insertions, 36 deletions
diff --git a/chrome/renderer/render_process.cc b/chrome/renderer/render_process.cc
index ff1cd33..198f854f 100644
--- a/chrome/renderer/render_process.cc
+++ b/chrome/renderer/render_process.cc
@@ -29,48 +29,34 @@
#include "chrome/renderer/render_view.h"
#include "webkit/glue/webkit_glue.h"
+//-----------------------------------------------------------------------------
-RenderProcess::RenderProcess()
- : ChildProcess(new RenderThread()),
- ALLOW_THIS_IN_INITIALIZER_LIST(shared_mem_cache_cleaner_(
- base::TimeDelta::FromSeconds(5),
- this, &RenderProcess::ClearTransportDIBCache)),
- sequence_number_(0) {
- Init();
-}
+bool RenderProcess::load_plugins_in_process_ = false;
+
+//-----------------------------------------------------------------------------
RenderProcess::RenderProcess(const std::wstring& channel_name)
- : ChildProcess(new RenderThread(channel_name)),
+ : render_thread_(channel_name),
ALLOW_THIS_IN_INITIALIZER_LIST(shared_mem_cache_cleaner_(
base::TimeDelta::FromSeconds(5),
this, &RenderProcess::ClearTransportDIBCache)),
sequence_number_(0) {
- Init();
+ for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i)
+ shared_mem_cache_[i] = NULL;
}
RenderProcess::~RenderProcess() {
- // TODO(port)
- // Try and limit what we pull in for our non-Win unit test bundle
-#ifndef NDEBUG
- // log important leaked objects
- webkit_glue::CheckForLeaks();
-#endif
-
// We need to stop the RenderThread as the clearer_factory_
// member could be in use while the object itself is destroyed,
// as a result of the containing RenderProcess object being destroyed.
// This race condition causes a crash when the renderer process is shutting
// down.
- child_thread()->Stop();
+ render_thread_.Stop();
ClearTransportDIBCache();
}
-void RenderProcess::Init() {
- in_process_plugins_ = InProcessPlugins();
- in_process_gears_ = false;
- for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i)
- shared_mem_cache_[i] = NULL;
-
+// static
+bool RenderProcess::GlobalInit(const std::wstring &channel_name) {
#if defined(OS_WIN)
// HACK: See http://b/issue?id=1024307 for rationale.
if (GetModuleHandle(L"LPK.DLL") == NULL) {
@@ -98,6 +84,10 @@ void RenderProcess::Init() {
webkit_glue::SetRecordPlaybackMode(true);
}
+ if (command_line.HasSwitch(switches::kInProcessPlugins) ||
+ command_line.HasSwitch(switches::kSingleProcess))
+ load_plugins_in_process_ = true;
+
if (command_line.HasSwitch(switches::kEnableWatchdog)) {
// TODO(JAR): Need to implement renderer IO msgloop watchdog.
}
@@ -108,7 +98,6 @@ void RenderProcess::Init() {
if (command_line.HasSwitch(switches::kGearsInRenderer)) {
#if defined(OS_WIN)
- in_process_gears_ = true;
// Load gears.dll on startup so we can access it before the sandbox
// blocks us.
std::wstring path;
@@ -124,12 +113,19 @@ void RenderProcess::Init() {
// TODO(scherkus): check for any DLL dependencies.
webkit_glue::SetMediaPlayerAvailable(true);
}
+
+ ChildProcessFactory<RenderProcess> factory;
+ return ChildProcess::GlobalInit(channel_name, &factory);
}
-bool RenderProcess::InProcessPlugins() {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- return command_line.HasSwitch(switches::kInProcessPlugins) ||
- command_line.HasSwitch(switches::kSingleProcess);
+// static
+void RenderProcess::GlobalCleanup() {
+ ChildProcess::GlobalCleanup();
+}
+
+// static
+bool RenderProcess::ShouldLoadPluginsInProcess() {
+ return load_plugins_in_process_;
}
// -----------------------------------------------------------------------------
@@ -159,7 +155,7 @@ TransportDIB* RenderProcess::CreateTransportDIB(size_t size) {
// get one.
IPC::Maybe<TransportDIB::Handle> mhandle;
IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(size, &mhandle);
- if (!child_thread()->Send(msg))
+ if (!render_thread_.Send(msg))
return NULL;
if (!mhandle.valid)
return NULL;
@@ -175,7 +171,7 @@ void RenderProcess::FreeTransportDIB(TransportDIB* dib) {
// On Mac we need to tell the browser that it can drop a reference to the
// shared memory.
IPC::Message* msg = new ViewHostMsg_FreeTransportDIB(dib->id());
- child_thread()->Send(msg);
+ render_thread_.Send(msg);
#endif
delete dib;
@@ -184,13 +180,14 @@ void RenderProcess::FreeTransportDIB(TransportDIB* dib) {
// -----------------------------------------------------------------------------
+// static
skia::PlatformCanvas* RenderProcess::GetDrawingCanvas(
TransportDIB** memory, const gfx::Rect& rect) {
const size_t stride = skia::PlatformCanvas::StrideForWidth(rect.width());
const size_t size = stride * rect.height();
- if (!GetTransportDIBFromCache(memory, size)) {
- *memory = CreateTransportDIB(size);
+ if (!self()->GetTransportDIBFromCache(memory, size)) {
+ *memory = self()->CreateTransportDIB(size);
if (!*memory)
return false;
}
@@ -198,13 +195,14 @@ skia::PlatformCanvas* RenderProcess::GetDrawingCanvas(
return CanvasFromTransportDIB(*memory, rect);
}
+// static
void RenderProcess::ReleaseTransportDIB(TransportDIB* mem) {
- if (PutSharedMemInCache(mem)) {
- shared_mem_cache_cleaner_.Reset();
+ if (self()->PutSharedMemInCache(mem)) {
+ self()->shared_mem_cache_cleaner_.Reset();
return;
}
- FreeTransportDIB(mem);
+ self()->FreeTransportDIB(mem);
}
bool RenderProcess::GetTransportDIBFromCache(TransportDIB** mem,
@@ -268,3 +266,11 @@ void RenderProcess::ClearTransportDIBCache() {
}
}
+void RenderProcess::Cleanup() {
+ // TODO(port)
+ // Try and limit what we pull in for our non-Win unit test bundle
+#ifndef NDEBUG
+ // log important leaked objects
+ webkit_glue::CheckForLeaks();
+#endif
+}