Roll leveldb from r73 to r75.
[chromium-blink-merge.git] / ppapi / proxy / ppp_instance_private_proxy.cc
blob1d8b8d753ca42da4fe18ea86f3246c31c42f65c1
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_instance_private_proxy.h"
7 #include <algorithm>
9 #include "ppapi/c/pp_var.h"
10 #include "ppapi/c/private/ppp_instance_private.h"
11 #include "ppapi/proxy/host_dispatcher.h"
12 #include "ppapi/proxy/plugin_dispatcher.h"
13 #include "ppapi/proxy/plugin_resource_tracker.h"
14 #include "ppapi/proxy/ppapi_messages.h"
15 #include "ppapi/shared_impl/proxy_lock.h"
17 namespace ppapi {
18 namespace proxy {
20 namespace {
22 PP_Var GetInstanceObject(PP_Instance instance) {
23 Dispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
24 if (!dispatcher->permissions().HasPermission(PERMISSION_PRIVATE))
25 return PP_MakeUndefined();
27 ReceiveSerializedVarReturnValue result;
28 dispatcher->Send(new PpapiMsg_PPPInstancePrivate_GetInstanceObject(
29 API_ID_PPP_INSTANCE_PRIVATE, instance, &result));
30 return result.Return(dispatcher);
33 static const PPP_Instance_Private instance_private_interface = {
34 &GetInstanceObject
37 InterfaceProxy* CreateInstancePrivateProxy(Dispatcher* dispatcher) {
38 return new PPP_Instance_Private_Proxy(dispatcher);
41 } // namespace
43 PPP_Instance_Private_Proxy::PPP_Instance_Private_Proxy(Dispatcher* dispatcher)
44 : InterfaceProxy(dispatcher),
45 ppp_instance_private_impl_(NULL) {
46 if (dispatcher->IsPlugin()) {
47 ppp_instance_private_impl_ = static_cast<const PPP_Instance_Private*>(
48 dispatcher->local_get_interface()(PPP_INSTANCE_PRIVATE_INTERFACE));
52 PPP_Instance_Private_Proxy::~PPP_Instance_Private_Proxy() {
55 // static
56 const InterfaceProxy::Info* PPP_Instance_Private_Proxy::GetInfo() {
57 static const Info info = {
58 &instance_private_interface,
59 PPP_INSTANCE_PRIVATE_INTERFACE,
60 API_ID_PPP_INSTANCE_PRIVATE,
61 false,
62 &CreateInstancePrivateProxy,
64 return &info;
67 bool PPP_Instance_Private_Proxy::OnMessageReceived(const IPC::Message& msg) {
68 if (!dispatcher()->IsPlugin())
69 return false;
71 bool handled = true;
72 IPC_BEGIN_MESSAGE_MAP(PPP_Instance_Private_Proxy, msg)
73 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstancePrivate_GetInstanceObject,
74 OnMsgGetInstanceObject)
75 IPC_MESSAGE_UNHANDLED(handled = false)
76 IPC_END_MESSAGE_MAP()
77 return handled;
80 void PPP_Instance_Private_Proxy::OnMsgGetInstanceObject(
81 PP_Instance instance,
82 SerializedVarReturnValue result) {
83 result.Return(dispatcher(),
84 CallWhileUnlocked(ppp_instance_private_impl_->GetInstanceObject,
85 instance));
88 } // namespace proxy
89 } // namespace ppapi