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_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 
     24 class Pickle;
     25 struct PP_FontDescription_Dev;
     26 struct PP_BrowserFont_Trusted_Description;
     27 
     28 namespace ppapi {
     29 namespace 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.
     34 struct 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 
     62 struct 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 };
     73 typedef std::vector<SerializedNetworkInfo> SerializedNetworkList;
     74 
     75 struct 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 
     99 struct SerializedDirEntry {
    100   std::string name;
    101   bool is_dir;
    102 };
    103 
    104 struct 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 
    120 struct 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 
    129 struct 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)
    137 typedef HANDLE ImageHandle;
    138 #elif defined(TOOLKIT_GTK)
    139 // On legacy X Windows this is a SysV shared memory key.
    140 typedef int ImageHandle;
    141 #else
    142 typedef base::SharedMemoryHandle ImageHandle;
    143 #endif
    144 
    145 }  // namespace proxy
    146 }  // namespace ppapi
    147 
    148 #endif  // PPAPI_PROXY_SERIALIZED_STRUCTS_H_
    149