summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-22 22:44:41 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-22 22:44:41 +0000
commitce79d8512c33e5993d7d92b0d7b017b864f62bf3 (patch)
treeadbe9a51124047844dfde716238796dc7036a0ae
parent78852f3791721c332ad6857689a18a100cff43c6 (diff)
downloadchromium_src-ce79d8512c33e5993d7d92b0d7b017b864f62bf3.zip
chromium_src-ce79d8512c33e5993d7d92b0d7b017b864f62bf3.tar.gz
chromium_src-ce79d8512c33e5993d7d92b0d7b017b864f62bf3.tar.bz2
Add Shutdown() helper to ChildThread and move all destructor logic.
r185551 changed the ordering of events in scoped_ptr<T>::reset(); specifically, callers can no longer rely on get() to return the old value of the stored pointer during a reset(). This causes issues such as http://crbug.com/232981. In order to break the dependency on the value of main_thread_.get() during main_thread_.reset(), destruction of ChildThread has been split into two parts. BUG=233761 Review URL: https://codereview.chromium.org/13878020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195628 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/common/child_process.cc5
-rw-r--r--content/common/child_thread.h6
-rw-r--r--content/gpu/gpu_child_thread.cc3
-rw-r--r--content/gpu/gpu_child_thread.h2
-rw-r--r--content/plugin/plugin_thread.cc3
-rw-r--r--content/plugin/plugin_thread.h1
-rw-r--r--content/ppapi_plugin/ppapi_thread.cc3
-rw-r--r--content/ppapi_plugin/ppapi_thread.h1
-rw-r--r--content/renderer/render_thread_impl.cc3
-rw-r--r--content/renderer/render_thread_impl.h1
-rw-r--r--content/utility/utility_thread_impl.cc3
-rw-r--r--content/utility/utility_thread_impl.h1
-rw-r--r--content/worker/worker_thread.cc3
-rw-r--r--content/worker/worker_thread.h1
14 files changed, 35 insertions, 1 deletions
diff --git a/content/common/child_process.cc b/content/common/child_process.cc
index c66e4a4..6bfff5c 100644
--- a/content/common/child_process.cc
+++ b/content/common/child_process.cc
@@ -71,7 +71,10 @@ ChildProcess::~ChildProcess() {
// Kill the main thread object before nulling child_process_, since
// destruction code might depend on it.
- main_thread_.reset();
+ if (main_thread_) { // null in unittests.
+ main_thread_->Shutdown();
+ main_thread_.reset();
+ }
child_process_ = NULL;
}
diff --git a/content/common/child_thread.h b/content/common/child_thread.h
index 6664d34..ee99868 100644
--- a/content/common/child_thread.h
+++ b/content/common/child_thread.h
@@ -43,7 +43,13 @@ class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender {
ChildThread();
// Used for single-process mode.
explicit ChildThread(const std::string& channel_name);
+ // ChildProcess::main_thread() is reset after Shutdown(), and before the
+ // destructor, so any subsystem that relies on ChildProcess::main_thread()
+ // must be terminated before Shutdown returns. In particular, if a subsystem
+ // has a thread that post tasks to ChildProcess::main_thread(), that thread
+ // should be joined in Shutdown().
virtual ~ChildThread();
+ virtual void Shutdown() = 0;
// IPC::Sender implementation:
virtual bool Send(IPC::Message* msg) OVERRIDE;
diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc
index 165d9dfc..24b0cd6 100644
--- a/content/gpu/gpu_child_thread.cc
+++ b/content/gpu/gpu_child_thread.cc
@@ -82,6 +82,9 @@ GpuChildThread::GpuChildThread(const std::string& channel_id)
}
GpuChildThread::~GpuChildThread() {
+}
+
+void GpuChildThread::Shutdown() {
logging::SetLogMessageHandler(NULL);
}
diff --git a/content/gpu/gpu_child_thread.h b/content/gpu/gpu_child_thread.h
index 58c6c10..0d4baeb 100644
--- a/content/gpu/gpu_child_thread.h
+++ b/content/gpu/gpu_child_thread.h
@@ -43,6 +43,8 @@ class GpuChildThread : public ChildThread {
virtual ~GpuChildThread();
+ virtual void Shutdown() OVERRIDE;
+
void Init(const base::Time& process_start_time);
void StopWatchdog();
diff --git a/content/plugin/plugin_thread.cc b/content/plugin/plugin_thread.cc
index 9d3af8c..595bf5b 100644
--- a/content/plugin/plugin_thread.cc
+++ b/content/plugin/plugin_thread.cc
@@ -137,6 +137,9 @@ PluginThread::PluginThread()
}
PluginThread::~PluginThread() {
+}
+
+void PluginThread::Shutdown() {
if (preloaded_plugin_module_) {
base::UnloadNativeLibrary(preloaded_plugin_module_);
preloaded_plugin_module_ = NULL;
diff --git a/content/plugin/plugin_thread.h b/content/plugin/plugin_thread.h
index f967126..86c9b2d 100644
--- a/content/plugin/plugin_thread.h
+++ b/content/plugin/plugin_thread.h
@@ -25,6 +25,7 @@ class PluginThread : public ChildThread {
public:
PluginThread();
virtual ~PluginThread();
+ virtual void Shutdown() OVERRIDE;
// Returns the one plugin thread.
static PluginThread* current();
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc
index 006f28c..f321d59 100644
--- a/content/ppapi_plugin/ppapi_thread.cc
+++ b/content/ppapi_plugin/ppapi_thread.cc
@@ -113,6 +113,9 @@ PpapiThread::PpapiThread(const CommandLine& command_line, bool is_broker)
}
PpapiThread::~PpapiThread() {
+}
+
+void PpapiThread::Shutdown() {
ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(NULL);
if (plugin_entry_points_.shutdown_module)
plugin_entry_points_.shutdown_module();
diff --git a/content/ppapi_plugin/ppapi_thread.h b/content/ppapi_plugin/ppapi_thread.h
index 5203ce1..7faff6b 100644
--- a/content/ppapi_plugin/ppapi_thread.h
+++ b/content/ppapi_plugin/ppapi_thread.h
@@ -47,6 +47,7 @@ class PpapiThread : public ChildThread,
public:
PpapiThread(const CommandLine& command_line, bool is_broker);
virtual ~PpapiThread();
+ virtual void Shutdown() OVERRIDE;
private:
// Make sure the enum list in tools/histogram/histograms.xml is updated with
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 81613eb..5d43940 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -413,6 +413,9 @@ void RenderThreadImpl::Init() {
}
RenderThreadImpl::~RenderThreadImpl() {
+}
+
+void RenderThreadImpl::Shutdown() {
FOR_EACH_OBSERVER(
RenderProcessObserver, observers_, OnRenderProcessShutdown());
diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h
index 4708c22..a92ec60 100644
--- a/content/renderer/render_thread_impl.h
+++ b/content/renderer/render_thread_impl.h
@@ -108,6 +108,7 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread,
// Constructor that's used when running in single process mode.
explicit RenderThreadImpl(const std::string& channel_name);
virtual ~RenderThreadImpl();
+ virtual void Shutdown() OVERRIDE;
// When initializing WebKit, ensure that any schemes needed for the content
// module are registered properly. Static to allow sharing with tests.
diff --git a/content/utility/utility_thread_impl.cc b/content/utility/utility_thread_impl.cc
index 4febffa..eed1704 100644
--- a/content/utility/utility_thread_impl.cc
+++ b/content/utility/utility_thread_impl.cc
@@ -45,6 +45,9 @@ UtilityThreadImpl::UtilityThreadImpl()
}
UtilityThreadImpl::~UtilityThreadImpl() {
+}
+
+void UtilityThreadImpl::Shutdown() {
WebKit::shutdown();
}
diff --git a/content/utility/utility_thread_impl.h b/content/utility/utility_thread_impl.h
index da2ffbd..31c51a1 100644
--- a/content/utility/utility_thread_impl.h
+++ b/content/utility/utility_thread_impl.h
@@ -27,6 +27,7 @@ class UtilityThreadImpl : public UtilityThread,
public:
UtilityThreadImpl();
virtual ~UtilityThreadImpl();
+ virtual void Shutdown() OVERRIDE;
virtual bool Send(IPC::Message* msg) OVERRIDE;
virtual void ReleaseProcessIfNeeded() OVERRIDE;
diff --git a/content/worker/worker_thread.cc b/content/worker/worker_thread.cc
index 540212a..65083b3 100644
--- a/content/worker/worker_thread.cc
+++ b/content/worker/worker_thread.cc
@@ -73,6 +73,9 @@ WorkerThread::WorkerThread() {
}
WorkerThread::~WorkerThread() {
+}
+
+void WorkerThread::Shutdown() {
// Shutdown in reverse of the initialization order.
channel()->RemoveFilter(indexed_db_message_filter_.get());
indexed_db_message_filter_ = NULL;
diff --git a/content/worker/worker_thread.h b/content/worker/worker_thread.h
index aaa78a3..bc51f49 100644
--- a/content/worker/worker_thread.h
+++ b/content/worker/worker_thread.h
@@ -23,6 +23,7 @@ class WorkerThread : public ChildThread {
public:
WorkerThread();
virtual ~WorkerThread();
+ virtual void Shutdown() OVERRIDE;
// Returns the one worker thread.
static WorkerThread* current();