Chromium Code Reviews| Index: ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc |
| diff --git a/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc b/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc |
| index 75096a0cb8dc615b89ceed60ffcd6e0642afc774..328b3bfd5f40b1945833a398b63f3c4c17ac729f 100644 |
| --- a/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc |
| +++ b/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc |
| @@ -100,20 +100,28 @@ void DrmGpuPlatformSupportHost::RemoveGpuThreadObserver( |
| } |
| bool DrmGpuPlatformSupportHost::IsConnected() { |
| - return host_id_ >= 0; |
| + return host_id_ >= 0 && channel_established_; |
| } |
| -void DrmGpuPlatformSupportHost::OnChannelEstablished( |
| +void DrmGpuPlatformSupportHost::OnGpuProcessLaunched( |
|
dnicoara
2016/11/01 19:00:40
Is it guaranteed that this will execute before OnC
hshi1
2016/11/01 19:06:00
Yes because OnGpuProcessLaunched is only invoked s
|
| int host_id, |
| scoped_refptr<base::SingleThreadTaskRunner> send_runner, |
| const base::Callback<void(IPC::Message*)>& send_callback) { |
| - TRACE_EVENT1("drm", "DrmGpuPlatformSupportHost::OnChannelEstablished", |
| + TRACE_EVENT1("drm", "DrmGpuPlatformSupportHost::OnGpuProcessLaunched", |
| "host_id", host_id); |
| host_id_ = host_id; |
| send_runner_ = send_runner; |
| send_callback_ = send_callback; |
| for (GpuThreadObserver& observer : gpu_thread_observers_) |
| + observer.OnGpuProcessLaunched(); |
| +} |
| + |
| +void DrmGpuPlatformSupportHost::OnChannelEstablished() { |
| + TRACE_EVENT0("drm", "DrmGpuPlatformSupportHost::OnChannelEstablished"); |
| + channel_established_ = true; |
| + |
| + for (GpuThreadObserver& observer : gpu_thread_observers_) |
| observer.OnGpuThreadReady(); |
| // The cursor is special since it will process input events on the IO thread |
| @@ -131,6 +139,7 @@ void DrmGpuPlatformSupportHost::OnChannelDestroyed(int host_id) { |
| if (host_id_ == host_id) { |
| cursor_->ResetDrmCursorProxy(); |
| host_id_ = -1; |
| + channel_established_ = false; |
| send_runner_ = nullptr; |
| send_callback_.Reset(); |
| for (GpuThreadObserver& observer : gpu_thread_observers_) |
| @@ -230,7 +239,15 @@ bool DrmGpuPlatformSupportHost::GpuRelinquishDisplayControl() { |
| bool DrmGpuPlatformSupportHost::GpuAddGraphicsDevice( |
| const base::FilePath& path, |
| const base::FileDescriptor& fd) { |
| - return Send(new OzoneGpuMsg_AddGraphicsDevice(path, fd)); |
| + IPC::Message* message = new OzoneGpuMsg_AddGraphicsDevice(path, fd); |
| + if (send_runner_ && send_runner_->BelongsToCurrentThread()) { |
| + // Synchronously send IPC if we are on the same thread. |
| + DCHECK(!send_callback_.is_null()); |
| + send_callback_.Run(message); |
|
hshi1
2016/11/01 01:47:50
Done (addressing the comment on posting the Send).
|
| + return true; |
| + } |
| + |
| + return Send(message); |
| } |
| bool DrmGpuPlatformSupportHost::GpuRemoveGraphicsDevice( |