From 2964d2080646dc87150c3abb140ccac800282958 Mon Sep 17 00:00:00 2001 From: "wez@chromium.org" Date: Thu, 15 Mar 2012 23:58:04 +0000 Subject: Fix RectangleUpdateDecoder to reference the FrameConsumerProxy. RectangleUpdateDecoder runs on a separate thread from the FrameConsumer in the PPAPI plugin client, requiring FrameConsumer calls to be proxied to the correct thread. Previously it was passed a bare FrameConsumer pointer, with the underlying FrameConsumerProxy lifetime managed by the ChromotingInstance. Since the RectangleUpdateDecoder is itself ref-counted it can outlive the ChromotingInstance, and thereby the FrameConsumerProxy, if it is still processing queued messages at the time. This CL: * Changes RectangleUpdateDecoder() to take scoped_refptr<>s to the message-loop-proxy and consumer. * Has RectangleUpdateDecoder() take a FrameConsumerProxy, since FrameConsumer is not ref-counted. Ideally it should take a scoped_ptr, and leave ref-counting to be an internal detail of FrameConsumerProxy. Also: * FrameConsumerProxy now accepts a WeakPtr, removing the need for an explicit Detach(), which feels safer. The WeakPtr must have been created on the thread the FrameConsumerProxy will punt calls to, which shouldn't be a problem. * PepperView now SupportsWeakPtr rather than containing a WeakPtrFactory, to make it easy to get a WeakPtr to it. BUG=118110 Review URL: http://codereview.chromium.org/9703006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127035 0039d316-1c4b-4281-b951-d872f2087c98 --- remoting/client/frame_consumer_proxy.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'remoting/client/frame_consumer_proxy.h') diff --git a/remoting/client/frame_consumer_proxy.h b/remoting/client/frame_consumer_proxy.h index 039f042..7e62f2e 100644 --- a/remoting/client/frame_consumer_proxy.h +++ b/remoting/client/frame_consumer_proxy.h @@ -11,6 +11,7 @@ #define REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_ #include "base/memory/ref_counted.h" +#include "base/memory/weak_ptr.h" #include "remoting/client/frame_consumer.h" namespace base { @@ -25,7 +26,8 @@ class FrameConsumerProxy public: // Constructs a proxy for |frame_consumer| which will trampoline invocations // to |frame_consumer_message_loop|. - FrameConsumerProxy(base::MessageLoopProxy* frame_consumer_message_loop); + FrameConsumerProxy( + scoped_refptr frame_consumer_message_loop); virtual ~FrameConsumerProxy(); // FrameConsumer implementation. @@ -38,15 +40,10 @@ class FrameConsumerProxy // Attaches to |frame_consumer_|. // This must only be called from |frame_consumer_message_loop_|. - void Attach(FrameConsumer* frame_consumer); - - // Detaches from |frame_consumer_|, ensuring no further calls reach it. - // This must only be called from |frame_consumer_message_loop_|. - void Detach(); + void Attach(const base::WeakPtr& frame_consumer); private: - FrameConsumer* frame_consumer_; - + base::WeakPtr frame_consumer_; scoped_refptr frame_consumer_message_loop_; DISALLOW_COPY_AND_ASSIGN(FrameConsumerProxy); -- cgit v1.1