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

Unified Diff: net/base/ip_endpoint.cc

Issue 1540413002: net: add a ctor to IPEndPoint that takes an IPAddress (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/ip_endpoint.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/ip_endpoint.cc
diff --git a/net/base/ip_endpoint.cc b/net/base/ip_endpoint.cc
index f7f7b1822336c7408ef40a2d53ee5f30c4902e9b..00ac3d90b766f953f3c6a2f54295c4bca718538b 100644
--- a/net/base/ip_endpoint.cc
+++ b/net/base/ip_endpoint.cc
@@ -4,25 +4,31 @@
#include "net/base/ip_endpoint.h"
-#include <tuple>
+#include "build/build_config.h"
-#include "base/logging.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/sys_byteorder.h"
#if defined(OS_WIN)
#include <winsock2.h>
#elif defined(OS_POSIX)
#include <netinet/in.h>
#endif
+
+#include <tuple>
+
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/sys_byteorder.h"
+#include "net/base/ip_address.h"
#include "net/base/net_util.h"
namespace net {
namespace {
+
// By definition, socklen_t is large enough to hold both sizes.
const socklen_t kSockaddrInSize = sizeof(struct sockaddr_in);
const socklen_t kSockaddrIn6Size = sizeof(struct sockaddr_in6);
-}
+
+} // namespace
IPEndPoint::IPEndPoint() : port_(0) {}
@@ -32,6 +38,10 @@ IPEndPoint::IPEndPoint(const IPAddressNumber& address, uint16_t port)
: address_(address), port_(port) {
}
+IPEndPoint::IPEndPoint(const IPAddress& address, uint16_t port)
+ : address_(address.bytes()), port_(port) {
+}
+
IPEndPoint::IPEndPoint(const IPEndPoint& endpoint) {
address_ = endpoint.address_;
port_ = endpoint.port_;
« no previous file with comments | « net/base/ip_endpoint.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698