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_PPAPI_PARAM_TRAITS_H_
      6 #define PPAPI_PROXY_PPAPI_PARAM_TRAITS_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "ipc/ipc_message_utils.h"
     12 #include "ipc/ipc_platform_file.h"
     13 #include "ppapi/c/pp_completion_callback.h"
     14 #include "ppapi/c/pp_rect.h"
     15 #include "ppapi/c/pp_var.h"
     16 #include "ppapi/proxy/ppapi_proxy_export.h"
     17 #include "ppapi/shared_impl/compositor_layer_data.h"
     18 #include "ppapi/shared_impl/file_path.h"
     19 #include "ppapi/shared_impl/file_ref_create_info.h"
     20 #include "ppapi/shared_impl/media_stream_video_track_shared.h"
     21 #include "ppapi/shared_impl/ppapi_permissions.h"
     22 #include "ppapi/shared_impl/socket_option_data.h"
     23 
     24 struct PP_NetAddress_Private;
     25 
     26 namespace ppapi {
     27 
     28 class HostResource;
     29 class PPB_X509Certificate_Fields;
     30 
     31 namespace proxy {
     32 
     33 struct PPBFlash_DrawGlyphs_Params;
     34 struct PPBURLLoader_UpdateProgress_Params;
     35 struct SerializedDirEntry;
     36 struct SerializedFontDescription;
     37 struct SerializedTrueTypeFontDesc;
     38 class SerializedFlashMenu;
     39 class SerializedHandle;
     40 class SerializedVar;
     41 
     42 }  // namespace proxy
     43 }  // namespace ppapi
     44 
     45 namespace IPC {
     46 
     47 template<>
     48 struct PPAPI_PROXY_EXPORT ParamTraits<PP_Bool> {
     49   typedef PP_Bool param_type;
     50   static void Write(Message* m, const param_type& p);
     51   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
     52   static void Log(const param_type& p, std::string* l);
     53 };
     54 
     55 template <>
     56 struct PPAPI_PROXY_EXPORT ParamTraits<PP_NetAddress_Private> {
     57   typedef PP_NetAddress_Private param_type;
     58   static void Write(Message* m, const param_type& p);
     59   static bool Read(const Message* m, PickleIterator* iter, param_type* p);
     60   static void Log(const param_type& p, std::string* l);
     61 };
     62 
     63 template<>
     64 struct PPAPI_PROXY_EXPORT ParamTraits<
     65     ppapi::proxy::PPBFlash_DrawGlyphs_Params> {
     66   typedef ppapi::proxy::PPBFlash_DrawGlyphs_Params param_type;
     67   static void Write(Message* m, const param_type& p);
     68   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
     69   static void Log(const param_type& p, std::string* l);
     70 };
     71 
     72 template<>
     73 struct PPAPI_PROXY_EXPORT ParamTraits<
     74     ppapi::proxy::PPBURLLoader_UpdateProgress_Params> {
     75   typedef ppapi::proxy::PPBURLLoader_UpdateProgress_Params param_type;
     76   static void Write(Message* m, const param_type& p);
     77   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
     78   static void Log(const param_type& p, std::string* l);
     79 };
     80 
     81 template<>
     82 struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedDirEntry> {
     83   typedef ppapi::proxy::SerializedDirEntry param_type;
     84   static void Write(Message* m, const param_type& p);
     85   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
     86   static void Log(const param_type& p, std::string* l);
     87 };
     88 
     89 template<>
     90 struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedFontDescription> {
     91   typedef ppapi::proxy::SerializedFontDescription param_type;
     92   static void Write(Message* m, const param_type& p);
     93   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
     94   static void Log(const param_type& p, std::string* l);
     95 };
     96 
     97 template<>
     98 struct PPAPI_PROXY_EXPORT
     99     ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc> {
    100   typedef ppapi::proxy::SerializedTrueTypeFontDesc param_type;
    101   static void Write(Message* m, const param_type& p);
    102   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
    103   static void Log(const param_type& p, std::string* l);
    104 };
    105 
    106 template<>
    107 struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedHandle> {
    108   typedef ppapi::proxy::SerializedHandle param_type;
    109   static void Write(Message* m, const param_type& p);
    110   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
    111   static void Log(const param_type& p, std::string* l);
    112 };
    113 
    114 template<>
    115 struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::HostResource> {
    116   typedef ppapi::HostResource param_type;
    117   static void Write(Message* m, const param_type& p);
    118   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
    119   static void Log(const param_type& p, std::string* l);
    120 };
    121 
    122 template<>
    123 struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedVar> {
    124   typedef ppapi::proxy::SerializedVar param_type;
    125   static void Write(Message* m, const param_type& p);
    126   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
    127   static void Log(const param_type& p, std::string* l);
    128 };
    129 
    130 template<>
    131 struct PPAPI_PROXY_EXPORT ParamTraits<
    132     std::vector<ppapi::proxy::SerializedVar> > {
    133   typedef std::vector<ppapi::proxy::SerializedVar> param_type;
    134   static void Write(Message* m, const param_type& p);
    135   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
    136   static void Log(const param_type& p, std::string* l);
    137 };
    138 
    139 template<>
    140 struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::PpapiPermissions> {
    141   typedef ppapi::PpapiPermissions param_type;
    142   static void Write(Message* m, const param_type& p);
    143   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
    144   static void Log(const param_type& p, std::string* l);
    145 };
    146 
    147 #if !defined(OS_NACL) && !defined(NACL_WIN64)
    148 template <>
    149 struct ParamTraits<ppapi::PepperFilePath> {
    150   typedef ppapi::PepperFilePath param_type;
    151   static void Write(Message* m, const param_type& p);
    152   static bool Read(const Message* m, PickleIterator* iter, param_type* p);
    153   static void Log(const param_type& p, std::string* l);
    154 };
    155 
    156 template<>
    157 struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedFlashMenu> {
    158   typedef ppapi::proxy::SerializedFlashMenu param_type;
    159   static void Write(Message* m, const param_type& p);
    160   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
    161   static void Log(const param_type& p, std::string* l);
    162 };
    163 #endif  // !defined(OS_NACL) && !defined(NACL_WIN64)
    164 
    165 template<>
    166 struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::PPB_X509Certificate_Fields> {
    167   typedef ppapi::PPB_X509Certificate_Fields param_type;
    168   static void Write(Message* m, const param_type& p);
    169   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
    170   static void Log(const param_type& p, std::string* l);
    171 };
    172 
    173 template<>
    174 struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::SocketOptionData> {
    175   typedef ppapi::SocketOptionData param_type;
    176   static void Write(Message* m, const param_type& p);
    177   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
    178   static void Log(const param_type& p, std::string* l);
    179 };
    180 
    181 template<>
    182 struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::CompositorLayerData::Transform> {
    183   typedef ppapi::CompositorLayerData::Transform param_type;
    184   static void Write(Message* m, const param_type& p);
    185   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
    186   static void Log(const param_type& p, std::string* l);
    187 };
    188 
    189 }  // namespace IPC
    190 
    191 #endif  // PPAPI_PROXY_PPAPI_PARAM_TRAITS_H_
    192