| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/cast/test/utility/net_utility.h" | 5 #include "media/cast/test/utility/net_utility.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 7 #include "net/base/ip_address.h" | 8 #include "net/base/ip_address.h" |
| 8 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 9 #include "net/udp/udp_server_socket.h" | 10 #include "net/udp/udp_server_socket.h" |
| 10 | 11 |
| 11 namespace media { | 12 namespace media { |
| 12 namespace cast { | 13 namespace cast { |
| 13 namespace test { | 14 namespace test { |
| 14 | 15 |
| 15 // TODO(hubbe): Move to /net/. | 16 // TODO(hubbe): Move to /net/. |
| 16 net::IPEndPoint GetFreeLocalPort() { | 17 net::IPEndPoint GetFreeLocalPort() { |
| 17 scoped_ptr<net::UDPServerSocket> receive_socket( | 18 scoped_ptr<net::UDPServerSocket> receive_socket( |
| 18 new net::UDPServerSocket(NULL, net::NetLog::Source())); | 19 new net::UDPServerSocket(NULL, net::NetLog::Source())); |
| 19 receive_socket->AllowAddressReuse(); | 20 receive_socket->AllowAddressReuse(); |
| 20 CHECK_EQ(net::OK, receive_socket->Listen( | 21 CHECK_EQ(net::OK, receive_socket->Listen( |
| 21 net::IPEndPoint(net::IPAddress::IPv4Localhost(), 0))); | 22 net::IPEndPoint(net::IPAddress::IPv4Localhost(), 0))); |
| 22 net::IPEndPoint endpoint; | 23 net::IPEndPoint endpoint; |
| 23 CHECK_EQ(net::OK, receive_socket->GetLocalAddress(&endpoint)); | 24 CHECK_EQ(net::OK, receive_socket->GetLocalAddress(&endpoint)); |
| 24 return endpoint; | 25 return endpoint; |
| 25 } | 26 } |
| 26 | 27 |
| 27 } // namespace test | 28 } // namespace test |
| 28 } // namespace cast | 29 } // namespace cast |
| 29 } // namespace media | 30 } // namespace media |
| OLD | NEW |