Chromium Code Reviews| Index: ui/ozone/platform/drm/gpu/drm_device_manager.cc | 
| diff --git a/ui/ozone/platform/drm/gpu/drm_device_manager.cc b/ui/ozone/platform/drm/gpu/drm_device_manager.cc | 
| index b01664abb706586b1332aee3d22d82fa6f87a5f0..5c8ce8dd6e86455604e509f1544ef72fa6874683 100644 | 
| --- a/ui/ozone/platform/drm/gpu/drm_device_manager.cc | 
| +++ b/ui/ozone/platform/drm/gpu/drm_device_manager.cc | 
| @@ -38,8 +38,17 @@ DrmDeviceManager::~DrmDeviceManager() { | 
| } | 
| bool DrmDeviceManager::AddDrmDevice(const base::FilePath& path, | 
| - const base::FileDescriptor& fd) { | 
| + const base::FileDescriptor& fd, | 
| + bool is_vgem) { | 
| DCHECK(thread_checker_.CalledOnValidThread()); | 
| + DCHECK(fd.auto_close); | 
| 
 
reveman
2015/05/12 13:47:01
this check seems inappropriate. why should this no
 
dshwang
2015/05/12 14:11:42
DrmDeviceManager implementation always close the g
 
reveman
2015/05/12 17:19:00
yes
 
dshwang
2015/05/13 13:09:00
Done.
 
 | 
| + | 
| + if (is_vgem) { | 
| 
 
reveman
2015/05/12 13:47:01
why is the code below not relevant in this case? C
 
dshwang
2015/05/12 14:11:42
That's good question. The answer is directly relat
 
reveman
2015/05/12 15:49:24
So should DrmDevice be doing something different i
 
dshwang
2015/05/12 16:18:57
Yes, vgem fd must be handled differently. I just a
 
reveman
2015/05/12 17:19:00
If vgem is supported, are all devices not vgem?
I
 
dshwang
2015/05/12 17:48:02
How about creating DriDevice pure virtual class? D
 
zachr
2015/05/12 18:24:37
All of these things wrap the same type of object:
 
dshwang
2015/05/12 18:36:20
Thank you for answering. I'll handle vgem in DrmDe
 
dshwang
2015/05/13 13:09:00
Done.
 
 | 
| + vgem_device_.reset(fd.fd); | 
| + vgem_path_ = path; | 
| 
 
reveman
2015/05/12 17:19:00
what happens if 2 vgem devices are added?
 
dshwang
2015/05/12 17:48:02
I don't think vgem can be 2. zachr, could you conf
 
zachr
2015/05/12 18:24:37
card numbers are arbitrary and it is a mistake to
 
dshwang
2015/05/12 18:36:20
Great answer. I did ask that can device have 2 dif
 
dshwang
2015/05/13 13:09:00
Done. handle multiple add and remove in same way t
 
 | 
| + return true; | 
| + } | 
| + | 
| base::File file(fd.fd); | 
| auto it = | 
| std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path)); | 
| @@ -67,6 +76,12 @@ bool DrmDeviceManager::AddDrmDevice(const base::FilePath& path, | 
| void DrmDeviceManager::RemoveDrmDevice(const base::FilePath& path) { | 
| DCHECK(thread_checker_.CalledOnValidThread()); | 
| + if (vgem_path_ == path) { | 
| + vgem_device_.reset(); | 
| + vgem_path_ = base::FilePath(); | 
| + return; | 
| + } | 
| + | 
| auto it = | 
| std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path)); | 
| if (it == devices_.end()) { | 
| @@ -123,4 +138,9 @@ const DrmDeviceVector& DrmDeviceManager::GetDrmDevices() const { | 
| return devices_; | 
| } | 
| +int DrmDeviceManager::GetVgemDevice() const { | 
| + DCHECK(thread_checker_.CalledOnValidThread()); | 
| + return vgem_device_.get(); | 
| +} | 
| + | 
| } // namespace ui |