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_SERIALIZED_STRUCTS_H_ 6#define PPAPI_PROXY_SERIALIZED_STRUCTS_H_ 7 8#include <string> 9#include <vector> 10 11#include "base/logging.h" 12#include "base/memory/shared_memory.h" 13#include "build/build_config.h" 14#include "ppapi/c/dev/ppb_truetype_font_dev.h" 15#include "ppapi/c/pp_bool.h" 16#include "ppapi/c/pp_instance.h" 17#include "ppapi/c/pp_point.h" 18#include "ppapi/c/pp_rect.h" 19#include "ppapi/c/ppb_network_list.h" 20#include "ppapi/c/private/ppb_net_address_private.h" 21#include "ppapi/proxy/ppapi_proxy_export.h" 22#include "ppapi/shared_impl/host_resource.h" 23 24class Pickle; 25struct PP_FontDescription_Dev; 26struct PP_BrowserFont_Trusted_Description; 27 28namespace ppapi { 29namespace proxy { 30 31// PP_FontDescription_Dev/PP_BrowserFontDescription (same definition, different 32// names) has to be redefined with a string in place of the PP_Var used for the 33// face name. 34struct PPAPI_PROXY_EXPORT SerializedFontDescription { 35 SerializedFontDescription(); 36 ~SerializedFontDescription(); 37 38 // Converts a PP_FontDescription_Dev to a SerializedFontDescription. 39 // 40 // The reference of |face| owned by the PP_FontDescription_Dev will be 41 // unchanged and the caller is responsible for freeing it. 42 void SetFromPPFontDescription(const PP_FontDescription_Dev& desc); 43 void SetFromPPBrowserFontDescription( 44 const PP_BrowserFont_Trusted_Description& desc); 45 46 // Converts to a PP_FontDescription_Dev. The face name will have one ref 47 // assigned to it. The caller is responsible for freeing it. 48 void SetToPPFontDescription(PP_FontDescription_Dev* desc) const; 49 void SetToPPBrowserFontDescription( 50 PP_BrowserFont_Trusted_Description* desc) const; 51 52 std::string face; 53 int32_t family; 54 uint32_t size; 55 int32_t weight; 56 PP_Bool italic; 57 PP_Bool small_caps; 58 int32_t letter_spacing; 59 int32_t word_spacing; 60}; 61 62struct PPAPI_PROXY_EXPORT SerializedNetworkInfo { 63 SerializedNetworkInfo(); 64 ~SerializedNetworkInfo(); 65 66 std::string name; 67 PP_NetworkList_Type type; 68 PP_NetworkList_State state; 69 std::vector<PP_NetAddress_Private> addresses; 70 std::string display_name; 71 int mtu; 72}; 73typedef std::vector<SerializedNetworkInfo> SerializedNetworkList; 74 75struct PPAPI_PROXY_EXPORT SerializedTrueTypeFontDesc { 76 SerializedTrueTypeFontDesc(); 77 ~SerializedTrueTypeFontDesc(); 78 79 // Sets this to correspond to the contents of a PP_TrueTypeFontDesc_Dev. 80 // 81 // The reference count of the desc.family PP_Var will be unchanged and the 82 // caller is responsible for releasing it. 83 void SetFromPPTrueTypeFontDesc(const PP_TrueTypeFontDesc_Dev& desc); 84 85 // Converts this to a PP_FontDescription_Dev. 86 // 87 // The desc.family PP_Var will have one reference assigned to it. The caller 88 // is responsible for releasing it. 89 void CopyToPPTrueTypeFontDesc(PP_TrueTypeFontDesc_Dev* desc) const; 90 91 std::string family; 92 PP_TrueTypeFontFamily_Dev generic_family; 93 PP_TrueTypeFontStyle_Dev style; 94 PP_TrueTypeFontWeight_Dev weight; 95 PP_TrueTypeFontWidth_Dev width; 96 PP_TrueTypeFontCharset_Dev charset; 97}; 98 99struct SerializedDirEntry { 100 std::string name; 101 bool is_dir; 102}; 103 104struct PPAPI_PROXY_EXPORT PPBFlash_DrawGlyphs_Params { 105 PPBFlash_DrawGlyphs_Params(); 106 ~PPBFlash_DrawGlyphs_Params(); 107 108 PP_Instance instance; 109 ppapi::HostResource image_data; 110 SerializedFontDescription font_desc; 111 uint32_t color; 112 PP_Point position; 113 PP_Rect clip; 114 float transformation[3][3]; 115 PP_Bool allow_subpixel_aa; 116 std::vector<uint16_t> glyph_indices; 117 std::vector<PP_Point> glyph_advances; 118}; 119 120struct PPBURLLoader_UpdateProgress_Params { 121 PP_Instance instance; 122 ppapi::HostResource resource; 123 int64_t bytes_sent; 124 int64_t total_bytes_to_be_sent; 125 int64_t bytes_received; 126 int64_t total_bytes_to_be_received; 127}; 128 129struct PPPDecryptor_Buffer { 130 ppapi::HostResource resource; 131 uint32_t size; 132 base::SharedMemoryHandle handle; 133}; 134 135// TODO(raymes): Make ImageHandle compatible with SerializedHandle. 136#if defined(OS_WIN) 137typedef HANDLE ImageHandle; 138#else 139typedef base::SharedMemoryHandle ImageHandle; 140#endif 141 142} // namespace proxy 143} // namespace ppapi 144 145#endif // PPAPI_PROXY_SERIALIZED_STRUCTS_H_ 146