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

Unified Diff: extensions/browser/api/socket/udp_socket.cc

Issue 721273002: Remove timing limitation to set Broadcast, ReceiveBuffer, and SendBuffer options from UDPSocket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « cloud_print/gcp20/prototype/dns_sd_server.cc ('k') | media/cast/net/udp_transport.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/socket/udp_socket.cc
diff --git a/extensions/browser/api/socket/udp_socket.cc b/extensions/browser/api/socket/udp_socket.cc
index d8f3eae3f4a74cf33b65767d1ab5d081c5e8eac0..42d7bc3e3849fe1dd030c0d713dad53ab6adc4b6 100644
--- a/extensions/browser/api/socket/udp_socket.cc
+++ b/extensions/browser/api/socket/udp_socket.cc
@@ -49,8 +49,16 @@ void UDPSocket::Connect(const std::string& address,
break;
}
+ result = socket_.Open(ip_end_point.GetFamily());
+ if (result != net::OK)
+ break;
+
result = socket_.Connect(ip_end_point);
- is_connected_ = (result == net::OK);
+ if (result != net::OK) {
+ socket_.Close();
+ break;
+ }
+ is_connected_ = true;
} while (false);
callback.Run(result);
@@ -64,7 +72,14 @@ int UDPSocket::Bind(const std::string& address, uint16 port) {
if (!StringAndPortToIPEndPoint(address, port, &ip_end_point))
return net::ERR_INVALID_ARGUMENT;
- return socket_.Bind(ip_end_point);
+ int result = socket_.Open(ip_end_point.GetFamily());
+ if (result != net::OK)
+ return result;
+
+ result = socket_.Bind(ip_end_point);
+ if (result != net::OK)
+ socket_.Close();
+ return result;
}
void UDPSocket::Disconnect() {
« no previous file with comments | « cloud_print/gcp20/prototype/dns_sd_server.cc ('k') | media/cast/net/udp_transport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698