OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 #ifndef CONTENT_COMMON_GPU_MEDIA_GPU_ARC_VIDEO_SERVICE_H_ | |
6 #define CONTENT_COMMON_GPU_MEDIA_GPU_ARC_VIDEO_SERVICE_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/threading/non_thread_safe.h" | |
12 #include "base/threading/thread.h" | |
13 #include "media/video/arc_video_accelerator.h" | |
14 | |
15 namespace base { | |
16 class SingleThreadTaskRunner; | |
17 class WaitableEvent; | |
18 } | |
19 | |
20 namespace IPC { | |
21 class Sender; | |
22 } | |
23 | |
24 namespace content { | |
25 | |
26 // GpuArcVideoService manages life-cycle and IPC message translation for | |
27 // ArcVideoAccelerator. | |
28 // | |
29 // For each creation requests from GpuChannelManager, GpuArcVideoService will | |
30 // create a new IPC channel. All messages to ArcVideoAccelerator are handled on | |
31 // |arc_video_accelerator_thread_|. | |
32 class GpuArcVideoService : public base::NonThreadSafe { | |
33 public: | |
34 class AcceleratorStub; | |
35 | |
36 // |gpu_channel_manager| is used to send reply message for CreateChannel. | |
37 // |shutdown_event| should signal an event when this process shutdown in | |
38 // order to notify our new IPC channel to terminate. | |
39 GpuArcVideoService( | |
40 IPC::Sender* gpu_channel_manager, | |
41 base::WaitableEvent* shutdown_event, | |
42 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | |
43 | |
44 // Upon deletion, all ArcVideoAccelerator will be deleted and the associated | |
45 // IPC channels are closed. | |
46 ~GpuArcVideoService(); | |
47 | |
48 void Initialize(); | |
49 | |
50 // Creates a new accelerator stub. The creation result, as an IPC message, | |
51 // will be send | |
52 // back via |gpu_channel_manager_|. | |
53 void CreateChannel(); | |
Owen Lin
2015/12/15 03:04:06
I mean if we have a callback for this function. It
kcwu
2015/12/16 14:05:33
Done.
| |
54 | |
55 // Removes the reference of |stub| (and trigger deletion) from this class. | |
56 void RemoveClientOnArcThread(AcceleratorStub* stub); | |
57 | |
58 private: | |
59 void CreateClientOnArcThread(); | |
60 void RemoveAllClientsOnArcThread(base::WaitableEvent* done); | |
61 | |
62 // |gpu_channel_manager_| outlives this class. So a raw pointer is safe. | |
63 IPC::Sender* gpu_channel_manager_; | |
64 | |
65 // Shutdown event of GPU process. | |
66 base::WaitableEvent* shutdown_event_; | |
67 | |
68 // GPU io thread task runner. | |
69 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | |
70 | |
71 // GPU main thread task runner. | |
72 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
73 | |
74 // Arc accelerator thread. | |
75 base::Thread arc_video_accelerator_thread_; | |
76 | |
77 // Arc accelerator task runner. | |
78 scoped_refptr<base::SingleThreadTaskRunner> arc_task_runner_; | |
79 | |
80 // Bookkeeping all accelerator stubs. Only accessed on arc thread. | |
81 std::map<AcceleratorStub*, scoped_ptr<AcceleratorStub>> accelerator_stubs_; | |
82 | |
83 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuArcVideoService); | |
84 }; | |
85 | |
86 } // namespace content | |
87 | |
88 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_ARC_VIDEO_SERVICE_H_ | |
OLD | NEW |