Home | History | Annotate | Download | only in proxy
      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 #ifndef PPAPI_PROXY_PPP_CLASS_PROXY_H_
      6 #define PPAPI_PROXY_PPP_CLASS_PROXY_H_
      7 
      8 #include <vector>
      9 
     10 #include "base/basictypes.h"
     11 #include "ppapi/c/pp_instance.h"
     12 #include "ppapi/c/pp_var.h"
     13 #include "ppapi/proxy/interface_proxy.h"
     14 
     15 struct PPB_Var_Deprecated;
     16 
     17 namespace ppapi {
     18 namespace proxy {
     19 
     20 class SerializedVar;
     21 class SerializedVarReceiveInput;
     22 class SerializedVarVectorReceiveInput;
     23 class SerializedVarOutParam;
     24 class SerializedVarReturnValue;
     25 
     26 class PPP_Class_Proxy : public InterfaceProxy {
     27  public:
     28   // PPP_Class isn't a normal interface that you can query for, so this
     29   // constructor doesn't take an interface pointer.
     30   explicit PPP_Class_Proxy(Dispatcher* dispatcher);
     31   virtual ~PPP_Class_Proxy();
     32 
     33   // Factory function used for registration (normal code can just use the
     34   // constructor).
     35   static InterfaceProxy* Create(Dispatcher* dispatcher);
     36 
     37   // Creates a proxied object in the browser process. This takes the browser's
     38   // PPB_Var_Deprecated interface to use to create the object. The class and
     39   static PP_Var CreateProxiedObject(const PPB_Var_Deprecated* var,
     40                                     Dispatcher* dispatcher,
     41                                     PP_Instance instance_id,
     42                                     int64 ppp_class,
     43                                     int64 class_data);
     44 
     45   static PP_Bool IsInstanceOf(const PPB_Var_Deprecated* ppb_var_impl,
     46                               const PP_Var& var,
     47                               int64 ppp_class,
     48                               int64* ppp_class_data);
     49 
     50   // InterfaceProxy implementation.
     51   virtual bool OnMessageReceived(const IPC::Message& msg);
     52 
     53  private:
     54   // IPC message handlers.
     55   void OnMsgHasProperty(int64 ppp_class, int64 object,
     56                         SerializedVarReceiveInput property,
     57                         SerializedVarOutParam exception,
     58                         bool* result);
     59   void OnMsgHasMethod(int64 ppp_class, int64 object,
     60                       SerializedVarReceiveInput property,
     61                       SerializedVarOutParam exception,
     62                       bool* result);
     63   void OnMsgGetProperty(int64 ppp_class, int64 object,
     64                         SerializedVarReceiveInput property,
     65                         SerializedVarOutParam exception,
     66                         SerializedVarReturnValue result);
     67   void OnMsgEnumerateProperties(
     68       int64 ppp_class, int64 object,
     69       std::vector<SerializedVar>* props,
     70       SerializedVarOutParam exception);
     71   void OnMsgSetProperty(int64 ppp_class, int64 object,
     72                         SerializedVarReceiveInput property,
     73                         SerializedVarReceiveInput value,
     74                         SerializedVarOutParam exception);
     75   void OnMsgRemoveProperty(int64 ppp_class, int64 object,
     76                            SerializedVarReceiveInput property,
     77                            SerializedVarOutParam exception);
     78   void OnMsgCall(int64 ppp_class, int64 object,
     79                  SerializedVarReceiveInput method_name,
     80                  SerializedVarVectorReceiveInput arg_vector,
     81                  SerializedVarOutParam exception,
     82                  SerializedVarReturnValue result);
     83   void OnMsgConstruct(int64 ppp_class, int64 object,
     84                       SerializedVarVectorReceiveInput arg_vector,
     85                       SerializedVarOutParam exception,
     86                       SerializedVarReturnValue result);
     87   void OnMsgDeallocate(int64 ppp_class, int64 object);
     88 
     89   // Returns true if the given class/data points to a plugin-implemented
     90   // object. On failure, the exception, if non-NULL, will also be set.
     91   bool ValidateUserData(int64 ppp_class, int64 class_data,
     92                         SerializedVarOutParam* exception);
     93 
     94   DISALLOW_COPY_AND_ASSIGN(PPP_Class_Proxy);
     95 };
     96 
     97 }  // namespace proxy
     98 }  // namespace ppapi
     99 
    100 #endif  // PPAPI_PROXY_PPP_CLASS_PROXY_H_
    101