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