From f11030094e99bcb61555dc3bb4c157703dc1d7ea Mon Sep 17 00:00:00 2001 From: "dimich@google.com" Date: Wed, 24 Feb 2010 23:50:53 +0000 Subject: Make sure the workers are given a chance to terminate their thread when the IPC channel fails. Usually, the ChildThread::OnChannelError() simply kills the message loop. we want to give workers an opportunity to get out of their threads to avoid crashes when main thread destroys globals. BUG=35963 TEST=WorkerTest.StressJSExecution Review URL: http://codereview.chromium.org/647064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39951 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/worker/worker_thread.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'chrome/worker/worker_thread.cc') diff --git a/chrome/worker/worker_thread.cc b/chrome/worker/worker_thread.cc index ac8a1c7..0591902 100644 --- a/chrome/worker/worker_thread.cc +++ b/chrome/worker/worker_thread.cc @@ -62,3 +62,22 @@ void WorkerThread::OnCreateWorker(const GURL& url, else new WebWorkerStub(url, route_id); } + +// The browser process is likely dead. Terminate all workers. +void WorkerThread::OnChannelError() { + set_on_channel_error_called(true); + + for (WorkerStubsList::iterator it = worker_stubs_.begin(); + it != worker_stubs_.end(); ++it) { + (*it)->OnChannelError(); + } +} + +void WorkerThread::RemoveWorkerStub(WebWorkerStubBase* stub) { + worker_stubs_.erase(stub); +} + +void WorkerThread::AddWorkerStub(WebWorkerStubBase* stub) { + worker_stubs_.insert(stub); +} + -- cgit v1.1