Chromium Code Reviews| 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 5b75fc9d1a48d9ad464fba784f46b365be7cf514..806f0b6db75103086a2d52d3daf5b13098a47fef 100644 |
| --- a/chrome/browser/extensions/api/socket/socket_api.cc |
| +++ b/chrome/browser/extensions/api/socket/socket_api.cc |
| @@ -43,6 +43,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 AllowReuseAddress on TCP sockets, as TCP sockets support" |
| + " address reuse by default."; |
|
miket_OOO
2013/05/24 20:53:48
I think you accidentally a word.
Noam Samuel
2013/05/24 21:43:53
Fixed.
|
| const char kWildcardAddress[] = "*"; |
| const int kWildcardPort = 0; |
| @@ -735,7 +738,6 @@ void SocketJoinGroupFunction::Work() { |
| SetResult(Value::CreateIntegerValue(result)); |
| } |
| - |
| SocketLeaveGroupFunction::SocketLeaveGroupFunction() |
| : params_(NULL) {} |
| @@ -889,4 +891,37 @@ void SocketGetJoinedGroupsFunction::Work() { |
| SetResult(values); |
| } |
| +SocketAllowAddressReuseFunction::SocketAllowAddressReuseFunction() |
| + : params_(NULL) {} |
|
mmenke
2013/05/24 21:12:00
nit: Should be 4-space indent.
Noam Samuel
2013/05/24 21:43:53
Done.
|
| + |
| +SocketAllowAddressReuseFunction:: |
| + ~SocketAllowAddressReuseFunction() {} |
|
mmenke
2013/05/24 21:12:00
nit: This should be 4-space indent or 0-space (Bo
Noam Samuel
2013/05/24 21:43:53
Looks like it fits on one line. Not sure why I for
|
| + |
| +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)); |
|
mmenke
2013/05/24 21:12:00
I know this is done elsewhere, but this is really
|
| + 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 |