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.
4 
5 #include "ppapi/proxy/ppb_var_deprecated_proxy.h"
6 
7 #include <stdlib.h>  // For malloc
8 
9 #include "base/bind.h"
10 #include "base/logging.h"
11 #include "ppapi/c/dev/ppb_var_deprecated.h"
12 #include "ppapi/c/pp_var.h"
13 #include "ppapi/c/ppb_core.h"
14 #include "ppapi/c/ppb_var.h"
15 #include "ppapi/proxy/host_dispatcher.h"
16 #include "ppapi/proxy/plugin_dispatcher.h"
17 #include "ppapi/proxy/plugin_globals.h"
18 #include "ppapi/proxy/plugin_resource_tracker.h"
19 #include "ppapi/proxy/plugin_var_tracker.h"
20 #include "ppapi/proxy/ppapi_messages.h"
21 #include "ppapi/proxy/ppp_class_proxy.h"
22 #include "ppapi/proxy/proxy_object_var.h"
23 #include "ppapi/proxy/serialized_var.h"
24 #include "ppapi/shared_impl/ppapi_globals.h"
25 #include "ppapi/shared_impl/ppb_var_shared.h"
26 #include "ppapi/shared_impl/proxy_lock.h"
27 #include "ppapi/shared_impl/var.h"
28 
29 namespace ppapi {
30 namespace proxy {
31 
32 namespace {
33 
34 // Used to do get the set-up information for calling a var object. If the
35 // exception is set, returns NULL. Otherwise, computes the dispatcher for the
36 // given var object. If the var is not a valid object, returns NULL and sets
37 // the exception.
CheckExceptionAndGetDispatcher(const PP_Var & object,PP_Var * exception)38 PluginDispatcher* CheckExceptionAndGetDispatcher(const PP_Var& object,
39                                                  PP_Var* exception) {
40   // If an exception is already set, we don't need to do anything, just return
41   // an error to the caller.
42   if (exception && exception->type != PP_VARTYPE_UNDEFINED)
43     return NULL;
44 
45 
46   if (object.type == PP_VARTYPE_OBJECT) {
47     // Get the dispatcher for the object.
48     PluginDispatcher* dispatcher =
49         PluginGlobals::Get()->plugin_var_tracker()->
50             DispatcherForPluginObject(object);
51     if (dispatcher)
52       return dispatcher;
53   }
54 
55   // The object is invalid. This means we can't figure out which dispatcher
56   // to use, which is OK because the call will fail anyway. Set the exception.
57   if (exception) {
58     *exception = StringVar::StringToPPVar(
59         std::string("Attempting to use an invalid object"));
60   }
61   return NULL;
62 }
63 
64 // PPB_Var_Deprecated plugin ---------------------------------------------------
65 
HasProperty(PP_Var var,PP_Var name,PP_Var * exception)66 bool HasProperty(PP_Var var,
67                  PP_Var name,
68                  PP_Var* exception) {
69   ProxyAutoLock lock;
70   Dispatcher* dispatcher = CheckExceptionAndGetDispatcher(var, exception);
71   if (!dispatcher)
72     return false;
73 
74   ReceiveSerializedException se(dispatcher, exception);
75   PP_Bool result = PP_FALSE;
76   if (!se.IsThrown()) {
77     dispatcher->Send(new PpapiHostMsg_PPBVar_HasProperty(
78         API_ID_PPB_VAR_DEPRECATED,
79         SerializedVarSendInput(dispatcher, var),
80         SerializedVarSendInput(dispatcher, name), &se, &result));
81   }
82   return PP_ToBool(result);
83 }
84 
HasMethod(PP_Var var,PP_Var name,PP_Var * exception)85 bool HasMethod(PP_Var var,
86                PP_Var name,
87                PP_Var* exception) {
88   ProxyAutoLock lock;
89   Dispatcher* dispatcher = CheckExceptionAndGetDispatcher(var, exception);
90   if (!dispatcher)
91     return false;
92 
93   ReceiveSerializedException se(dispatcher, exception);
94   PP_Bool result = PP_FALSE;
95   if (!se.IsThrown()) {
96     dispatcher->Send(new PpapiHostMsg_PPBVar_HasMethodDeprecated(
97         API_ID_PPB_VAR_DEPRECATED,
98         SerializedVarSendInput(dispatcher, var),
99         SerializedVarSendInput(dispatcher, name), &se, &result));
100   }
101   return PP_ToBool(result);
102 }
103 
GetProperty(PP_Var var,PP_Var name,PP_Var * exception)104 PP_Var GetProperty(PP_Var var,
105                    PP_Var name,
106                    PP_Var* exception) {
107   ProxyAutoLock lock;
108   Dispatcher* dispatcher = CheckExceptionAndGetDispatcher(var, exception);
109   if (!dispatcher)
110     return PP_MakeUndefined();
111 
112   ReceiveSerializedException se(dispatcher, exception);
113   ReceiveSerializedVarReturnValue result;
114   if (!se.IsThrown()) {
115     dispatcher->Send(new PpapiHostMsg_PPBVar_GetProperty(
116         API_ID_PPB_VAR_DEPRECATED,
117         SerializedVarSendInput(dispatcher, var),
118         SerializedVarSendInput(dispatcher, name), &se, &result));
119   }
120   return result.Return(dispatcher);
121 }
122 
EnumerateProperties(PP_Var var,uint32_t * property_count,PP_Var ** properties,PP_Var * exception)123 void EnumerateProperties(PP_Var var,
124                          uint32_t* property_count,
125                          PP_Var** properties,
126                          PP_Var* exception) {
127   ProxyAutoLock lock;
128   Dispatcher* dispatcher = CheckExceptionAndGetDispatcher(var, exception);
129   if (!dispatcher) {
130     *property_count = 0;
131     *properties = NULL;
132     return;
133   }
134 
135   ReceiveSerializedVarVectorOutParam out_vector(dispatcher,
136                                                 property_count, properties);
137   ReceiveSerializedException se(dispatcher, exception);
138   if (!se.IsThrown()) {
139     dispatcher->Send(new PpapiHostMsg_PPBVar_EnumerateProperties(
140         API_ID_PPB_VAR_DEPRECATED,
141         SerializedVarSendInput(dispatcher, var),
142         out_vector.OutParam(), &se));
143   }
144 }
145 
SetProperty(PP_Var var,PP_Var name,PP_Var value,PP_Var * exception)146 void SetProperty(PP_Var var,
147                  PP_Var name,
148                  PP_Var value,
149                  PP_Var* exception) {
150   ProxyAutoLock lock;
151   Dispatcher* dispatcher = CheckExceptionAndGetDispatcher(var, exception);
152   if (!dispatcher)
153     return;
154 
155   ReceiveSerializedException se(dispatcher, exception);
156   if (!se.IsThrown()) {
157     dispatcher->Send(new PpapiHostMsg_PPBVar_SetPropertyDeprecated(
158         API_ID_PPB_VAR_DEPRECATED,
159         SerializedVarSendInput(dispatcher, var),
160         SerializedVarSendInput(dispatcher, name),
161         SerializedVarSendInput(dispatcher, value), &se));
162   }
163 }
164 
RemoveProperty(PP_Var var,PP_Var name,PP_Var * exception)165 void RemoveProperty(PP_Var var,
166                     PP_Var name,
167                     PP_Var* exception) {
168   ProxyAutoLock lock;
169   Dispatcher* dispatcher = CheckExceptionAndGetDispatcher(var, exception);
170   if (!dispatcher)
171     return;
172 
173   ReceiveSerializedException se(dispatcher, exception);
174   PP_Bool result = PP_FALSE;
175   if (!se.IsThrown()) {
176     dispatcher->Send(new PpapiHostMsg_PPBVar_DeleteProperty(
177         API_ID_PPB_VAR_DEPRECATED,
178         SerializedVarSendInput(dispatcher, var),
179         SerializedVarSendInput(dispatcher, name), &se, &result));
180   }
181 }
182 
Call(PP_Var object,PP_Var method_name,uint32_t argc,PP_Var * argv,PP_Var * exception)183 PP_Var Call(PP_Var object,
184             PP_Var method_name,
185             uint32_t argc,
186             PP_Var* argv,
187             PP_Var* exception) {
188   ProxyAutoLock lock;
189   Dispatcher* dispatcher = CheckExceptionAndGetDispatcher(object, exception);
190   if (!dispatcher)
191     return PP_MakeUndefined();
192 
193   ReceiveSerializedVarReturnValue result;
194   ReceiveSerializedException se(dispatcher, exception);
195   if (!se.IsThrown()) {
196     std::vector<SerializedVar> argv_vect;
197     SerializedVarSendInput::ConvertVector(dispatcher, argv, argc, &argv_vect);
198 
199     dispatcher->Send(new PpapiHostMsg_PPBVar_CallDeprecated(
200         API_ID_PPB_VAR_DEPRECATED,
201         SerializedVarSendInput(dispatcher, object),
202         SerializedVarSendInput(dispatcher, method_name), argv_vect,
203         &se, &result));
204   }
205   return result.Return(dispatcher);
206 }
207 
Construct(PP_Var object,uint32_t argc,PP_Var * argv,PP_Var * exception)208 PP_Var Construct(PP_Var object,
209                  uint32_t argc,
210                  PP_Var* argv,
211                  PP_Var* exception) {
212   ProxyAutoLock lock;
213   Dispatcher* dispatcher = CheckExceptionAndGetDispatcher(object, exception);
214   if (!dispatcher)
215     return PP_MakeUndefined();
216 
217   ReceiveSerializedVarReturnValue result;
218   ReceiveSerializedException se(dispatcher, exception);
219   if (!se.IsThrown()) {
220     std::vector<SerializedVar> argv_vect;
221     SerializedVarSendInput::ConvertVector(dispatcher, argv, argc, &argv_vect);
222 
223     dispatcher->Send(new PpapiHostMsg_PPBVar_Construct(
224         API_ID_PPB_VAR_DEPRECATED,
225         SerializedVarSendInput(dispatcher, object),
226         argv_vect, &se, &result));
227   }
228   return result.Return(dispatcher);
229 }
230 
IsInstanceOf(PP_Var var,const PPP_Class_Deprecated * ppp_class,void ** ppp_class_data)231 bool IsInstanceOf(PP_Var var,
232                   const PPP_Class_Deprecated* ppp_class,
233                   void** ppp_class_data) {
234   ProxyAutoLock lock;
235   Dispatcher* dispatcher = CheckExceptionAndGetDispatcher(var, NULL);
236   if (!dispatcher)
237     return false;
238 
239   PP_Bool result = PP_FALSE;
240   int64_t class_int =
241       static_cast<int64_t>(reinterpret_cast<intptr_t>(ppp_class));
242   int64_t class_data_int = 0;
243   dispatcher->Send(new PpapiHostMsg_PPBVar_IsInstanceOfDeprecated(
244       API_ID_PPB_VAR_DEPRECATED, SerializedVarSendInput(dispatcher, var),
245       class_int, &class_data_int, &result));
246   *ppp_class_data =
247       reinterpret_cast<void*>(static_cast<intptr_t>(class_data_int));
248   return PP_ToBool(result);
249 }
250 
CreateObject(PP_Instance instance,const PPP_Class_Deprecated * ppp_class,void * ppp_class_data)251 PP_Var CreateObject(PP_Instance instance,
252                     const PPP_Class_Deprecated* ppp_class,
253                     void* ppp_class_data) {
254   ProxyAutoLock lock;
255   Dispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
256   if (!dispatcher)
257     return PP_MakeUndefined();
258 
259   PluginVarTracker* tracker = PluginGlobals::Get()->plugin_var_tracker();
260   if (tracker->IsPluginImplementedObjectAlive(ppp_class_data))
261     return PP_MakeUndefined();  // Object already exists with this user data.
262 
263   ReceiveSerializedVarReturnValue result;
264   int64_t class_int =
265       static_cast<int64_t>(reinterpret_cast<intptr_t>(ppp_class));
266   int64_t data_int =
267       static_cast<int64_t>(reinterpret_cast<intptr_t>(ppp_class_data));
268   dispatcher->Send(new PpapiHostMsg_PPBVar_CreateObjectDeprecated(
269       API_ID_PPB_VAR_DEPRECATED, instance, class_int, data_int,
270       &result));
271   PP_Var ret_var = result.Return(dispatcher);
272 
273   // Register this object as being implemented by the plugin.
274   if (ret_var.type == PP_VARTYPE_OBJECT) {
275     tracker->PluginImplementedObjectCreated(instance, ret_var,
276                                             ppp_class, ppp_class_data);
277   }
278   return ret_var;
279 }
280 
281 }  // namespace
282 
PPB_Var_Deprecated_Proxy(Dispatcher * dispatcher)283 PPB_Var_Deprecated_Proxy::PPB_Var_Deprecated_Proxy(Dispatcher* dispatcher)
284     : InterfaceProxy(dispatcher), ppb_var_impl_(nullptr) {
285   if (!dispatcher->IsPlugin()) {
286     ppb_var_impl_ = static_cast<const PPB_Var_Deprecated*>(
287         dispatcher->local_get_interface()(PPB_VAR_DEPRECATED_INTERFACE));
288   }
289 }
290 
~PPB_Var_Deprecated_Proxy()291 PPB_Var_Deprecated_Proxy::~PPB_Var_Deprecated_Proxy() {
292 }
293 
294 // static
GetProxyInterface()295 const PPB_Var_Deprecated* PPB_Var_Deprecated_Proxy::GetProxyInterface() {
296   static const PPB_Var_Deprecated var_deprecated_interface = {
297     ppapi::PPB_Var_Shared::GetVarInterface1_0()->AddRef,
298     ppapi::PPB_Var_Shared::GetVarInterface1_0()->Release,
299     ppapi::PPB_Var_Shared::GetVarInterface1_0()->VarFromUtf8,
300     ppapi::PPB_Var_Shared::GetVarInterface1_0()->VarToUtf8,
301     &HasProperty,
302     &HasMethod,
303     &GetProperty,
304     &EnumerateProperties,
305     &SetProperty,
306     &RemoveProperty,
307     &Call,
308     &Construct,
309     &IsInstanceOf,
310     &CreateObject
311   };
312   return &var_deprecated_interface;
313 }
314 
OnMessageReceived(const IPC::Message & msg)315 bool PPB_Var_Deprecated_Proxy::OnMessageReceived(const IPC::Message& msg) {
316   if (!dispatcher()->permissions().HasPermission(PERMISSION_FLASH))
317     return false;
318 
319   // Prevent the dispatcher from going away during a call to Call or other
320   // function that could mutate the DOM. This must happen OUTSIDE of
321   // the message handlers since the SerializedVars use the dispatcher upon
322   // return of the function (converting the SerializedVarReturnValue/OutParam
323   // to a SerializedVar in the destructor).
324   ScopedModuleReference death_grip(dispatcher());
325 
326   bool handled = true;
327   IPC_BEGIN_MESSAGE_MAP(PPB_Var_Deprecated_Proxy, msg)
328     IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVar_AddRefObject, OnMsgAddRefObject)
329     IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVar_ReleaseObject, OnMsgReleaseObject)
330     IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVar_HasProperty,
331                         OnMsgHasProperty)
332     IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVar_HasMethodDeprecated,
333                         OnMsgHasMethodDeprecated)
334     IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVar_GetProperty,
335                         OnMsgGetProperty)
336     IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVar_DeleteProperty,
337                         OnMsgDeleteProperty)
338     IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVar_EnumerateProperties,
339                         OnMsgEnumerateProperties)
340     IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVar_SetPropertyDeprecated,
341                         OnMsgSetPropertyDeprecated)
342     IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVar_CallDeprecated,
343                         OnMsgCallDeprecated)
344     IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVar_Construct,
345                         OnMsgConstruct)
346     IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVar_IsInstanceOfDeprecated,
347                         OnMsgIsInstanceOfDeprecated)
348     IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVar_CreateObjectDeprecated,
349                         OnMsgCreateObjectDeprecated)
350     IPC_MESSAGE_UNHANDLED(handled = false)
351   IPC_END_MESSAGE_MAP()
352   // TODO(brettw) handle bad messages!
353   return handled;
354 }
355 
OnMsgAddRefObject(int64_t object_id)356 void PPB_Var_Deprecated_Proxy::OnMsgAddRefObject(int64_t object_id) {
357   PP_Var var = { PP_VARTYPE_OBJECT };
358   var.value.as_id = object_id;
359   ppb_var_impl_->AddRef(var);
360 }
361 
OnMsgReleaseObject(int64_t object_id)362 void PPB_Var_Deprecated_Proxy::OnMsgReleaseObject(int64_t object_id) {
363   // Ok, so this is super subtle.
364   // When the browser side sends a sync IPC message that returns a var, and the
365   // plugin wants to give ownership of that var to the browser, dropping all
366   // references, it may call ReleaseObject right after returning the result.
367   // However, the IPC system doesn't enforce strict ordering of messages in that
368   // case, where a message that is set to unblock (e.g. a sync message, or in
369   // our case all messages coming from the plugin) that is sent *after* the
370   // result may be dispatched on the browser side *before* the sync send
371   // returned (see ipc_sync_channel.cc). In this case, that means it could
372   // release the object before it is AddRef'ed on the browser side.
373   // To work around this, we post a task here, that will not execute before
374   // control goes back to the main message loop, that will ensure the sync send
375   // has returned and the browser side can take its reference before we Release.
376   // Note: if the instance is gone by the time the task is executed, then it
377   // will Release the objects itself and this Release will be a NOOP (aside of a
378   // spurious warning).
379   // TODO(piman): See if we can fix the IPC code to enforce strict ordering, and
380   // then remove this.
381   PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostNonNestableTask(
382       FROM_HERE,
383       RunWhileLocked(base::BindOnce(&PPB_Var_Deprecated_Proxy::DoReleaseObject,
384                                     task_factory_.GetWeakPtr(), object_id)));
385 }
386 
OnMsgHasProperty(SerializedVarReceiveInput var,SerializedVarReceiveInput name,SerializedVarOutParam exception,PP_Bool * result)387 void PPB_Var_Deprecated_Proxy::OnMsgHasProperty(
388     SerializedVarReceiveInput var,
389     SerializedVarReceiveInput name,
390     SerializedVarOutParam exception,
391     PP_Bool* result) {
392   SetAllowPluginReentrancy();
393   *result = PP_FromBool(ppb_var_impl_->HasProperty(
394       var.Get(dispatcher()),
395       name.Get(dispatcher()),
396       exception.OutParam(dispatcher())));
397 }
398 
OnMsgHasMethodDeprecated(SerializedVarReceiveInput var,SerializedVarReceiveInput name,SerializedVarOutParam exception,PP_Bool * result)399 void PPB_Var_Deprecated_Proxy::OnMsgHasMethodDeprecated(
400     SerializedVarReceiveInput var,
401     SerializedVarReceiveInput name,
402     SerializedVarOutParam exception,
403     PP_Bool* result) {
404   SetAllowPluginReentrancy();
405   *result = PP_FromBool(ppb_var_impl_->HasMethod(
406       var.Get(dispatcher()),
407       name.Get(dispatcher()),
408       exception.OutParam(dispatcher())));
409 }
410 
OnMsgGetProperty(SerializedVarReceiveInput var,SerializedVarReceiveInput name,SerializedVarOutParam exception,SerializedVarReturnValue result)411 void PPB_Var_Deprecated_Proxy::OnMsgGetProperty(
412     SerializedVarReceiveInput var,
413     SerializedVarReceiveInput name,
414     SerializedVarOutParam exception,
415     SerializedVarReturnValue result) {
416   SetAllowPluginReentrancy();
417   result.Return(dispatcher(), ppb_var_impl_->GetProperty(
418       var.Get(dispatcher()), name.Get(dispatcher()),
419       exception.OutParam(dispatcher())));
420 }
421 
OnMsgEnumerateProperties(SerializedVarReceiveInput var,SerializedVarVectorOutParam props,SerializedVarOutParam exception)422 void PPB_Var_Deprecated_Proxy::OnMsgEnumerateProperties(
423     SerializedVarReceiveInput var,
424     SerializedVarVectorOutParam props,
425     SerializedVarOutParam exception) {
426   SetAllowPluginReentrancy();
427   ppb_var_impl_->GetAllPropertyNames(var.Get(dispatcher()),
428       props.CountOutParam(), props.ArrayOutParam(dispatcher()),
429       exception.OutParam(dispatcher()));
430 }
431 
OnMsgSetPropertyDeprecated(SerializedVarReceiveInput var,SerializedVarReceiveInput name,SerializedVarReceiveInput value,SerializedVarOutParam exception)432 void PPB_Var_Deprecated_Proxy::OnMsgSetPropertyDeprecated(
433     SerializedVarReceiveInput var,
434     SerializedVarReceiveInput name,
435     SerializedVarReceiveInput value,
436     SerializedVarOutParam exception) {
437   SetAllowPluginReentrancy();
438   ppb_var_impl_->SetProperty(var.Get(dispatcher()),
439                                 name.Get(dispatcher()),
440                                 value.Get(dispatcher()),
441                                 exception.OutParam(dispatcher()));
442 }
443 
OnMsgDeleteProperty(SerializedVarReceiveInput var,SerializedVarReceiveInput name,SerializedVarOutParam exception,PP_Bool * result)444 void PPB_Var_Deprecated_Proxy::OnMsgDeleteProperty(
445     SerializedVarReceiveInput var,
446     SerializedVarReceiveInput name,
447     SerializedVarOutParam exception,
448     PP_Bool* result) {
449   SetAllowPluginReentrancy();
450   ppb_var_impl_->RemoveProperty(var.Get(dispatcher()),
451                                    name.Get(dispatcher()),
452                                    exception.OutParam(dispatcher()));
453   // This deprecated function doesn't actually return a value, but we re-use
454   // the message from the non-deprecated interface with the return value.
455   *result = PP_TRUE;
456 }
457 
OnMsgCallDeprecated(SerializedVarReceiveInput object,SerializedVarReceiveInput method_name,SerializedVarVectorReceiveInput arg_vector,SerializedVarOutParam exception,SerializedVarReturnValue result)458 void PPB_Var_Deprecated_Proxy::OnMsgCallDeprecated(
459     SerializedVarReceiveInput object,
460     SerializedVarReceiveInput method_name,
461     SerializedVarVectorReceiveInput arg_vector,
462     SerializedVarOutParam exception,
463     SerializedVarReturnValue result) {
464   SetAllowPluginReentrancy();
465   uint32_t arg_count = 0;
466   PP_Var* args = arg_vector.Get(dispatcher(), &arg_count);
467   result.Return(dispatcher(), ppb_var_impl_->Call(
468       object.Get(dispatcher()),
469       method_name.Get(dispatcher()),
470       arg_count, args,
471       exception.OutParam(dispatcher())));
472 }
473 
OnMsgConstruct(SerializedVarReceiveInput var,SerializedVarVectorReceiveInput arg_vector,SerializedVarOutParam exception,SerializedVarReturnValue result)474 void PPB_Var_Deprecated_Proxy::OnMsgConstruct(
475     SerializedVarReceiveInput var,
476     SerializedVarVectorReceiveInput arg_vector,
477     SerializedVarOutParam exception,
478     SerializedVarReturnValue result) {
479   SetAllowPluginReentrancy();
480   uint32_t arg_count = 0;
481   PP_Var* args = arg_vector.Get(dispatcher(), &arg_count);
482   result.Return(dispatcher(), ppb_var_impl_->Construct(
483       var.Get(dispatcher()), arg_count, args,
484       exception.OutParam(dispatcher())));
485 }
486 
OnMsgIsInstanceOfDeprecated(SerializedVarReceiveInput var,int64_t ppp_class,int64_t * ppp_class_data,PP_Bool * result)487 void PPB_Var_Deprecated_Proxy::OnMsgIsInstanceOfDeprecated(
488     SerializedVarReceiveInput var,
489     int64_t ppp_class,
490     int64_t* ppp_class_data,
491     PP_Bool* result) {
492   SetAllowPluginReentrancy();
493   *result = PPP_Class_Proxy::IsInstanceOf(ppb_var_impl_,
494                                           var.Get(dispatcher()),
495                                           ppp_class,
496                                           ppp_class_data);
497 }
498 
OnMsgCreateObjectDeprecated(PP_Instance instance,int64_t ppp_class,int64_t class_data,SerializedVarReturnValue result)499 void PPB_Var_Deprecated_Proxy::OnMsgCreateObjectDeprecated(
500     PP_Instance instance,
501     int64_t ppp_class,
502     int64_t class_data,
503     SerializedVarReturnValue result) {
504   SetAllowPluginReentrancy();
505   result.Return(dispatcher(), PPP_Class_Proxy::CreateProxiedObject(
506       ppb_var_impl_, dispatcher(), instance, ppp_class, class_data));
507 }
508 
SetAllowPluginReentrancy()509 void PPB_Var_Deprecated_Proxy::SetAllowPluginReentrancy() {
510   if (dispatcher()->IsPlugin())
511     NOTREACHED();
512   else
513     static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy();
514 }
515 
DoReleaseObject(int64_t object_id)516 void PPB_Var_Deprecated_Proxy::DoReleaseObject(int64_t object_id) {
517   PP_Var var = { PP_VARTYPE_OBJECT };
518   var.value.as_id = object_id;
519   ppb_var_impl_->Release(var);
520 }
521 
522 }  // namespace proxy
523 }  // namespace ppapi
524