ppapi_param_traits.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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/ppapi_permissions.h" 19#include "ppapi/shared_impl/ppb_file_ref_shared.h" 20 21struct PP_FileInfo; 22struct PP_ObjectProperty; 23struct PP_NetAddress_Private; 24 25namespace ppapi { 26 27class HostResource; 28class PPB_X509Certificate_Fields; 29 30namespace proxy { 31 32struct PPBFlash_DrawGlyphs_Params; 33struct PPBURLLoader_UpdateProgress_Params; 34struct SerializedDirEntry; 35struct SerializedFontDescription; 36struct SerializedTrueTypeFontDesc; 37class SerializedFlashMenu; 38class SerializedHandle; 39class SerializedVar; 40 41} // namespace proxy 42} // namespace ppapi 43 44namespace IPC { 45 46template<> 47struct PPAPI_PROXY_EXPORT ParamTraits<PP_Bool> { 48 typedef PP_Bool param_type; 49 static void Write(Message* m, const param_type& p); 50 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 51 static void Log(const param_type& p, std::string* l); 52}; 53 54template<> 55struct PPAPI_PROXY_EXPORT ParamTraits<PP_FileInfo> { 56 typedef PP_FileInfo param_type; 57 static void Write(Message* m, const param_type& p); 58 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 59 static void Log(const param_type& p, std::string* l); 60}; 61 62template <> 63struct PPAPI_PROXY_EXPORT ParamTraits<PP_NetAddress_Private> { 64 typedef PP_NetAddress_Private param_type; 65 static void Write(Message* m, const param_type& p); 66 static bool Read(const Message* m, PickleIterator* iter, param_type* p); 67 static void Log(const param_type& p, std::string* l); 68}; 69 70template<> 71struct PPAPI_PROXY_EXPORT ParamTraits<PP_ObjectProperty> { 72 typedef PP_ObjectProperty param_type; 73 static void Write(Message* m, const param_type& p); 74 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 75 static void Log(const param_type& p, std::string* l); 76}; 77 78template<> 79struct PPAPI_PROXY_EXPORT ParamTraits< 80 ppapi::proxy::PPBFlash_DrawGlyphs_Params> { 81 typedef ppapi::proxy::PPBFlash_DrawGlyphs_Params 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 87template<> 88struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::PPB_FileRef_CreateInfo> { 89 typedef ppapi::PPB_FileRef_CreateInfo 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 95template<> 96struct PPAPI_PROXY_EXPORT ParamTraits< 97 ppapi::proxy::PPBURLLoader_UpdateProgress_Params> { 98 typedef ppapi::proxy::PPBURLLoader_UpdateProgress_Params 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 104template<> 105struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedDirEntry> { 106 typedef ppapi::proxy::SerializedDirEntry 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 112template<> 113struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedFontDescription> { 114 typedef ppapi::proxy::SerializedFontDescription 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 120template<> 121struct PPAPI_PROXY_EXPORT 122 ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc> { 123 typedef ppapi::proxy::SerializedTrueTypeFontDesc param_type; 124 static void Write(Message* m, const param_type& p); 125 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 126 static void Log(const param_type& p, std::string* l); 127}; 128 129template<> 130struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedHandle> { 131 typedef ppapi::proxy::SerializedHandle 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 137template<> 138struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::HostResource> { 139 typedef ppapi::HostResource 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 145template<> 146struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedVar> { 147 typedef ppapi::proxy::SerializedVar param_type; 148 static void Write(Message* m, const param_type& p); 149 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 150 static void Log(const param_type& p, std::string* l); 151}; 152 153template<> 154struct PPAPI_PROXY_EXPORT ParamTraits< 155 std::vector<ppapi::proxy::SerializedVar> > { 156 typedef std::vector<ppapi::proxy::SerializedVar> 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 162template<> 163struct PPAPI_PROXY_EXPORT ParamTraits< std::vector< 164 ppapi::PPB_FileRef_CreateInfo> > { 165 typedef std::vector<ppapi::PPB_FileRef_CreateInfo> 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 171template<> 172struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::PpapiPermissions> { 173 typedef ppapi::PpapiPermissions 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#if !defined(OS_NACL) && !defined(NACL_WIN64) 180template <> 181struct ParamTraits<ppapi::PepperFilePath> { 182 typedef ppapi::PepperFilePath param_type; 183 static void Write(Message* m, const param_type& p); 184 static bool Read(const Message* m, PickleIterator* iter, param_type* p); 185 static void Log(const param_type& p, std::string* l); 186}; 187 188template<> 189struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedFlashMenu> { 190 typedef ppapi::proxy::SerializedFlashMenu param_type; 191 static void Write(Message* m, const param_type& p); 192 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 193 static void Log(const param_type& p, std::string* l); 194}; 195#endif // !defined(OS_NACL) && !defined(NACL_WIN64) 196 197template<> 198struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::PPB_X509Certificate_Fields> { 199 typedef ppapi::PPB_X509Certificate_Fields param_type; 200 static void Write(Message* m, const param_type& p); 201 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 202 static void Log(const param_type& p, std::string* l); 203}; 204 205 206} // namespace IPC 207 208#endif // PPAPI_PROXY_PPAPI_PARAM_TRAITS_H_ 209