OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
Sergey Ulanov
2011/01/25 21:29:37
2011
Alpha Left Google
2011/01/25 22:20:47
Done.
| |
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/ref_counted.h" | |
20 #include "remoting/client/plugin/pepper_view.h" | |
21 | |
22 namespace remoting { | |
23 | |
24 class ChromotingInstance; | |
25 class ClientContext; | |
26 | |
27 class PepperViewProxy : public base::RefCountedThreadSafe<PepperViewProxy>, | |
28 public ChromotingView, | |
29 public FrameConsumer { | |
30 public: | |
31 PepperViewProxy(ChromotingInstance* instance, PepperView* view); | |
32 virtual ~PepperViewProxy(); | |
33 | |
34 // ChromotingView implementation. | |
35 virtual bool Initialize(); | |
36 virtual void TearDown(); | |
37 virtual void Paint(); | |
38 virtual void SetSolidFill(uint32 color); | |
39 virtual void UnsetSolidFill(); | |
40 virtual void SetConnectionState(ConnectionState state); | |
41 virtual void SetViewport(int x, int y, int width, int height); | |
42 | |
43 // FrameConsumer implementation. | |
44 virtual void AllocateFrame(media::VideoFrame::Format format, | |
45 size_t width, | |
46 size_t height, | |
47 base::TimeDelta timestamp, | |
48 base::TimeDelta duration, | |
49 scoped_refptr<media::VideoFrame>* frame_out, | |
50 Task* done); | |
51 virtual void ReleaseFrame(media::VideoFrame* frame); | |
52 virtual void OnPartialFrameOutput(media::VideoFrame* frame, | |
53 UpdatedRects* rects, | |
54 Task* done); | |
55 | |
56 // Remove the reference to |instance_| and |view_| by setting the value to | |
57 // NULL. | |
58 // This method should only be called on pepper thread. | |
59 void Detach(); | |
60 | |
61 private: | |
62 // This variable is accessed on chromoting threads and pepper thread. | |
63 // This is initialized when this object is constructed. Its value is reset | |
64 // to NULL on pepper thread when Detach() is called and there will be no | |
65 // other threads accessing this variable at the same time. Given the above | |
66 // conditions locking this variable is not necessary. | |
67 ChromotingInstance* instance_; | |
68 | |
69 // This variable is only accessed on the pepper thread. Locking is not | |
70 // necessary. | |
71 PepperView* view_; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(PepperViewProxy); | |
74 }; | |
75 | |
76 } // namespace remoting | |
77 | |
78 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_PROXY_H_ | |
OLD | NEW |