Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/api/socket/udp_socket.h" | 5 #include "chrome/browser/extensions/api/socket/udp_socket.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/api/api_resource.h" | 9 #include "chrome/browser/extensions/api/api_resource.h" |
| 10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 normalized_address); | 236 normalized_address); |
| 237 if (find_result != multicast_groups_.end()) | 237 if (find_result != multicast_groups_.end()) |
| 238 return net::ERR_ADDRESS_INVALID; | 238 return net::ERR_ADDRESS_INVALID; |
| 239 | 239 |
| 240 int rv = socket_.JoinGroup(ip); | 240 int rv = socket_.JoinGroup(ip); |
| 241 if (rv == 0) | 241 if (rv == 0) |
| 242 multicast_groups_.push_back(normalized_address); | 242 multicast_groups_.push_back(normalized_address); |
| 243 return rv; | 243 return rv; |
| 244 } | 244 } |
| 245 | 245 |
| 246 int UDPSocket::AllowAddressReuse() { | |
| 247 if (socket_.is_connected()) { | |
| 248 return net::ERR_UNEXPECTED; | |
| 249 } | |
| 250 socket_.AllowAddressReuse(); | |
| 251 return net::OK; | |
|
mmenke
2013/05/24 21:12:00
I think "return 0;" is actually more consistent wi
Noam Samuel
2013/05/24 21:43:53
Done.
| |
| 252 } | |
| 253 | |
| 246 int UDPSocket::LeaveGroup(const std::string& address) { | 254 int UDPSocket::LeaveGroup(const std::string& address) { |
| 247 net::IPAddressNumber ip; | 255 net::IPAddressNumber ip; |
| 248 if (!net::ParseIPLiteralToNumber(address, &ip)) | 256 if (!net::ParseIPLiteralToNumber(address, &ip)) |
| 249 return net::ERR_ADDRESS_INVALID; | 257 return net::ERR_ADDRESS_INVALID; |
| 250 | 258 |
| 251 std::string normalized_address = net::IPAddressToString(ip); | 259 std::string normalized_address = net::IPAddressToString(ip); |
| 252 std::vector<std::string>::iterator find_result = | 260 std::vector<std::string>::iterator find_result = |
| 253 std::find(multicast_groups_.begin(), | 261 std::find(multicast_groups_.begin(), |
| 254 multicast_groups_.end(), | 262 multicast_groups_.end(), |
| 255 normalized_address); | 263 normalized_address); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 268 | 276 |
| 269 int UDPSocket::SetMulticastLoopbackMode(bool loopback) { | 277 int UDPSocket::SetMulticastLoopbackMode(bool loopback) { |
| 270 return socket_.SetMulticastLoopbackMode(loopback); | 278 return socket_.SetMulticastLoopbackMode(loopback); |
| 271 } | 279 } |
| 272 | 280 |
| 273 const std::vector<std::string>& UDPSocket::GetJoinedGroups() const { | 281 const std::vector<std::string>& UDPSocket::GetJoinedGroups() const { |
| 274 return multicast_groups_; | 282 return multicast_groups_; |
| 275 } | 283 } |
| 276 | 284 |
| 277 } // namespace extensions | 285 } // namespace extensions |
| OLD | NEW |