Memory suppressions
[chromium-blink-merge.git] / remoting / client / frame_consumer_proxy.h
blobe39d15610ea628a16679bfeb3a26cee5cd3aca40
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // FrameConsumerProxy is used to allow a FrameConsumer on the UI thread to be
6 // invoked by a Decoder on the decoder thread. The Detach() method is used by
7 // the proxy's owner before tearing down the FrameConsumer, to prevent any
8 // further invokations reaching it.
10 #ifndef REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_
11 #define REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "remoting/client/frame_consumer.h"
17 namespace base {
18 class SingleThreadTaskRunner;
19 } // namespace base
21 namespace remoting {
23 class FrameConsumerProxy
24 : public base::RefCountedThreadSafe<FrameConsumerProxy>,
25 public FrameConsumer {
26 public:
27 // Constructs a proxy for |frame_consumer| which will trampoline invocations
28 // to |frame_consumer_message_loop|.
29 FrameConsumerProxy(scoped_refptr<base::SingleThreadTaskRunner> task_runner);
31 // FrameConsumer implementation.
32 virtual void ApplyBuffer(const SkISize& view_size,
33 const SkIRect& clip_area,
34 webrtc::DesktopFrame* buffer,
35 const SkRegion& region) OVERRIDE;
36 virtual void ReturnBuffer(webrtc::DesktopFrame* buffer) OVERRIDE;
37 virtual void SetSourceSize(const SkISize& source_size,
38 const SkIPoint& dpi) OVERRIDE;
40 // Attaches to |frame_consumer_|.
41 // This must only be called from |frame_consumer_message_loop_|.
42 void Attach(const base::WeakPtr<FrameConsumer>& frame_consumer);
44 private:
45 friend class base::RefCountedThreadSafe<FrameConsumerProxy>;
46 virtual ~FrameConsumerProxy();
48 base::WeakPtr<FrameConsumer> frame_consumer_;
49 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
51 DISALLOW_COPY_AND_ASSIGN(FrameConsumerProxy);
54 } // namespace remoting
56 #endif // REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_