diff options
author | dimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-26 19:16:16 +0000 |
---|---|---|
committer | dimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-26 19:16:16 +0000 |
commit | ecc0738c8ec3fe083ea639740e4a3ebbc695114d (patch) | |
tree | a72e92b51e43517066da693350282f6ccaed4161 /chrome/worker | |
parent | beda4150e41daa8f6aa91e788fccce2a3e9aca00 (diff) | |
download | chromium_src-ecc0738c8ec3fe083ea639740e4a3ebbc695114d.zip chromium_src-ecc0738c8ec3fe083ea639740e4a3ebbc695114d.tar.gz chromium_src-ecc0738c8ec3fe083ea639740e4a3ebbc695114d.tar.bz2 |
Un-revert r39999, now with a Valgrind fix. Original change: http://codereview.chromium.org/647064
BUG=35963
TEST=WorkerTest.StressJSExecution
Review URL: http://codereview.chromium.org/661139
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40141 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/worker')
-rw-r--r-- | chrome/worker/websharedworker_stub.cc | 4 | ||||
-rw-r--r-- | chrome/worker/websharedworker_stub.h | 1 | ||||
-rw-r--r-- | chrome/worker/webworker_stub.cc | 4 | ||||
-rw-r--r-- | chrome/worker/webworker_stub.h | 1 | ||||
-rw-r--r-- | chrome/worker/webworker_stub_base.cc | 10 | ||||
-rw-r--r-- | chrome/worker/webworkerclient_proxy.cc | 3 | ||||
-rw-r--r-- | chrome/worker/worker_thread.cc | 19 | ||||
-rw-r--r-- | chrome/worker/worker_thread.h | 11 | ||||
-rw-r--r-- | chrome/worker/worker_uitest.cc | 4 |
9 files changed, 52 insertions, 5 deletions
diff --git a/chrome/worker/websharedworker_stub.cc b/chrome/worker/websharedworker_stub.cc index 7c9646e..232f842 100644 --- a/chrome/worker/websharedworker_stub.cc +++ b/chrome/worker/websharedworker_stub.cc @@ -34,6 +34,10 @@ void WebSharedWorkerStub::OnMessageReceived(const IPC::Message& message) { IPC_END_MESSAGE_MAP() } +void WebSharedWorkerStub::OnChannelError() { + OnTerminateWorkerContext(); +} + void WebSharedWorkerStub::OnStartWorkerContext( const GURL& url, const string16& user_agent, const string16& source_code) { // Ignore multiple attempts to start this worker (can happen if two pages diff --git a/chrome/worker/websharedworker_stub.h b/chrome/worker/websharedworker_stub.h index b12cd99..37ab640 100644 --- a/chrome/worker/websharedworker_stub.h +++ b/chrome/worker/websharedworker_stub.h @@ -21,6 +21,7 @@ class WebSharedWorkerStub : public WebWorkerStubBase { // IPC::Channel::Listener implementation. virtual void OnMessageReceived(const IPC::Message& message); + virtual void OnChannelError(); private: virtual ~WebSharedWorkerStub(); diff --git a/chrome/worker/webworker_stub.cc b/chrome/worker/webworker_stub.cc index 33a9b60..142adcf 100644 --- a/chrome/worker/webworker_stub.cc +++ b/chrome/worker/webworker_stub.cc @@ -48,6 +48,10 @@ WebWorkerStub::~WebWorkerStub() { impl_->clientDestroyed(); } +void WebWorkerStub::OnChannelError() { + OnTerminateWorkerContext(); +} + void WebWorkerStub::OnMessageReceived(const IPC::Message& message) { if (!impl_) return; diff --git a/chrome/worker/webworker_stub.h b/chrome/worker/webworker_stub.h index 59a46f1..dab69d0 100644 --- a/chrome/worker/webworker_stub.h +++ b/chrome/worker/webworker_stub.h @@ -21,6 +21,7 @@ class WebWorkerStub : public WebWorkerStubBase { // IPC::Channel::Listener implementation. virtual void OnMessageReceived(const IPC::Message& message); + virtual void OnChannelError(); private: virtual ~WebWorkerStub(); diff --git a/chrome/worker/webworker_stub_base.cc b/chrome/worker/webworker_stub_base.cc index 8ea2a15..b999f44 100644 --- a/chrome/worker/webworker_stub_base.cc +++ b/chrome/worker/webworker_stub_base.cc @@ -12,13 +12,19 @@ WebWorkerStubBase::WebWorkerStubBase(int route_id) : route_id_(route_id), ALLOW_THIS_IN_INITIALIZER_LIST(client_(route_id, this)) { + WorkerThread* workerThread = WorkerThread::current(); + DCHECK(workerThread); + workerThread->AddWorkerStub(this); // Start processing incoming IPCs for this worker. - WorkerThread::current()->AddRoute(route_id_, this); + workerThread->AddRoute(route_id_, this); ChildProcess::current()->AddRefProcess(); } WebWorkerStubBase::~WebWorkerStubBase() { - WorkerThread::current()->RemoveRoute(route_id_); + WorkerThread* workerThread = WorkerThread::current(); + DCHECK(workerThread); + workerThread->RemoveWorkerStub(this); + workerThread->RemoveRoute(route_id_); ChildProcess::current()->ReleaseProcess(); } diff --git a/chrome/worker/webworkerclient_proxy.cc b/chrome/worker/webworkerclient_proxy.cc index 6ba589f..9f651c7 100644 --- a/chrome/worker/webworkerclient_proxy.cc +++ b/chrome/worker/webworkerclient_proxy.cc @@ -123,7 +123,8 @@ void WebWorkerClientProxy::EnsureWorkerContextTerminates() { // This shuts down the process cleanly from the perspective of the browser // process, and avoids the crashed worker infobar from appearing to the new - // page. + // page. It's ok to post several of theese, because the first executed task + // will exit the message loop and subsequent ones won't be executed. MessageLoop::current()->PostDelayedTask(FROM_HERE, kill_process_factory_.NewRunnableMethod( &WebWorkerClientProxy::workerContextDestroyed), 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); +} + diff --git a/chrome/worker/worker_thread.h b/chrome/worker/worker_thread.h index 040f0db..0a0feae 100644 --- a/chrome/worker/worker_thread.h +++ b/chrome/worker/worker_thread.h @@ -5,9 +5,12 @@ #ifndef CHROME_WORKER_WORKER_THREAD_H_ #define CHROME_WORKER_WORKER_THREAD_H_ +#include <set> + #include "chrome/common/child_thread.h" class GURL; +class WebWorkerStubBase; class WorkerWebKitClientImpl; class WorkerThread : public ChildThread { @@ -18,14 +21,22 @@ class WorkerThread : public ChildThread { // Returns the one worker thread. static WorkerThread* current(); + // Invoked from stub constructors/destructors. Stubs own themselves. + void AddWorkerStub(WebWorkerStubBase* stub); + void RemoveWorkerStub(WebWorkerStubBase* stub); + private: virtual void OnControlMessageReceived(const IPC::Message& msg); + virtual void OnChannelError(); void OnCreateWorker( const GURL& url, bool is_shared, const string16& name, int route_id); scoped_ptr<WorkerWebKitClientImpl> webkit_client_; + typedef std::set<WebWorkerStubBase*> WorkerStubsList; + WorkerStubsList worker_stubs_; + DISALLOW_COPY_AND_ASSIGN(WorkerThread); }; diff --git a/chrome/worker/worker_uitest.cc b/chrome/worker/worker_uitest.cc index bc5ea10..4baf800 100644 --- a/chrome/worker/worker_uitest.cc +++ b/chrome/worker/worker_uitest.cc @@ -180,8 +180,8 @@ TEST_F(WorkerTest, DISABLED_SharedWorkerHttpAuth) { } -// All kinds of crashes on Linux and Mac http://crbug.com/22898 -#if defined(OS_LINUX) || defined(OS_MACOSX) +// http://crbug.com/35963 +#if defined(OS_LINUX) #define StressJSExecution DISABLED_StressJSExecution #endif |