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

Side by Side Diff: net/base/ip_endpoint.cc

Issue 11528012: [net] Make IPEndPoint::GetFamily() return AddressFamily and add GetSockAddrFamily() to be used when… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update uses of GetFamily in net/dns/ Created 8 years 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
« no previous file with comments | « net/base/ip_endpoint.h ('k') | net/dns/address_sorter_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/base/ip_endpoint.h" 5 #include "net/base/ip_endpoint.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/sys_byteorder.h" 9 #include "base/sys_byteorder.h"
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
(...skipping 16 matching lines...) Expand all
27 27
28 IPEndPoint::IPEndPoint(const IPAddressNumber& address, int port) 28 IPEndPoint::IPEndPoint(const IPAddressNumber& address, int port)
29 : address_(address), 29 : address_(address),
30 port_(port) {} 30 port_(port) {}
31 31
32 IPEndPoint::IPEndPoint(const IPEndPoint& endpoint) { 32 IPEndPoint::IPEndPoint(const IPEndPoint& endpoint) {
33 address_ = endpoint.address_; 33 address_ = endpoint.address_;
34 port_ = endpoint.port_; 34 port_ = endpoint.port_;
35 } 35 }
36 36
37 int IPEndPoint::GetFamily() const { 37 AddressFamily IPEndPoint::GetFamily() const {
38 switch (address_.size()) {
39 case kIPv4AddressSize:
40 return ADDRESS_FAMILY_IPV4;
41 case kIPv6AddressSize:
42 return ADDRESS_FAMILY_IPV6;
43 default:
44 NOTREACHED() << "Bad IP address";
45 return ADDRESS_FAMILY_UNSPECIFIED;
46 }
47 }
48
49 int IPEndPoint::GetSockAddrFamily() const {
38 switch (address_.size()) { 50 switch (address_.size()) {
39 case kIPv4AddressSize: 51 case kIPv4AddressSize:
40 return AF_INET; 52 return AF_INET;
41 case kIPv6AddressSize: 53 case kIPv6AddressSize:
42 return AF_INET6; 54 return AF_INET6;
43 default: 55 default:
44 NOTREACHED() << "Bad IP address"; 56 NOTREACHED() << "Bad IP address";
45 return AF_UNSPEC; 57 return AF_UNSPEC;
46 } 58 }
47 } 59 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return address_ < that.address_; 126 return address_ < that.address_;
115 } 127 }
116 return port_ < that.port_; 128 return port_ < that.port_;
117 } 129 }
118 130
119 bool IPEndPoint::operator==(const IPEndPoint& that) const { 131 bool IPEndPoint::operator==(const IPEndPoint& that) const {
120 return address_ == that.address_ && port_ == that.port_; 132 return address_ == that.address_ && port_ == that.port_;
121 } 133 }
122 134
123 } // namespace net 135 } // namespace net
OLDNEW
« no previous file with comments | « net/base/ip_endpoint.h ('k') | net/dns/address_sorter_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698