Chromium Code Reviews| 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_ACCELERATOR_H_ | |
| 6 #define CONTENT_COMMON_GPU_MEDIA_GPU_ARC_ACCELERATOR_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 struct ChannelHandle; | |
| 22 } | |
| 23 | |
| 24 namespace content { | |
| 25 class GpuChannel; | |
| 26 | |
| 27 // GpuArcAccelerator manages life-cycle and IPC message translation for | |
| 28 // ArcVideoAccelerator. | |
| 29 // | |
| 30 // For each creation requests from GpuChannel, GpuArcAccelerator will create a | |
| 31 // new IPC channel. All messages to ArcVideoAccelerator are handled on | |
| 32 // |arc_accelerator_thread_|. | |
| 33 class GpuArcAccelerator : public base::NonThreadSafe { | |
|
Owen Lin
2015/11/26 03:54:41
How about refactor this class into two seperate cl
kcwu
2015/11/26 10:34:42
The latter responsibility is called "Client" (a ba
| |
| 34 public: | |
| 35 class Client; | |
| 36 | |
| 37 // |gpu_channel| is used to send reply message for CreateClient. | |
| 38 // |shutdown_event| should signal an event when this process shutdown in | |
| 39 // order to notify our new IPC channel to terminate. | |
| 40 GpuArcAccelerator( | |
| 41 GpuChannel* gpu_channel, | |
| 42 base::WaitableEvent* shutdown_event, | |
| 43 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | |
| 44 | |
| 45 // Upon deletion, all ArcVideoAccelerator will be deleted and the associated | |
| 46 // IPC channels are closed. | |
| 47 ~GpuArcAccelerator(); | |
| 48 | |
| 49 void Initialize(); | |
| 50 | |
| 51 // Creates a new client and initalize with |device_type|. The creation | |
| 52 // result, as an IPC message, will be send back via |gpu_channel_|. | |
| 53 void CreateClient(uint32_t device_type); | |
| 54 | |
| 55 // Removes the reference of |client| (and trigger deletion) from this class. | |
| 56 void RemoveClientOnArcThread(Client* client); | |
| 57 | |
| 58 private: | |
| 59 void CreateClientOnArcThread(uint32_t device_type); | |
| 60 void RemoveAllClientsOnArcThread(base::WaitableEvent* done); | |
| 61 | |
| 62 // GpuChannel outlives this class. So a raw pointer is safe. | |
| 63 GpuChannel* gpu_channel_; | |
| 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_accelerator_thread_; | |
| 76 | |
| 77 // Arc accelerator task runner. | |
| 78 scoped_refptr<base::SingleThreadTaskRunner> arc_task_runner_; | |
| 79 | |
| 80 // Bookkeeping all clients. Only accessed on arc thread. | |
| 81 std::map<Client*, scoped_ptr<Client>> clients_; | |
| 82 | |
| 83 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuArcAccelerator); | |
| 84 }; | |
| 85 | |
| 86 } // namespace content | |
| 87 | |
| 88 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_ARC_ACCELERATOR_H_ | |
| OLD | NEW |