OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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. | |
4 | |
5 // PepperViewProxy is used to invoke PepperView object on pepper thread. It | |
6 // has the same interface as PepperView. When a method calls is received on | |
7 // any chromoting threads it delegates the method call to pepper thread. | |
8 // It also provide a detach mechanism so that when PepperView object is | |
9 // destroyed PepperViewProxy will not call it anymore. This is important in | |
10 // providing a safe shutdown of ChromotingInstance and PepperView. | |
11 | |
12 // This object is accessed on chromoting threads and pepper thread. The internal | |
13 // PepperView object is only accessed on pepper thread so as the Detach() method | |
14 // call. | |
15 | |
16 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_PROXY_H_ | |
17 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_PROXY_H_ | |
18 | |
19 #include "base/memory/ref_counted.h" | |
20 #include "remoting/client/plugin/pepper_view.h" | |
21 | |
22 namespace base { | |
23 class MessageLoopProxy; | |
24 } // namespace base | |
25 | |
26 namespace remoting { | |
27 | |
28 class ChromotingInstance; | |
29 | |
30 class PepperViewProxy : public base::RefCountedThreadSafe<PepperViewProxy>, | |
31 public ChromotingView, | |
32 public FrameConsumer { | |
33 public: | |
34 PepperViewProxy(ChromotingInstance* instance, PepperView* view, | |
35 base::MessageLoopProxy* plugin_message_loop); | |
36 virtual ~PepperViewProxy(); | |
37 | |
38 // ChromotingView implementation. | |
39 virtual bool Initialize() OVERRIDE; | |
40 virtual void TearDown() OVERRIDE; | |
41 virtual void Paint() OVERRIDE; | |
42 virtual void SetSolidFill(uint32 color) OVERRIDE; | |
43 virtual void UnsetSolidFill() OVERRIDE; | |
44 virtual void SetConnectionState( | |
45 protocol::ConnectionToHost::State state, | |
46 protocol::ConnectionToHost::Error error) OVERRIDE; | |
47 | |
48 // This method returns a value, so must run synchronously, so must be | |
49 // called only on the pepper thread. | |
50 virtual double GetHorizontalScaleRatio() const OVERRIDE; | |
51 virtual double GetVerticalScaleRatio() const OVERRIDE; | |
52 | |
53 // FrameConsumer implementation. | |
54 virtual void AllocateFrame(media::VideoFrame::Format format, | |
55 const SkISize& size, | |
56 scoped_refptr<media::VideoFrame>* frame_out, | |
57 const base::Closure& done) OVERRIDE; | |
58 virtual void ReleaseFrame(media::VideoFrame* frame) OVERRIDE; | |
59 virtual void OnPartialFrameOutput(media::VideoFrame* frame, | |
60 RectVector* rects, | |
61 const base::Closure& done) OVERRIDE; | |
62 | |
63 // Remove the reference to |instance_| and |view_| by setting the value to | |
64 // NULL. | |
65 // This method should only be called on pepper thread. | |
66 void Detach(); | |
67 | |
68 private: | |
69 // This variable is accessed on chromoting threads and pepper thread. | |
70 // This is initialized when this object is constructed. Its value is reset | |
71 // to NULL on pepper thread when Detach() is called and there will be no | |
72 // other threads accessing this variable at the same time. Given the above | |
73 // conditions locking this variable is not necessary. | |
74 ChromotingInstance* instance_; | |
75 | |
76 // This variable is only accessed on the pepper thread. Locking is not | |
77 // necessary. | |
78 PepperView* view_; | |
79 | |
80 scoped_refptr<base::MessageLoopProxy> plugin_message_loop_; | |
81 | |
82 DISALLOW_COPY_AND_ASSIGN(PepperViewProxy); | |
83 }; | |
84 | |
85 } // namespace remoting | |
86 | |
87 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_PROXY_H_ | |
OLD | NEW |