OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // FrameConsumerProxy is used to allow a FrameConsumer on the UI thread to be | 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 | 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 | 7 // the proxy's owner before tearing down the FrameConsumer, to prevent any |
8 // further invokations reaching it. | 8 // further invokations reaching it. |
9 | 9 |
10 #ifndef REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_ | 10 #ifndef REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_ |
11 #define REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_ | 11 #define REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_ |
12 | 12 |
13 #include "base/memory/ref_counted.h" | |
14 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
15 #include "remoting/client/frame_consumer.h" | 14 #include "remoting/client/frame_consumer.h" |
16 | 15 |
17 namespace base { | 16 namespace base { |
18 class SingleThreadTaskRunner; | 17 class SingleThreadTaskRunner; |
19 } // namespace base | 18 } // namespace base |
20 | 19 |
21 namespace remoting { | 20 namespace remoting { |
22 | 21 |
23 class FrameConsumerProxy | 22 class FrameConsumerProxy : public FrameConsumer { |
24 : public base::RefCountedThreadSafe<FrameConsumerProxy>, | |
25 public FrameConsumer { | |
26 public: | 23 public: |
27 // Constructs a proxy for |frame_consumer| which will trampoline invocations | 24 // Constructs a FrameConsumer proxy which can be passed to another thread, |
28 // to |frame_consumer_message_loop|. | 25 // and will direct calls to |frame_consumer| on the thread from which the |
29 FrameConsumerProxy(scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 26 // proxy was constructed. |
30 const base::WeakPtr<FrameConsumer>& frame_consumer); | 27 FrameConsumerProxy(const base::WeakPtr<FrameConsumer>& frame_consumer); |
| 28 ~FrameConsumerProxy() override; |
31 | 29 |
32 // FrameConsumer implementation. | 30 // FrameConsumer implementation. |
33 void ApplyBuffer(const webrtc::DesktopSize& view_size, | 31 void ApplyBuffer(const webrtc::DesktopSize& view_size, |
34 const webrtc::DesktopRect& clip_area, | 32 const webrtc::DesktopRect& clip_area, |
35 webrtc::DesktopFrame* buffer, | 33 webrtc::DesktopFrame* buffer, |
36 const webrtc::DesktopRegion& region, | 34 const webrtc::DesktopRegion& region, |
37 const webrtc::DesktopRegion& shape) override; | 35 const webrtc::DesktopRegion* shape) override; |
38 void ReturnBuffer(webrtc::DesktopFrame* buffer) override; | 36 void ReturnBuffer(webrtc::DesktopFrame* buffer) override; |
39 void SetSourceSize(const webrtc::DesktopSize& source_size, | 37 void SetSourceSize(const webrtc::DesktopSize& source_size, |
40 const webrtc::DesktopVector& dpi) override; | 38 const webrtc::DesktopVector& dpi) override; |
41 PixelFormat GetPixelFormat() override; | 39 PixelFormat GetPixelFormat() override; |
42 | 40 |
43 private: | 41 private: |
44 friend class base::RefCountedThreadSafe<FrameConsumerProxy>; | 42 base::WeakPtr<FrameConsumer> frame_consumer_; |
45 ~FrameConsumerProxy() override; | |
46 | 43 |
47 base::WeakPtr<FrameConsumer> frame_consumer_; | |
48 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 44 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
49 | |
50 PixelFormat pixel_format_; | 45 PixelFormat pixel_format_; |
51 | 46 |
52 DISALLOW_COPY_AND_ASSIGN(FrameConsumerProxy); | 47 DISALLOW_COPY_AND_ASSIGN(FrameConsumerProxy); |
53 }; | 48 }; |
54 | 49 |
55 } // namespace remoting | 50 } // namespace remoting |
56 | 51 |
57 #endif // REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_ | 52 #endif // REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_ |
OLD | NEW |