1 // Copyright 2013 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_NET_ADDRESS_RESOURCE_H_ 6 #define PPAPI_PROXY_NET_ADDRESS_RESOURCE_H_ 7 8 #include "base/basictypes.h" 9 #include "base/compiler_specific.h" 10 #include "ppapi/c/private/ppb_net_address_private.h" 11 #include "ppapi/proxy/plugin_resource.h" 12 #include "ppapi/proxy/ppapi_proxy_export.h" 13 #include "ppapi/thunk/ppb_net_address_api.h" 14 15 namespace ppapi { 16 namespace proxy { 17 18 class PPAPI_PROXY_EXPORT NetAddressResource : public PluginResource, 19 public thunk::PPB_NetAddress_API { 20 public: 21 NetAddressResource(Connection connection, 22 PP_Instance instance, 23 const PP_NetAddress_IPv4& ipv4_addr); 24 NetAddressResource(Connection connection, 25 PP_Instance instance, 26 const PP_NetAddress_IPv6& ipv6_addr); 27 NetAddressResource(Connection connection, 28 PP_Instance instance, 29 const PP_NetAddress_Private& private_addr); 30 31 virtual ~NetAddressResource(); 32 33 // PluginResource implementation. 34 virtual thunk::PPB_NetAddress_API* AsPPB_NetAddress_API() OVERRIDE; 35 36 // PPB_NetAddress_API implementation. 37 virtual PP_NetAddress_Family GetFamily() OVERRIDE; 38 virtual PP_Var DescribeAsString(PP_Bool include_port) OVERRIDE; 39 virtual PP_Bool DescribeAsIPv4Address( 40 PP_NetAddress_IPv4* ipv4_addr) OVERRIDE; 41 virtual PP_Bool DescribeAsIPv6Address( 42 PP_NetAddress_IPv6* ipv6_addr) OVERRIDE; 43 virtual const PP_NetAddress_Private& GetNetAddressPrivate() OVERRIDE; 44 45 private: 46 // TODO(yzshen): Refactor the code so that PPB_NetAddress resource doesn't 47 // use PP_NetAddress_Private as storage type. 48 PP_NetAddress_Private address_; 49 50 DISALLOW_COPY_AND_ASSIGN(NetAddressResource); 51 }; 52 53 } // namespace proxy 54 } // namespace ppapi 55 56 #endif // PPAPI_PROXY_NET_ADDRESS_RESOURCE_H_ 57