Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: chrome/browser/extensions/api/socket/socket.cc

Issue 10309002: Reimplements net::AddressList without struct addrinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: get_canonical_name -> canonical_name. iterator to indexing Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/dns/dns_api.cc ('k') | chrome/browser/extensions/extension_web_socket_proxy_private_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698