1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ppapi/proxy/net_address_resource.h"
#include <string>
#include "ppapi/c/pp_bool.h"
#include "ppapi/shared_impl/private/net_address_private_impl.h"
#include "ppapi/shared_impl/var.h"
namespace ppapi {
namespace proxy {
NetAddressResource::NetAddressResource(
Connection connection,
PP_Instance instance,
const PP_NetAddress_IPv4_Dev& ipv4_addr)
: PluginResource(connection, instance) {
NetAddressPrivateImpl::CreateNetAddressPrivateFromIPv4Address(ipv4_addr,
&address_);
}
NetAddressResource::NetAddressResource(
Connection connection,
PP_Instance instance,
const PP_NetAddress_IPv6_Dev& ipv6_addr)
: PluginResource(connection, instance) {
NetAddressPrivateImpl::CreateNetAddressPrivateFromIPv6Address(ipv6_addr,
&address_);
}
NetAddressResource::NetAddressResource(
Connection connection,
PP_Instance instance,
const PP_NetAddress_Private& private_addr)
: PluginResource(connection, instance) {
address_ = private_addr;
}
NetAddressResource::~NetAddressResource() {
}
thunk::PPB_NetAddress_API* NetAddressResource::AsPPB_NetAddress_API() {
return this;
}
PP_NetAddress_Family_Dev NetAddressResource::GetFamily() {
return NetAddressPrivateImpl::GetFamilyFromNetAddressPrivate(address_);
}
PP_Var NetAddressResource::DescribeAsString(PP_Bool include_port) {
std::string description = NetAddressPrivateImpl::DescribeNetAddress(
address_, PP_ToBool(include_port));
if (description.empty())
return PP_MakeUndefined();
return StringVar::StringToPPVar(description);
}
PP_Bool NetAddressResource::DescribeAsIPv4Address(
PP_NetAddress_IPv4_Dev* ipv4_addr) {
return PP_FromBool(
NetAddressPrivateImpl::DescribeNetAddressPrivateAsIPv4Address(
address_, ipv4_addr));
}
PP_Bool NetAddressResource::DescribeAsIPv6Address(
PP_NetAddress_IPv6_Dev* ipv6_addr) {
return PP_FromBool(
NetAddressPrivateImpl::DescribeNetAddressPrivateAsIPv6Address(
address_, ipv6_addr));
}
const PP_NetAddress_Private& NetAddressResource::GetNetAddressPrivate() {
return address_;
}
} // namespace proxy
} // namespace ppapi
|