| 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/socket.h" | 5 #include "chrome/browser/extensions/api/socket/socket.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" | 8 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" |
| 9 #include "net/base/address_list.h" | 9 #include "net/base/address_list.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 *address_list = net::AddressList::CreateFromIPAddress(ip_number, port); | 73 *address_list = net::AddressList::CreateFromIPAddress(ip_number, port); |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void Socket::IPEndPointToStringAndPort(const net::IPEndPoint& address, | 77 void Socket::IPEndPointToStringAndPort(const net::IPEndPoint& address, |
| 78 std::string* ip_address_str, | 78 std::string* ip_address_str, |
| 79 int* port) { | 79 int* port) { |
| 80 DCHECK(ip_address_str); | 80 DCHECK(ip_address_str); |
| 81 DCHECK(port); | 81 DCHECK(port); |
| 82 struct sockaddr_storage addr; | 82 *ip_address_str = address.ToStringWithoutPort(); |
| 83 size_t addr_len = sizeof(addr); | 83 if (ip_address_str->empty()) { |
| 84 if (address.ToSockAddr(reinterpret_cast<struct sockaddr*>(&addr), | 84 *port = 0; |
| 85 &addr_len)) { | 85 } else { |
| 86 *ip_address_str = net::NetAddressToString( | |
| 87 reinterpret_cast<struct sockaddr*>(&addr), addr_len); | |
| 88 *port = address.port(); | 86 *port = address.port(); |
| 89 } else { | |
| 90 *ip_address_str = ""; | |
| 91 *port = 0; | |
| 92 } | 87 } |
| 93 } | 88 } |
| 94 | 89 |
| 95 } // namespace extensions | 90 } // namespace extensions |
| OLD | NEW |