Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: content/common/gpu/client/gpu_channel_host.h

Issue 11886005: Fix GpuChannelHost destruction races. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: stupid ios Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/client/gpu_channel_host.h
diff --git a/content/common/gpu/client/gpu_channel_host.h b/content/common/gpu/client/gpu_channel_host.h
index ea37e28b5e8bbb5cda174bcfdb6722222a845def..13fce1038585ec4c6cab701ec047ffdec5e1fe7f 100644
--- a/content/common/gpu/client/gpu_channel_host.h
+++ b/content/common/gpu/client/gpu_channel_host.h
@@ -78,7 +78,8 @@ class CONTENT_EXPORT GpuChannelHostFactory {
// Encapsulates an IPC channel between the client and one GPU process.
// On the GPU process side there's a corresponding GpuChannel.
class GpuChannelHost : public IPC::Sender,
- public base::RefCountedThreadSafe<GpuChannelHost> {
+ public base::RefCountedThreadSafe<GpuChannelHost>,
+ public base::SupportsWeakPtr<GpuChannelHost> {
public:
enum State {
// Not yet connected.
@@ -185,7 +186,8 @@ class GpuChannelHost : public IPC::Sender,
// to the correct message loop.
class MessageFilter : public IPC::ChannelProxy::MessageFilter {
public:
- explicit MessageFilter(GpuChannelHost* parent);
+ MessageFilter(base::WeakPtr<GpuChannelHost> parent,
+ GpuChannelHostFactory* factory);
void AddRoute(int route_id,
base::WeakPtr<IPC::Listener> listener,
@@ -199,7 +201,12 @@ class GpuChannelHost : public IPC::Sender,
private:
virtual ~MessageFilter();
- GpuChannelHost* parent_;
+ // Note: this reference can only be used to post tasks back to the
+ // GpuChannelHost, it is illegal to dereference on the IO thread where the
+ // MessageFilter lives.
+ base::WeakPtr<GpuChannelHost> parent_;
+
+ GpuChannelHostFactory* factory_;
typedef base::hash_map<int, GpuListenerInfo> ListenerMap;
ListenerMap listeners_;

Powered by Google App Engine
This is Rietveld 408576698