1 // Copyright 2014 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.
5 #include "ui/ozone/public/ui_thread_gpu.h"
7 #include "ipc/ipc_listener.h"
8 #include "ipc/ipc_message.h"
9 #include "ipc/ipc_sender.h"
10 #include "ui/ozone/public/gpu_platform_support.h"
11 #include "ui/ozone/public/gpu_platform_support_host.h"
12 #include "ui/ozone/public/ozone_platform.h"
16 class UiThreadGpuForwardingSender : public IPC::Sender {
18 explicit UiThreadGpuForwardingSender(IPC::Listener* listener)
19 : listener_(listener) {}
20 virtual ~UiThreadGpuForwardingSender() {}
23 virtual bool Send(IPC::Message* msg) OVERRIDE {
24 listener_->OnMessageReceived(*msg);
30 IPC::Listener* listener_;
33 UiThreadGpu::UiThreadGpu() {
36 UiThreadGpu::~UiThreadGpu() {
39 bool UiThreadGpu::Initialize() {
40 OzonePlatform* platform = ui::OzonePlatform::GetInstance();
43 new UiThreadGpuForwardingSender(platform->GetGpuPlatformSupportHost()));
45 new UiThreadGpuForwardingSender(platform->GetGpuPlatformSupport()));
47 const int kHostId = 1;
48 platform->GetGpuPlatformSupportHost()->OnChannelEstablished(
49 kHostId, gpu_sender_.get());
50 platform->GetGpuPlatformSupport()->OnChannelEstablished(ui_sender_.get());