Chromium Code Reviews| Index: ui/ozone/platform/drm/gpu/drm_gpu_platform_support_proxy.cc |
| diff --git a/ui/ozone/platform/drm/gpu/drm_gpu_platform_support_proxy.cc b/ui/ozone/platform/drm/gpu/drm_gpu_platform_support_proxy.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cfc5f5199f3e6813919ed82ada202862020214d9 |
| --- /dev/null |
| +++ b/ui/ozone/platform/drm/gpu/drm_gpu_platform_support_proxy.cc |
| @@ -0,0 +1,124 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support_proxy.h" |
| + |
| +#include "base/thread_task_runner_handle.h" |
| +#include "ipc/ipc_message.h" |
| +#include "ipc/message_filter.h" |
| +#include "ui/ozone/common/gpu/ozone_gpu_messages.h" |
| +#include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h" |
| +#include "ui/ozone/platform/drm/gpu/drm_thread.h" |
| +#include "ui/ozone/platform/drm/gpu/proxy_helpers.h" |
| + |
| +namespace ui { |
| + |
| +namespace { |
| + |
| +class MessageFilterProxy : public IPC::MessageFilter { |
| + public: |
| + MessageFilterProxy(DrmThread* drm_thread); |
| + |
| + // IPC::MessageFilter: |
| + void OnFilterAdded(IPC::Sender* sender) override; |
| + bool OnMessageReceived(const IPC::Message& message) override; |
| + |
| + private: |
| + ~MessageFilterProxy() override; |
| + |
| + void Send(IPC::Message* message); |
| + |
| + static void SendMessage(base::WeakPtr<MessageFilterProxy> proxy, |
| + IPC::Message* message); |
| + |
| + DrmThread* drm_thread_; |
| + |
| + base::WeakPtr<DrmGpuPlatformSupport> impl_; |
| + |
| + IPC::Sender* sender_ = nullptr; |
| + |
| + base::WeakPtrFactory<MessageFilterProxy> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MessageFilterProxy); |
| +}; |
| + |
| +MessageFilterProxy::MessageFilterProxy(DrmThread* drm_thread) |
| + : drm_thread_(drm_thread), weak_ptr_factory_(this) {} |
| + |
| +MessageFilterProxy::~MessageFilterProxy() {} |
| + |
| +void MessageFilterProxy::OnFilterAdded(IPC::Sender* sender) { |
| + sender_ = sender; |
| + |
| + // The DRM thread needs to be started late since we need to wait for the |
| + // sandbox to start. |
| + drm_thread_->Start(); |
| + impl_ = drm_thread_->GetGpuPlatformSupport(); |
| + |
| + DrmGpuPlatformSupport::IPCSender callback = CreateSafeCallback(base::Bind( |
| + &MessageFilterProxy::SendMessage, weak_ptr_factory_.GetWeakPtr())); |
| + drm_thread_->task_runner()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&DrmGpuPlatformSupport::RegisterSender, impl_, callback)); |
| +} |
| + |
| +bool MessageFilterProxy::OnMessageReceived(const IPC::Message& message) { |
|
spang
2015/09/18 00:46:25
I would strongly prefer to just unpickle the messa
dnicoara
2015/09/18 17:43:08
Why unpickle here? I don't see the benefit. It is
spang
2015/09/18 20:49:55
You've already lost on the boilerplate code by hav
dnicoara
2015/09/29 17:57:05
Done. I've stopped somewhere in between what we've
|
| + switch (message.type()) { |
| + case OzoneGpuMsg_CreateWindow::ID: |
| + case OzoneGpuMsg_DestroyWindow::ID: |
| + case OzoneGpuMsg_WindowBoundsChanged::ID: |
| + case OzoneGpuMsg_CursorSet::ID: |
| + case OzoneGpuMsg_CursorMove::ID: |
| + case OzoneGpuMsg_RefreshNativeDisplays::ID: |
| + case OzoneGpuMsg_ConfigureNativeDisplay::ID: |
| + case OzoneGpuMsg_DisableNativeDisplay::ID: |
| + case OzoneGpuMsg_TakeDisplayControl::ID: |
| + case OzoneGpuMsg_RelinquishDisplayControl::ID: |
| + case OzoneGpuMsg_AddGraphicsDevice::ID: |
| + case OzoneGpuMsg_RemoveGraphicsDevice::ID: |
| + case OzoneGpuMsg_GetHDCPState::ID: |
| + case OzoneGpuMsg_SetHDCPState::ID: |
| + case OzoneGpuMsg_SetGammaRamp::ID: |
| + case OzoneGpuMsg_CheckOverlayCapabilities::ID: |
| + drm_thread_->task_runner()->PostTask( |
| + FROM_HERE, base::Bind(base::IgnoreResult( |
| + &DrmGpuPlatformSupport::OnMessageReceived), |
| + impl_, message)); |
| + return true; |
| + default: |
| + return false; |
| + } |
| +} |
| + |
| +void MessageFilterProxy::Send(IPC::Message* message) { |
| + sender_->Send(message); |
| +} |
| + |
| +void MessageFilterProxy::SendMessage(base::WeakPtr<MessageFilterProxy> proxy, |
| + IPC::Message* message) { |
| + if (proxy) |
| + proxy->Send(message); |
| + else |
| + delete message; |
| +} |
| + |
| +} // namespace |
| + |
| +DrmGpuPlatformSupportProxy::DrmGpuPlatformSupportProxy(DrmThread* drm_thread) |
| + : filter_(new MessageFilterProxy(drm_thread)) {} |
| + |
| +DrmGpuPlatformSupportProxy::~DrmGpuPlatformSupportProxy() {} |
| + |
| +void DrmGpuPlatformSupportProxy::OnChannelEstablished(IPC::Sender* sender) {} |
| + |
| +IPC::MessageFilter* DrmGpuPlatformSupportProxy::GetMessageFilter() { |
| + return filter_.get(); |
| +} |
| + |
| +bool DrmGpuPlatformSupportProxy::OnMessageReceived( |
| + const IPC::Message& message) { |
| + return false; |
| +} |
| + |
| +} // namespace ui |