Cleanup: Remove vim comment settings, tab width and expansion variables from gyp...
[chromium-blink-merge.git] / ppapi / proxy / net_address_resource.cc
blob9d906a5e0621838495e3b585f3433610f8154073
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.
5 #include "ppapi/proxy/net_address_resource.h"
7 #include <string>
9 #include "ppapi/c/pp_bool.h"
10 #include "ppapi/shared_impl/private/net_address_private_impl.h"
11 #include "ppapi/shared_impl/var.h"
13 namespace ppapi {
14 namespace proxy {
16 NetAddressResource::NetAddressResource(
17 Connection connection,
18 PP_Instance instance,
19 const PP_NetAddress_IPv4& ipv4_addr)
20 : PluginResource(connection, instance) {
21 NetAddressPrivateImpl::CreateNetAddressPrivateFromIPv4Address(ipv4_addr,
22 &address_);
25 NetAddressResource::NetAddressResource(
26 Connection connection,
27 PP_Instance instance,
28 const PP_NetAddress_IPv6& ipv6_addr)
29 : PluginResource(connection, instance) {
30 NetAddressPrivateImpl::CreateNetAddressPrivateFromIPv6Address(ipv6_addr,
31 &address_);
34 NetAddressResource::NetAddressResource(
35 Connection connection,
36 PP_Instance instance,
37 const PP_NetAddress_Private& private_addr)
38 : PluginResource(connection, instance) {
39 address_ = private_addr;
42 NetAddressResource::~NetAddressResource() {
45 thunk::PPB_NetAddress_API* NetAddressResource::AsPPB_NetAddress_API() {
46 return this;
49 PP_NetAddress_Family NetAddressResource::GetFamily() {
50 return NetAddressPrivateImpl::GetFamilyFromNetAddressPrivate(address_);
53 PP_Var NetAddressResource::DescribeAsString(PP_Bool include_port) {
54 std::string description = NetAddressPrivateImpl::DescribeNetAddress(
55 address_, PP_ToBool(include_port));
57 if (description.empty())
58 return PP_MakeUndefined();
59 return StringVar::StringToPPVar(description);
62 PP_Bool NetAddressResource::DescribeAsIPv4Address(
63 PP_NetAddress_IPv4* ipv4_addr) {
64 return PP_FromBool(
65 NetAddressPrivateImpl::DescribeNetAddressPrivateAsIPv4Address(
66 address_, ipv4_addr));
69 PP_Bool NetAddressResource::DescribeAsIPv6Address(
70 PP_NetAddress_IPv6* ipv6_addr) {
71 return PP_FromBool(
72 NetAddressPrivateImpl::DescribeNetAddressPrivateAsIPv6Address(
73 address_, ipv6_addr));
76 const PP_NetAddress_Private& NetAddressResource::GetNetAddressPrivate() {
77 return address_;
80 } // namespace proxy
81 } // namespace ppapi