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

Unified Diff: net/base/tcp_listen_socket.cc

Issue 11236025: Test that debug stub works with browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: remove W00 case - it can't happen Created 8 years 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
Index: net/base/tcp_listen_socket.cc
===================================================================
--- net/base/tcp_listen_socket.cc (revision 170891)
+++ net/base/tcp_listen_socket.cc (working copy)
@@ -76,6 +76,28 @@
return s;
}
+SocketDescriptor TCPListenSocket::CreateAndBindAnyPort(const string& ip,
+ int* port) {
+ SocketDescriptor s = CreateAndBind(ip, 0);
szym 2012/12/05 18:21:37 Check if (s == kInvalidSocket) and return early he
halyavin 2012/12/06 15:35:01 Done.
+ sockaddr_in addr;
+ socklen_t addr_size = sizeof(addr);
+ bool failed = getsockname(s, (struct sockaddr *) &addr, &addr_size) != 0;
Mark Seaborn 2012/12/05 18:00:47 Use reinterpret_cast<> here
halyavin 2012/12/06 15:35:01 Done.
+ if (addr_size != sizeof(addr)) {
+ failed = true;
+ }
+ if (failed) {
+ LOG(ERROR) << "Could not determine bound port, getsockname() failed";
+#if defined(OS_WIN)
+ closesocket(s);
+#elif defined(OS_POSIX)
+ close(s);
+#endif
+ return kInvalidSocket;
+ }
+ *port = base::NetToHost16(addr.sin_port);
+ return s;
+}
+
void TCPListenSocket::Accept() {
SocketDescriptor conn = AcceptSocket();
if (conn == kInvalidSocket)
« chrome/browser/nacl_host/test/debug_stub_browser_tests.py ('K') | « net/base/tcp_listen_socket.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698