OLD | NEW |
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/tests/test_utils.h" | 5 #include "ppapi/tests/test_utils.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #if defined(_MSC_VER) | 10 #if defined(_MSC_VER) |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 bool ResolveHost(PP_Instance instance, | 133 bool ResolveHost(PP_Instance instance, |
134 const std::string& host, | 134 const std::string& host, |
135 uint16_t port, | 135 uint16_t port, |
136 pp::NetAddress* addr) { | 136 pp::NetAddress* addr) { |
137 // TODO(yzshen): Change to use the public host resolver once it is supported. | 137 // TODO(yzshen): Change to use the public host resolver once it is supported. |
138 pp::InstanceHandle instance_handle(instance); | 138 pp::InstanceHandle instance_handle(instance); |
139 pp::HostResolverPrivate host_resolver(instance_handle); | 139 pp::HostResolverPrivate host_resolver(instance_handle); |
140 PP_HostResolver_Private_Hint hint = { PP_NETADDRESSFAMILY_UNSPECIFIED, 0 }; | 140 PP_HostResolver_Private_Hint hint = |
| 141 { PP_NETADDRESSFAMILY_PRIVATE_UNSPECIFIED, 0 }; |
141 | 142 |
142 TestCompletionCallback callback(instance); | 143 TestCompletionCallback callback(instance); |
143 callback.WaitForResult( | 144 callback.WaitForResult( |
144 host_resolver.Resolve(host, port, hint, callback.GetCallback())); | 145 host_resolver.Resolve(host, port, hint, callback.GetCallback())); |
145 | 146 |
146 PP_NetAddress_Private addr_private; | 147 PP_NetAddress_Private addr_private; |
147 if (callback.result() != PP_OK || host_resolver.GetSize() == 0 || | 148 if (callback.result() != PP_OK || host_resolver.GetSize() == 0 || |
148 !host_resolver.GetNetAddress(0, &addr_private)) { | 149 !host_resolver.GetNetAddress(0, &addr_private)) { |
149 return false; | 150 return false; |
150 } | 151 } |
151 | 152 |
152 switch (pp::NetAddressPrivate::GetFamily(addr_private)) { | 153 switch (pp::NetAddressPrivate::GetFamily(addr_private)) { |
153 case PP_NETADDRESSFAMILY_IPV4: { | 154 case PP_NETADDRESSFAMILY_PRIVATE_IPV4: { |
154 PP_NetAddress_IPv4 ipv4_addr; | 155 PP_NetAddress_IPv4 ipv4_addr; |
155 ipv4_addr.port = ConvertToNetEndian16( | 156 ipv4_addr.port = ConvertToNetEndian16( |
156 pp::NetAddressPrivate::GetPort(addr_private)); | 157 pp::NetAddressPrivate::GetPort(addr_private)); |
157 if (!pp::NetAddressPrivate::GetAddress(addr_private, ipv4_addr.addr, | 158 if (!pp::NetAddressPrivate::GetAddress(addr_private, ipv4_addr.addr, |
158 sizeof(ipv4_addr.addr))) { | 159 sizeof(ipv4_addr.addr))) { |
159 return false; | 160 return false; |
160 } | 161 } |
161 *addr = pp::NetAddress(instance_handle, ipv4_addr); | 162 *addr = pp::NetAddress(instance_handle, ipv4_addr); |
162 return true; | 163 return true; |
163 } | 164 } |
164 case PP_NETADDRESSFAMILY_IPV6: { | 165 case PP_NETADDRESSFAMILY_PRIVATE_IPV6: { |
165 PP_NetAddress_IPv6 ipv6_addr; | 166 PP_NetAddress_IPv6 ipv6_addr; |
166 ipv6_addr.port = ConvertToNetEndian16( | 167 ipv6_addr.port = ConvertToNetEndian16( |
167 pp::NetAddressPrivate::GetPort(addr_private)); | 168 pp::NetAddressPrivate::GetPort(addr_private)); |
168 if (!pp::NetAddressPrivate::GetAddress(addr_private, ipv6_addr.addr, | 169 if (!pp::NetAddressPrivate::GetAddress(addr_private, ipv6_addr.addr, |
169 sizeof(ipv6_addr.addr))) { | 170 sizeof(ipv6_addr.addr))) { |
170 return false; | 171 return false; |
171 } | 172 } |
172 *addr = pp::NetAddress(instance_handle, ipv6_addr); | 173 *addr = pp::NetAddress(instance_handle, ipv6_addr); |
173 return true; | 174 return true; |
174 } | 175 } |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 pp::MessageLoop loop(pp::MessageLoop::GetCurrent()); | 369 pp::MessageLoop loop(pp::MessageLoop::GetCurrent()); |
369 // If we don't have a message loop, we're probably running in process, where | 370 // If we don't have a message loop, we're probably running in process, where |
370 // PPB_MessageLoop is not supported. Just use the Testing message loop. | 371 // PPB_MessageLoop is not supported. Just use the Testing message loop. |
371 if (loop.is_null() || loop == pp::MessageLoop::GetForMainThread()) { | 372 if (loop.is_null() || loop == pp::MessageLoop::GetForMainThread()) { |
372 GetTestingInterface()->QuitMessageLoop(instance_); | 373 GetTestingInterface()->QuitMessageLoop(instance_); |
373 } else { | 374 } else { |
374 const bool should_quit = false; | 375 const bool should_quit = false; |
375 loop.PostQuit(should_quit); | 376 loop.PostQuit(should_quit); |
376 } | 377 } |
377 } | 378 } |
OLD | NEW |