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

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

Issue 2378763003: Add ability to reuse address in chrome.sockets.udp
Patch Set: Respond to code reviews, clean up tests Created 4 years, 3 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 | « extensions/browser/api/socket/udp_socket.h ('k') | extensions/browser/api/sockets_udp/sockets_udp_api.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 e65957493849ae6d1b85eb500974e712870ecfe6..133a09be1a6bd8afd6c62114d198e854b1e6af3f 100644
--- a/extensions/browser/api/socket/udp_socket.cc
+++ b/extensions/browser/api/socket/udp_socket.cc
@@ -33,7 +33,8 @@ UDPSocket::UDPSocket(const std::string& owner_extension_id)
socket_(net::DatagramSocket::DEFAULT_BIND,
net::RandIntCallback(),
NULL,
- net::NetLog::Source()) {}
+ net::NetLog::Source()),
+ allow_address_reuse_(false) {}
UDPSocket::~UDPSocket() { Disconnect(); }
@@ -74,6 +75,10 @@ int UDPSocket::Bind(const std::string& address, uint16_t port) {
if (result != net::OK)
return result;
+ if (allow_address_reuse()) {
+ socket_.AllowAddressReuse();
+ }
+
result = socket_.Bind(ip_end_point);
if (result != net::OK)
socket_.Close();
« no previous file with comments | « extensions/browser/api/socket/udp_socket.h ('k') | extensions/browser/api/sockets_udp/sockets_udp_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698