Android WebView: build debug/release based on variant.
[chromium-blink-merge.git] / ppapi / proxy / ppp_graphics_3d_proxy.cc
blobee00a925ed0eee6cf07079750a7675fceb61bc3d
1 // Copyright (c) 2012 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 "ppapi/proxy/ppp_graphics_3d_proxy.h"
7 #include "ppapi/c/ppp_graphics_3d.h"
8 #include "ppapi/proxy/host_dispatcher.h"
9 #include "ppapi/proxy/plugin_dispatcher.h"
10 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/shared_impl/proxy_lock.h"
13 namespace ppapi {
14 namespace proxy {
16 namespace {
18 #if !defined(OS_NACL)
19 void ContextLost(PP_Instance instance) {
20 HostDispatcher::GetForInstance(instance)->Send(
21 new PpapiMsg_PPPGraphics3D_ContextLost(API_ID_PPP_GRAPHICS_3D, instance));
24 static const PPP_Graphics3D graphics_3d_interface = {
25 &ContextLost
27 #else
28 // The NaCl plugin doesn't need the host side interface - stub it out.
29 static const PPP_Graphics3D graphics_3d_interface = {};
30 #endif // !defined(OS_NACL)
32 InterfaceProxy* CreateGraphics3DProxy(Dispatcher* dispatcher) {
33 return new PPP_Graphics3D_Proxy(dispatcher);
36 } // namespace
38 PPP_Graphics3D_Proxy::PPP_Graphics3D_Proxy(Dispatcher* dispatcher)
39 : InterfaceProxy(dispatcher),
40 ppp_graphics_3d_impl_(NULL) {
41 if (dispatcher->IsPlugin()) {
42 ppp_graphics_3d_impl_ = static_cast<const PPP_Graphics3D*>(
43 dispatcher->local_get_interface()(PPP_GRAPHICS_3D_INTERFACE));
47 PPP_Graphics3D_Proxy::~PPP_Graphics3D_Proxy() {
50 // static
51 const InterfaceProxy::Info* PPP_Graphics3D_Proxy::GetInfo() {
52 static const Info info = {
53 &graphics_3d_interface,
54 PPP_GRAPHICS_3D_INTERFACE,
55 API_ID_PPP_GRAPHICS_3D,
56 false,
57 &CreateGraphics3DProxy,
59 return &info;
62 bool PPP_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) {
63 if (!dispatcher()->IsPlugin())
64 return false;
66 bool handled = true;
67 IPC_BEGIN_MESSAGE_MAP(PPP_Graphics3D_Proxy, msg)
68 IPC_MESSAGE_HANDLER(PpapiMsg_PPPGraphics3D_ContextLost,
69 OnMsgContextLost)
70 IPC_MESSAGE_UNHANDLED(handled = false)
71 IPC_END_MESSAGE_MAP()
72 return handled;
75 void PPP_Graphics3D_Proxy::OnMsgContextLost(PP_Instance instance) {
76 if (ppp_graphics_3d_impl_)
77 CallWhileUnlocked(ppp_graphics_3d_impl_->Graphics3DContextLost, instance);
80 } // namespace proxy
81 } // namespace ppapi