diff options
author | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 17:33:22 +0000 |
---|---|---|
committer | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 17:33:22 +0000 |
commit | 9291ed107d2031cea55f324431ffee8d7bae1416 (patch) | |
tree | 5c1d8e6d992aa324f099062b0f85e3945fdfe761 /chrome/renderer/render_process.cc | |
parent | fefa8b29191ffd7730f7d3428697408bf979e6ee (diff) | |
download | chromium_src-9291ed107d2031cea55f324431ffee8d7bae1416.zip chromium_src-9291ed107d2031cea55f324431ffee8d7bae1416.tar.gz chromium_src-9291ed107d2031cea55f324431ffee8d7bae1416.tar.bz2 |
Revert 21355 because it might be causing all the new
crashes on reliability. It also seems to be causing
valgrind error.
Original change:
Switch the first thread in a child process to be the main thread, and make theIO thread be the second thread. The change is needed for plugins on mac.
Review URL: http://codereview.chromium.org/159274
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21398 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_process.cc')
-rw-r--r-- | chrome/renderer/render_process.cc | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/chrome/renderer/render_process.cc b/chrome/renderer/render_process.cc index 2718d37..3fe22c5 100644 --- a/chrome/renderer/render_process.cc +++ b/chrome/renderer/render_process.cc @@ -47,10 +47,43 @@ static size_t GetMaxSharedMemorySize() { //----------------------------------------------------------------------------- RenderProcess::RenderProcess() - : ALLOW_THIS_IN_INITIALIZER_LIST(shared_mem_cache_cleaner_( + : ChildProcess(new RenderThread()), + ALLOW_THIS_IN_INITIALIZER_LIST(shared_mem_cache_cleaner_( base::TimeDelta::FromSeconds(5), this, &RenderProcess::ClearTransportDIBCache)), sequence_number_(0) { + Init(); +} + +RenderProcess::RenderProcess(const std::string& channel_name) + : ChildProcess(new RenderThread(channel_name)), + ALLOW_THIS_IN_INITIALIZER_LIST(shared_mem_cache_cleaner_( + base::TimeDelta::FromSeconds(5), + this, &RenderProcess::ClearTransportDIBCache)), + sequence_number_(0) { + Init(); +} + +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 + + GetShutDownEvent()->Signal(); + + // 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(); + ClearTransportDIBCache(); +} + +void RenderProcess::Init() { in_process_plugins_ = InProcessPlugins(); for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) shared_mem_cache_[i] = NULL; @@ -98,18 +131,6 @@ RenderProcess::RenderProcess() media::InitializeMediaLibrary(module_path); } -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 - - GetShutDownEvent()->Signal(); - ClearTransportDIBCache(); -} - bool RenderProcess::InProcessPlugins() { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); #if defined(OS_LINUX) @@ -136,7 +157,7 @@ TransportDIB* RenderProcess::CreateTransportDIB(size_t size) { // get one. TransportDIB::Handle handle; IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(size, &handle); - if (!main_thread()->Send(msg)) + if (!child_thread()->Send(msg)) return NULL; if (handle.fd < 0) return NULL; @@ -152,7 +173,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()); - main_thread()->Send(msg); + child_thread()->Send(msg); #endif delete dib; |