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