Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: ppapi/cpp/net_address.cc

Issue 17419008: Move PPB_NetAddress out of dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/cpp/net_address.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "ppapi/cpp/net_address.h"
6
7 #include "ppapi/c/pp_bool.h"
8 #include "ppapi/cpp/instance_handle.h"
9 #include "ppapi/cpp/module_impl.h"
10
11 namespace pp {
12
13 namespace {
14
15 template <> const char* interface_name<PPB_NetAddress_1_0>() {
16 return PPB_NETADDRESS_INTERFACE_1_0;
17 }
18
19 } // namespace
20
21 NetAddress::NetAddress() {
22 }
23
24 NetAddress::NetAddress(PassRef, PP_Resource resource)
25 : Resource(PASS_REF, resource) {
26 }
27
28 NetAddress::NetAddress(const InstanceHandle& instance,
29 const PP_NetAddress_IPv4& ipv4_addr) {
30 if (has_interface<PPB_NetAddress_1_0>()) {
31 PassRefFromConstructor(
32 get_interface<PPB_NetAddress_1_0>()->CreateFromIPv4Address(
33 instance.pp_instance(), &ipv4_addr));
34 }
35 }
36
37 NetAddress::NetAddress(const InstanceHandle& instance,
38 const PP_NetAddress_IPv6& ipv6_addr) {
39 if (has_interface<PPB_NetAddress_1_0>()) {
40 PassRefFromConstructor(
41 get_interface<PPB_NetAddress_1_0>()->CreateFromIPv6Address(
42 instance.pp_instance(), &ipv6_addr));
43 }
44 }
45
46 NetAddress::NetAddress(const NetAddress& other) : Resource(other) {
47 }
48
49 NetAddress::~NetAddress() {
50 }
51
52 NetAddress& NetAddress::operator=(const NetAddress& other) {
53 Resource::operator=(other);
54 return *this;
55 }
56
57 // static
58 bool NetAddress::IsAvailable() {
59 return has_interface<PPB_NetAddress_1_0>();
60 }
61
62 PP_NetAddress_Family NetAddress::GetFamily() const {
63 if (has_interface<PPB_NetAddress_1_0>())
64 return get_interface<PPB_NetAddress_1_0>()->GetFamily(pp_resource());
65
66 return PP_NETADDRESS_FAMILY_UNSPECIFIED;
67 }
68
69 Var NetAddress::DescribeAsString(bool include_port) const {
70 if (has_interface<PPB_NetAddress_1_0>()) {
71 return Var(PASS_REF,
72 get_interface<PPB_NetAddress_1_0>()->DescribeAsString(
73 pp_resource(), PP_FromBool(include_port)));
74 }
75
76 return Var();
77 }
78
79 bool NetAddress::DescribeAsIPv4Address(PP_NetAddress_IPv4* ipv4_addr) const {
80 if (has_interface<PPB_NetAddress_1_0>()) {
81 return PP_ToBool(
82 get_interface<PPB_NetAddress_1_0>()->DescribeAsIPv4Address(
83 pp_resource(), ipv4_addr));
84 }
85
86 return false;
87 }
88
89 bool NetAddress::DescribeAsIPv6Address(PP_NetAddress_IPv6* ipv6_addr) const {
90 if (has_interface<PPB_NetAddress_1_0>()) {
91 return PP_ToBool(
92 get_interface<PPB_NetAddress_1_0>()->DescribeAsIPv6Address(
93 pp_resource(), ipv6_addr));
94 }
95
96 return false;
97 }
98
99 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/net_address.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698