summaryrefslogtreecommitdiffstats
path: root/remoting/client/frame_consumer_proxy.h
diff options
context:
space:
mode:
authorwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-15 23:58:04 +0000
committerwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-15 23:58:04 +0000
commit2964d2080646dc87150c3abb140ccac800282958 (patch)
tree176b65b769a863d4a033b909d418b09ccf550cbf /remoting/client/frame_consumer_proxy.h
parentdc04be7c8fa4f83a72aab879b312a3707016e371 (diff)
downloadchromium_src-2964d2080646dc87150c3abb140ccac800282958.zip
chromium_src-2964d2080646dc87150c3abb140ccac800282958.tar.gz
chromium_src-2964d2080646dc87150c3abb140ccac800282958.tar.bz2
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<FrameConsumer>, and leave ref-counting to be an internal detail of FrameConsumerProxy. Also: * FrameConsumerProxy now accepts a WeakPtr<FrameConsumer>, 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
Diffstat (limited to 'remoting/client/frame_consumer_proxy.h')
-rw-r--r--remoting/client/frame_consumer_proxy.h13
1 files changed, 5 insertions, 8 deletions
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<base::MessageLoopProxy> 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<FrameConsumer>& frame_consumer);
private:
- FrameConsumer* frame_consumer_;
-
+ base::WeakPtr<FrameConsumer> frame_consumer_;
scoped_refptr<base::MessageLoopProxy> frame_consumer_message_loop_;
DISALLOW_COPY_AND_ASSIGN(FrameConsumerProxy);