| Index: chrome/browser/extensions/api/socket/socket_api.cc
|
| diff --git a/chrome/browser/extensions/api/socket/socket_api.cc b/chrome/browser/extensions/api/socket/socket_api.cc
|
| index 49699d26b932aafe61c2bec7ef0062f6bbd045b7..0dc43ec9b6299e3c9c872776a9454d24cef84d9e 100644
|
| --- a/chrome/browser/extensions/api/socket/socket_api.cc
|
| +++ b/chrome/browser/extensions/api/socket/socket_api.cc
|
| @@ -44,6 +44,9 @@ const char kTCPSocketBindError[] =
|
| "TCP socket does not support bind. For TCP server please use listen.";
|
| const char kMulticastSocketTypeError[] =
|
| "Only UDP socket supports multicast.";
|
| +const char kAddressReuseSocketTypeError[] =
|
| + "There is no need to call AllowReuseAddress on TCP sockets, as TCP sockets"
|
| + " support address reuse by default.";
|
| const char kWildcardAddress[] = "*";
|
| const int kWildcardPort = 0;
|
|
|
| @@ -742,7 +745,6 @@ void SocketJoinGroupFunction::Work() {
|
| SetResult(Value::CreateIntegerValue(result));
|
| }
|
|
|
| -
|
| SocketLeaveGroupFunction::SocketLeaveGroupFunction()
|
| : params_(NULL) {}
|
|
|
| @@ -899,4 +901,36 @@ void SocketGetJoinedGroupsFunction::Work() {
|
| SetResult(values);
|
| }
|
|
|
| +SocketAllowAddressReuseFunction::SocketAllowAddressReuseFunction()
|
| + : params_(NULL) {}
|
| +
|
| +SocketAllowAddressReuseFunction::~SocketAllowAddressReuseFunction() {}
|
| +
|
| +bool SocketAllowAddressReuseFunction::Prepare() {
|
| + params_ = api::socket::AllowAddressReuse::Params::Create(*args_);
|
| + EXTENSION_FUNCTION_VALIDATE(params_.get());
|
| + return true;
|
| +}
|
| +
|
| +void SocketAllowAddressReuseFunction::Work() {
|
| + int result = -1;
|
| + Socket* socket = GetSocket(params_->socket_id);
|
| + if (!socket) {
|
| + error_ = kSocketNotFoundError;
|
| + SetResult(Value::CreateIntegerValue(result));
|
| + return;
|
| + }
|
| +
|
| + if (socket->GetSocketType() != Socket::TYPE_UDP) {
|
| + error_ = kAddressReuseSocketTypeError;
|
| + SetResult(Value::CreateIntegerValue(result));
|
| + return;
|
| + }
|
| +
|
| + result = static_cast<UDPSocket*>(socket)->AllowAddressReuse();
|
| + if (result != 0)
|
| + error_ = net::ErrorToString(result);
|
| + SetResult(Value::CreateIntegerValue(result));
|
| +}
|
| +
|
| } // namespace extensions
|
|
|