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

Side by Side Diff: ppapi/cpp/private/net_address_private.cc

Issue 9722008: Add CreateFromIPv[46]Address() in PPB_NetAddress_Private. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/cpp/private/net_address_private.h" 5 #include "ppapi/cpp/private/net_address_private.h"
6 6
7 #include "ppapi/c/pp_bool.h" 7 #include "ppapi/c/pp_bool.h"
8 #include "ppapi/cpp/module.h" 8 #include "ppapi/cpp/module.h"
9 #include "ppapi/cpp/module_impl.h" 9 #include "ppapi/cpp/module_impl.h"
10 #include "ppapi/cpp/var.h" 10 #include "ppapi/cpp/var.h"
11 11
12 namespace pp { 12 namespace pp {
13 13
14 namespace { 14 namespace {
15 15
viettrungluu 2012/03/16 22:19:15 And you need to support 0.1, 1.0, and 1.1.
16 template <> const char* interface_name<PPB_NetAddress_Private_1_0>() { 16 template <> const char* interface_name<PPB_NetAddress_Private_1_0>() {
17 return PPB_NETADDRESS_PRIVATE_INTERFACE_1_0; 17 return PPB_NETADDRESS_PRIVATE_INTERFACE_1_0;
18 } 18 }
19 19
20 template <> const char* interface_name<PPB_NetAddress_Private_0_1>() { 20 template <> const char* interface_name<PPB_NetAddress_Private_0_1>() {
21 return PPB_NETADDRESS_PRIVATE_INTERFACE_0_1; 21 return PPB_NETADDRESS_PRIVATE_INTERFACE_0_1;
22 } 22 }
23 23
24 } // namespace 24 } // namespace
25 25
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 uint16_t address_size) { 133 uint16_t address_size) {
134 if (has_interface<PPB_NetAddress_Private_1_0>()) { 134 if (has_interface<PPB_NetAddress_Private_1_0>()) {
135 return PP_ToBool(get_interface<PPB_NetAddress_Private_1_0>()->GetAddress( 135 return PP_ToBool(get_interface<PPB_NetAddress_Private_1_0>()->GetAddress(
136 &addr, 136 &addr,
137 address, 137 address,
138 address_size)); 138 address_size));
139 } 139 }
140 return false; 140 return false;
141 } 141 }
142 142
143 // static
144 void NetAddressPrivate::CreateFromIPv4Address(
145 const uint8_t ip[4],
146 uint16_t port,
147 struct PP_NetAddress_Private* addr_out) {
148 if (has_interface<PPB_NetAddress_Private_1_0>()) {
149 get_interface<PPB_NetAddress_Private_1_0>()->CreateFromIPv4Address(
150 ip, port, addr_out);
151 }
152 }
153
154 // static
155 void NetAddressPrivate::CreateFromIPv6Address(
156 const uint8_t ip[16],
157 uint32_t scope_id,
158 uint16_t port,
159 struct PP_NetAddress_Private* addr_out) {
160 if (has_interface<PPB_NetAddress_Private_1_0>()) {
161 get_interface<PPB_NetAddress_Private_1_0>()->CreateFromIPv6Address(
162 ip, scope_id, port, addr_out);
163 }
164 }
165
143 } // namespace pp 166 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698