Skip to content

Commit

Permalink
Implement ChildThread::shutdown and clear members that have refs into…
Browse files Browse the repository at this point in the history
… blink

This enables classes deriving frmo ChildThread to cleanly shut down
WebKit

BUG=263034
R=jam@chromium.org

Review URL: https://chromiumcodereview.appspot.com/19641008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213239 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jochen@chromium.org committed Jul 23, 2013
1 parent 9bb0e5a commit 0e7015f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions content/child/child_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ ChildThread::~ChildThread() {
g_lazy_tls.Pointer()->Set(NULL);
}

void ChildThread::Shutdown() {
// Delete objects that hold references to blink so derived classes can
// safely shutdown blink in their Shutdown implementation.
file_system_dispatcher_.reset();
}

void ChildThread::OnChannelConnected(int32 peer_pid) {
channel_connected_factory_.InvalidateWeakPtrs();
}
Expand Down
2 changes: 1 addition & 1 deletion content/child/child_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender {
// has a thread that post tasks to ChildProcess::main_thread(), that thread
// should be joined in Shutdown().
virtual ~ChildThread();
virtual void Shutdown() = 0;
virtual void Shutdown();

// IPC::Sender implementation:
virtual bool Send(IPC::Message* msg) OVERRIDE;
Expand Down
1 change: 1 addition & 0 deletions content/gpu/gpu_child_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ GpuChildThread::~GpuChildThread() {
}

void GpuChildThread::Shutdown() {
ChildThread::Shutdown();
logging::SetLogMessageHandler(NULL);
}

Expand Down
2 changes: 2 additions & 0 deletions content/plugin/plugin_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ void PluginThread::SetForcefullyTerminatePluginProcess() {
}

void PluginThread::Shutdown() {
ChildThread::Shutdown();

if (preloaded_plugin_module_) {
base::UnloadNativeLibrary(preloaded_plugin_module_);
preloaded_plugin_module_ = NULL;
Expand Down
2 changes: 2 additions & 0 deletions content/renderer/render_thread_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ void RenderThreadImpl::Shutdown() {
FOR_EACH_OBSERVER(
RenderProcessObserver, observers_, OnRenderProcessShutdown());

ChildThread::Shutdown();

// Wait for all databases to be closed.
if (web_database_observer_impl_)
web_database_observer_impl_->WaitForAllDatabasesToClose();
Expand Down
2 changes: 2 additions & 0 deletions content/utility/utility_thread_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ UtilityThreadImpl::~UtilityThreadImpl() {
}

void UtilityThreadImpl::Shutdown() {
ChildThread::Shutdown();

if (!single_process_)
WebKit::shutdown();
}
Expand Down
2 changes: 2 additions & 0 deletions content/worker/worker_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ WorkerThread::~WorkerThread() {
}

void WorkerThread::Shutdown() {
ChildThread::Shutdown();

// Shutdown in reverse of the initialization order.
channel()->RemoveFilter(indexed_db_message_filter_.get());
indexed_db_message_filter_ = NULL;
Expand Down

0 comments on commit 0e7015f

Please sign in to comment.