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" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "remoting/client/frame_consumer.h" | 15 #include "remoting/client/frame_consumer.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class SingleThreadTaskRunner; | 18 class SingleThreadTaskRunner; |
19 } // namespace base | 19 } // namespace base |
20 | 20 |
21 namespace remoting { | 21 namespace remoting { |
22 | 22 |
23 class FrameConsumerProxy | 23 class FrameConsumerProxy |
24 : public base::RefCountedThreadSafe<FrameConsumerProxy>, | 24 : public base::RefCountedThreadSafe<FrameConsumerProxy>, |
25 public FrameConsumer { | 25 public FrameConsumer { |
26 public: | 26 public: |
27 // Constructs a proxy for |frame_consumer| which will trampoline invocations | 27 // Constructs a proxy for |frame_consumer| which will trampoline invocations |
28 // to |frame_consumer_message_loop|. | 28 // to |frame_consumer_message_loop|. |
29 FrameConsumerProxy(scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 29 FrameConsumerProxy(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 30 const base::WeakPtr<FrameConsumer>& frame_consumer); |
30 | 31 |
31 // FrameConsumer implementation. | 32 // FrameConsumer implementation. |
32 virtual void ApplyBuffer(const webrtc::DesktopSize& view_size, | 33 virtual void ApplyBuffer(const webrtc::DesktopSize& view_size, |
33 const webrtc::DesktopRect& clip_area, | 34 const webrtc::DesktopRect& clip_area, |
34 webrtc::DesktopFrame* buffer, | 35 webrtc::DesktopFrame* buffer, |
35 const webrtc::DesktopRegion& region) OVERRIDE; | 36 const webrtc::DesktopRegion& region) OVERRIDE; |
36 virtual void ReturnBuffer(webrtc::DesktopFrame* buffer) OVERRIDE; | 37 virtual void ReturnBuffer(webrtc::DesktopFrame* buffer) OVERRIDE; |
37 virtual void SetSourceSize(const webrtc::DesktopSize& source_size, | 38 virtual void SetSourceSize(const webrtc::DesktopSize& source_size, |
38 const webrtc::DesktopVector& dpi) OVERRIDE; | 39 const webrtc::DesktopVector& dpi) OVERRIDE; |
39 | 40 virtual PixelFormat GetPixelFormat() 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); | |
43 | 41 |
44 private: | 42 private: |
45 friend class base::RefCountedThreadSafe<FrameConsumerProxy>; | 43 friend class base::RefCountedThreadSafe<FrameConsumerProxy>; |
46 virtual ~FrameConsumerProxy(); | 44 virtual ~FrameConsumerProxy(); |
47 | 45 |
48 base::WeakPtr<FrameConsumer> frame_consumer_; | 46 base::WeakPtr<FrameConsumer> frame_consumer_; |
49 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 47 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
50 | 48 |
| 49 PixelFormat pixel_format_; |
| 50 |
51 DISALLOW_COPY_AND_ASSIGN(FrameConsumerProxy); | 51 DISALLOW_COPY_AND_ASSIGN(FrameConsumerProxy); |
52 }; | 52 }; |
53 | 53 |
54 } // namespace remoting | 54 } // namespace remoting |
55 | 55 |
56 #endif // REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_ | 56 #endif // REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_ |
OLD | NEW |