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

Unified Diff: media/cast/test/utility/net_utility.cc

Issue 283233002: Cast: Fix udp_transport_unittest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment moved Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cast/test/utility/net_utility.h ('k') | media/cast/transport/transport/udp_transport_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/test/utility/net_utility.cc
diff --git a/media/cast/test/utility/net_utility.cc b/media/cast/test/utility/net_utility.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d0bc2ad328f4df88cc7dbc7f234732019785f40d
--- /dev/null
+++ b/media/cast/test/utility/net_utility.cc
@@ -0,0 +1,36 @@
+// Copyright 2014 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 "media/cast/test/utility/net_utility.h"
+
+#include "base/basictypes.h"
+#include "net/base/net_errors.h"
+#include "net/udp/udp_socket.h"
+
+namespace media {
+namespace cast {
+namespace test {
+
+// TODO(hubbe): Move to /net/.
+net::IPEndPoint GetFreeLocalPort() {
+ net::IPAddressNumber localhost;
+ localhost.push_back(127);
+ localhost.push_back(0);
+ localhost.push_back(0);
+ localhost.push_back(1);
+ scoped_ptr<net::UDPSocket> receive_socket(
+ new net::UDPSocket(net::DatagramSocket::DEFAULT_BIND,
+ net::RandIntCallback(),
+ NULL,
+ net::NetLog::Source()));
+ receive_socket->AllowAddressReuse();
+ CHECK_EQ(net::OK, receive_socket->Bind(net::IPEndPoint(localhost, 0)));
+ net::IPEndPoint endpoint;
+ CHECK_EQ(net::OK, receive_socket->GetLocalAddress(&endpoint));
+ return endpoint;
+}
+
+} // namespace test
+} // namespace cast
+} // namespace media
« no previous file with comments | « media/cast/test/utility/net_utility.h ('k') | media/cast/transport/transport/udp_transport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698