Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / content / browser / compositor / browser_compositor_output_surface_proxy.cc
blob27fe55a7ea9b32bc2efea51e86d8574d548603d5
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 "content/browser/compositor/browser_compositor_output_surface_proxy.h"
7 #include "base/bind.h"
8 #include "content/browser/compositor/browser_compositor_output_surface.h"
9 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
10 #include "content/common/gpu/gpu_messages.h"
12 namespace content {
14 BrowserCompositorOutputSurfaceProxy::BrowserCompositorOutputSurfaceProxy(
15 IDMap<BrowserCompositorOutputSurface>* surface_map)
16 : surface_map_(surface_map),
17 connected_to_gpu_process_host_id_(0) {}
19 BrowserCompositorOutputSurfaceProxy::~BrowserCompositorOutputSurfaceProxy() {}
21 void BrowserCompositorOutputSurfaceProxy::ConnectToGpuProcessHost(
22 base::SingleThreadTaskRunner* compositor_thread_task_runner) {
23 BrowserGpuChannelHostFactory* factory =
24 BrowserGpuChannelHostFactory::instance();
26 int gpu_process_host_id = factory->GpuProcessHostId();
27 if (connected_to_gpu_process_host_id_ == gpu_process_host_id)
28 return;
30 const uint32 kMessagesToFilter[] = { GpuHostMsg_UpdateVSyncParameters::ID };
31 factory->SetHandlerForControlMessages(
32 kMessagesToFilter,
33 arraysize(kMessagesToFilter),
34 base::Bind(&BrowserCompositorOutputSurfaceProxy::
35 OnMessageReceivedOnCompositorThread,
36 this),
37 compositor_thread_task_runner);
38 connected_to_gpu_process_host_id_ = gpu_process_host_id;
41 void BrowserCompositorOutputSurfaceProxy::OnMessageReceivedOnCompositorThread(
42 const IPC::Message& message) {
43 IPC_BEGIN_MESSAGE_MAP(BrowserCompositorOutputSurfaceProxy, message)
44 IPC_MESSAGE_HANDLER(GpuHostMsg_UpdateVSyncParameters,
45 OnUpdateVSyncParametersOnCompositorThread);
46 IPC_END_MESSAGE_MAP()
49 void
50 BrowserCompositorOutputSurfaceProxy::OnUpdateVSyncParametersOnCompositorThread(
51 int surface_id,
52 base::TimeTicks timebase,
53 base::TimeDelta interval) {
54 BrowserCompositorOutputSurface* surface = surface_map_->Lookup(surface_id);
55 if (surface)
56 surface->OnUpdateVSyncParametersFromGpu(timebase, interval);
58 } // namespace content