diff options
-rw-r--r-- | chrome/common/child_thread.cc | 4 | ||||
-rw-r--r-- | chrome/common/child_thread.h | 8 | ||||
-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 |
11 files changed, 63 insertions, 6 deletions
diff --git a/chrome/common/child_thread.cc b/chrome/common/child_thread.cc index 5d61738..877a3af 100644 --- a/chrome/common/child_thread.cc +++ b/chrome/common/child_thread.cc @@ -30,6 +30,7 @@ ChildThread::ChildThread(const std::string& channel_name) void ChildThread::Init() { check_with_browser_before_shutdown_ = false; + on_channel_error_called_ = false; message_loop_ = MessageLoop::current(); if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserAgent)) { webkit_glue::SetUserAgent( @@ -71,6 +72,7 @@ ChildThread::~ChildThread() { } void ChildThread::OnChannelError() { + set_on_channel_error_called(true); MessageLoop::current()->Quit(); } @@ -160,7 +162,7 @@ ChildThread* ChildThread::current() { } void ChildThread::OnProcessFinalRelease() { - if (!check_with_browser_before_shutdown_) { + if (on_channel_error_called_ || !check_with_browser_before_shutdown_) { MessageLoop::current()->Quit(); return; } diff --git a/chrome/common/child_thread.h b/chrome/common/child_thread.h index 2b55417..ee05e11 100644 --- a/chrome/common/child_thread.h +++ b/chrome/common/child_thread.h @@ -70,6 +70,10 @@ class ChildThread : public IPC::Channel::Listener, IPC::SyncChannel* channel() { return channel_.get(); } + void set_on_channel_error_called(bool on_channel_error_called) { + on_channel_error_called_ = on_channel_error_called; + } + private: void Init(); @@ -94,6 +98,10 @@ class ChildThread : public IPC::Channel::Listener, // that would addref it. bool check_with_browser_before_shutdown_; + // The OnChannelError() callback was invoked - the channel is dead, don't + // attempt to communicate. + bool on_channel_error_called_; + MessageLoop* message_loop_; scoped_ptr<NotificationService> notification_service_; 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 |