| 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..79484cb0940ae317e7db38fa857cb2f79028e8b8
|
| --- /dev/null
|
| +++ b/ui/ozone/platform/drm/gpu/drm_gpu_platform_support_proxy.cc
|
| @@ -0,0 +1,122 @@
|
| +// 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/proxy_helpers.h"
|
| +
|
| +namespace ui {
|
| +
|
| +namespace {
|
| +
|
| +class MessageFilterProxy : public IPC::MessageFilter {
|
| + public:
|
| + MessageFilterProxy(
|
| + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
|
| + base::WeakPtr<DrmGpuPlatformSupport> impl);
|
| +
|
| + // 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);
|
| +
|
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
| + base::WeakPtr<DrmGpuPlatformSupport> impl_;
|
| +
|
| + IPC::Sender* sender_ = nullptr;
|
| +
|
| + base::WeakPtrFactory<MessageFilterProxy> weak_ptr_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MessageFilterProxy);
|
| +};
|
| +
|
| +MessageFilterProxy::MessageFilterProxy(
|
| + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
|
| + base::WeakPtr<DrmGpuPlatformSupport> impl)
|
| + : task_runner_(task_runner), impl_(impl), weak_ptr_factory_(this) {}
|
| +
|
| +MessageFilterProxy::~MessageFilterProxy() {}
|
| +
|
| +void MessageFilterProxy::OnFilterAdded(IPC::Sender* sender) {
|
| + sender_ = sender;
|
| + DrmGpuPlatformSupport::IPCSender callback = CreateSafeCallback(base::Bind(
|
| + &MessageFilterProxy::SendMessage, weak_ptr_factory_.GetWeakPtr()));
|
| + task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&DrmGpuPlatformSupport::RegisterSender, impl_, callback));
|
| +}
|
| +
|
| +bool MessageFilterProxy::OnMessageReceived(const IPC::Message& message) {
|
| + 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:
|
| + 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(
|
| + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
|
| + base::WeakPtr<DrmGpuPlatformSupport> impl)
|
| + : filter_(new MessageFilterProxy(task_runner, impl)) {}
|
| +
|
| +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
|
|
|