| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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/callback.h" | |
| 11 #include "base/threading/thread_checker.h" | |
| 12 | |
| 13 namespace base { | |
| 14 class SingleThreadTaskRunner; | |
| 15 class WaitableEvent; | |
| 16 } | |
| 17 | |
| 18 namespace IPC { | |
| 19 struct ChannelHandle; | |
| 20 } | |
| 21 | |
| 22 namespace content { | |
| 23 | |
| 24 // GpuArcVideoService manages life-cycle and IPC message translation for | |
| 25 // ArcVideoAccelerator. | |
| 26 // | |
| 27 // For each creation request from GpuChannelManager, GpuArcVideoService will | |
| 28 // create a new IPC channel. | |
| 29 class GpuArcVideoService { | |
| 30 public: | |
| 31 class AcceleratorStub; | |
| 32 using CreateChannelCallback = base::Callback<void(const IPC::ChannelHandle&)>; | |
| 33 | |
| 34 // |shutdown_event| should signal an event when this process is about to be | |
| 35 // shut down in order to notify our new IPC channel to terminate. | |
| 36 GpuArcVideoService( | |
| 37 base::WaitableEvent* shutdown_event, | |
| 38 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | |
| 39 | |
| 40 // Upon deletion, all ArcVideoAccelerator will be deleted and the associated | |
| 41 // IPC channels are closed. | |
| 42 ~GpuArcVideoService(); | |
| 43 | |
| 44 // Creates a new accelerator stub. The creation result will be sent back via | |
| 45 // |callback|. | |
| 46 void CreateChannel(const CreateChannelCallback& callback); | |
| 47 | |
| 48 // Removes the reference of |stub| (and trigger deletion) from this class. | |
| 49 void RemoveClient(AcceleratorStub* stub); | |
| 50 | |
| 51 private: | |
| 52 base::ThreadChecker thread_checker_; | |
| 53 | |
| 54 // Shutdown event of GPU process. | |
| 55 base::WaitableEvent* shutdown_event_; | |
| 56 | |
| 57 // GPU io thread task runner. | |
| 58 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | |
| 59 | |
| 60 // Bookkeeping all accelerator stubs. | |
| 61 std::map<AcceleratorStub*, scoped_ptr<AcceleratorStub>> accelerator_stubs_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(GpuArcVideoService); | |
| 64 }; | |
| 65 | |
| 66 } // namespace content | |
| 67 | |
| 68 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_ARC_VIDEO_SERVICE_H_ | |
| OLD | NEW |