Commit 0cd10c47 authored by sievers@chromium.org's avatar sievers@chromium.org

Fix thread-checker debug code in GpuChannelHost::MessageFilter.

GpuChannelHost can actually outlive the GPUChannel instance (if there is still a context
referencing it). Therefore filter destruction can legally happen on IO, main, or
compositor thread. Put more explicit DCHECK()s to for the member function that must
be called on the IO thread instead.

BUG=95148


Review URL: http://codereview.chromium.org/7835010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99822 0039d316-1c4b-4281-b951-d872f2087c98
parent c112a8f4
......@@ -4,6 +4,7 @@
#include "content/renderer/gpu/gpu_channel_host.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
#include "content/common/child_process.h"
#include "content/common/gpu/gpu_messages.h"
......@@ -41,7 +42,6 @@ void GpuChannelHost::Listener::DispatchError() {
GpuChannelHost::MessageFilter::MessageFilter(GpuChannelHost* parent)
: parent_(parent) {
DetachFromThread();
}
GpuChannelHost::MessageFilter::~MessageFilter() {
......@@ -52,13 +52,13 @@ void GpuChannelHost::MessageFilter::AddRoute(
int route_id,
base::WeakPtr<IPC::Channel::Listener> listener,
scoped_refptr<MessageLoopProxy> loop) {
DCHECK(CalledOnValidThread());
DCHECK(MessageLoop::current() == ChildProcess::current()->io_message_loop());
DCHECK(listeners_.find(route_id) == listeners_.end());
listeners_[route_id] = new GpuChannelHost::Listener(listener, loop);
}
void GpuChannelHost::MessageFilter::RemoveRoute(int route_id) {
DCHECK(CalledOnValidThread());
DCHECK(MessageLoop::current() == ChildProcess::current()->io_message_loop());
ListenerMap::iterator it = listeners_.find(route_id);
if (it != listeners_.end())
listeners_.erase(it);
......@@ -66,8 +66,7 @@ void GpuChannelHost::MessageFilter::RemoveRoute(int route_id) {
bool GpuChannelHost::MessageFilter::OnMessageReceived(
const IPC::Message& message) {
DCHECK(CalledOnValidThread());
DCHECK(MessageLoop::current() == ChildProcess::current()->io_message_loop());
// Never handle sync message replies or we will deadlock here.
if (message.is_reply())
return false;
......@@ -90,8 +89,7 @@ bool GpuChannelHost::MessageFilter::OnMessageReceived(
}
void GpuChannelHost::MessageFilter::OnChannelError() {
DCHECK(CalledOnValidThread());
DCHECK(MessageLoop::current() == ChildProcess::current()->io_message_loop());
// Inform all the proxies that an error has occurred. This will be reported
// via OpenGL as a lost context.
for (ListenerMap::iterator it = listeners_.begin();
......
......@@ -15,7 +15,6 @@
#include "base/memory/weak_ptr.h"
#include "base/process_util.h"
#include "base/synchronization/lock.h"
#include "base/threading/non_thread_safe.h"
#include "content/common/gpu/gpu_info.h"
#include "content/common/message_router.h"
#include "content/renderer/gpu/gpu_video_decode_accelerator_host.h"
......@@ -132,8 +131,7 @@ class GpuChannelHost : public IPC::Message::Sender,
// A filter used internally to route incoming messages from the IO thread
// to the correct message loop.
class MessageFilter : public IPC::ChannelProxy::MessageFilter,
public base::NonThreadSafe {
class MessageFilter : public IPC::ChannelProxy::MessageFilter {
public:
MessageFilter(GpuChannelHost* parent);
virtual ~MessageFilter();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment