diff options
-rw-r--r-- | net/base/ip_address.cc | 8 | ||||
-rw-r--r-- | net/base/ip_address.h | 4 | ||||
-rw-r--r-- | net/http/http_server_properties_impl_unittest.cc | 3 | ||||
-rw-r--r-- | net/http/http_server_properties_manager_unittest.cc | 9 | ||||
-rw-r--r-- | net/http/http_transaction_test_util.cc | 3 | ||||
-rw-r--r-- | net/quic/p2p/quic_p2p_session.cc | 4 | ||||
-rw-r--r-- | net/quic/p2p/quic_p2p_session_test.cc | 3 | ||||
-rw-r--r-- | net/quic/quic_end_to_end_unittest.cc | 3 | ||||
-rw-r--r-- | net/quic/quic_http_stream_test.cc | 3 | ||||
-rw-r--r-- | net/quic/test_tools/quic_test_utils.cc | 8 | ||||
-rw-r--r-- | net/tools/quic/end_to_end_test.cc | 6 | ||||
-rw-r--r-- | net/tools/quic/quic_client.cc | 3 | ||||
-rw-r--r-- | net/tools/quic/quic_simple_client.cc | 3 |
13 files changed, 27 insertions, 33 deletions
diff --git a/net/base/ip_address.cc b/net/base/ip_address.cc index 4076460..f9565e5 100644 --- a/net/base/ip_address.cc +++ b/net/base/ip_address.cc @@ -20,6 +20,14 @@ IPAddress::IPAddress(const IPAddressNumber& address) : ip_address_(address) {} IPAddress::IPAddress(const uint8_t* address, size_t address_len) : ip_address_(address, address + address_len) {} +IPAddress::IPAddress(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3) { + ip_address_.reserve(4); + ip_address_.push_back(b0); + ip_address_.push_back(b1); + ip_address_.push_back(b2); + ip_address_.push_back(b3); +} + IPAddress::~IPAddress() {} bool IPAddress::IsIPv4() const { diff --git a/net/base/ip_address.h b/net/base/ip_address.h index 3969f02..f46eadb 100644 --- a/net/base/ip_address.h +++ b/net/base/ip_address.h @@ -39,6 +39,10 @@ class NET_EXPORT IPAddress { // parameter. The input is expected to be in network byte order. IPAddress(const uint8_t* address, size_t address_len); + // Initializes |ip_address_| from the 4 bX bytes. The bytes are expected to be + // in network byte order. + IPAddress(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3); + ~IPAddress(); // Returns true if the IP has |kIPv4AddressSize| elements. diff --git a/net/http/http_server_properties_impl_unittest.cc b/net/http/http_server_properties_impl_unittest.cc index 73c5c39..d06574f 100644 --- a/net/http/http_server_properties_impl_unittest.cc +++ b/net/http/http_server_properties_impl_unittest.cc @@ -1283,8 +1283,7 @@ TEST_F(SupportsQuicServerPropertiesTest, SetSupportsQuic) { EXPECT_FALSE(impl_.GetSupportsQuic(&address)); EXPECT_TRUE(address.empty()); - IPAddress actual_address; - CHECK(actual_address.AssignFromIPLiteral("127.0.0.1")); + IPAddress actual_address(127, 0, 0, 1); impl_.SetSupportsQuic(true, actual_address); EXPECT_TRUE(impl_.GetSupportsQuic(&address)); diff --git a/net/http/http_server_properties_manager_unittest.cc b/net/http/http_server_properties_manager_unittest.cc index 3d6f6c7..5471fd1 100644 --- a/net/http/http_server_properties_manager_unittest.cc +++ b/net/http/http_server_properties_manager_unittest.cc @@ -820,8 +820,7 @@ TEST_P(HttpServerPropertiesManagerTest, SupportsQuic) { IPAddress address; EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address)); - IPAddress actual_address; - CHECK(actual_address.AssignFromIPLiteral("127.0.0.1")); + IPAddress actual_address(127, 0, 0, 1); http_server_props_manager_->SetSupportsQuic(true, actual_address); // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. http_server_props_manager_->SetSupportsQuic(true, actual_address); @@ -888,8 +887,7 @@ TEST_P(HttpServerPropertiesManagerTest, Clear) { AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com", 1234); http_server_props_manager_->SetAlternativeService( spdy_server_mail, alternative_service, 1.0, one_day_from_now_); - IPAddress actual_address; - CHECK(actual_address.AssignFromIPLiteral("127.0.0.1")); + IPAddress actual_address(127, 0, 0, 1); http_server_props_manager_->SetSupportsQuic(true, actual_address); ServerNetworkStats stats; stats.srtt = base::TimeDelta::FromMicroseconds(10); @@ -1078,8 +1076,7 @@ TEST_P(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) { quic_server_info1); // Set SupportsQuic. - IPAddress actual_address; - CHECK(actual_address.AssignFromIPLiteral("127.0.0.1")); + IPAddress actual_address(127, 0, 0, 1); http_server_props_manager_->SetSupportsQuic(true, actual_address); // Update cache. diff --git a/net/http/http_transaction_test_util.cc b/net/http/http_transaction_test_util.cc index 0e027a2..2298efd 100644 --- a/net/http/http_transaction_test_util.cc +++ b/net/http/http_transaction_test_util.cc @@ -390,8 +390,7 @@ bool MockNetworkTransaction::GetLoadTimingInfo( } bool MockNetworkTransaction::GetRemoteEndpoint(IPEndPoint* endpoint) const { - IPAddress ip_address; - CHECK(ip_address.AssignFromIPLiteral("127.0.0.1")); + IPAddress ip_address(127, 0, 0, 1); *endpoint = IPEndPoint(ip_address, 80); return true; } diff --git a/net/quic/p2p/quic_p2p_session.cc b/net/quic/p2p/quic_p2p_session.cc index 0c1be86..e198399 100644 --- a/net/quic/p2p/quic_p2p_session.cc +++ b/net/quic/p2p/quic_p2p_session.cc @@ -31,9 +31,7 @@ QuicP2PSession::QuicP2PSession(const QuicConfig& config, // ToString() to format addresses for logging and ToString() is not allowed // for empty addresses. // TODO(sergeyu): Fix QuicConnection and remove SetSelfAddress() call below. - net::IPAddress ip; - bool success = ip.AssignFromIPLiteral("0.0.0.0"); - DCHECK(success); + net::IPAddress ip(0, 0, 0, 0); this->connection()->SetSelfAddress(net::IPEndPoint(ip, 0)); } diff --git a/net/quic/p2p/quic_p2p_session_test.cc b/net/quic/p2p/quic_p2p_session_test.cc index 75d1f2c..88dc76c 100644 --- a/net/quic/p2p/quic_p2p_session_test.cc +++ b/net/quic/p2p/quic_p2p_session_test.cc @@ -228,8 +228,7 @@ class QuicP2PSessionTest : public ::testing::Test { Perspective perspective) { net::QuicChromiumPacketWriter* writer = new net::QuicChromiumPacketWriter(socket.get()); - net::IPAddress ip; - EXPECT_TRUE(ip.AssignFromIPLiteral("0.0.0.0")); + net::IPAddress ip(0, 0, 0, 0); scoped_ptr<QuicConnection> quic_connection1(new QuicConnection( 0, net::IPEndPoint(ip, 0), &quic_helper_, writer, true /* owns_writer */, perspective, QuicSupportedVersions())); diff --git a/net/quic/quic_end_to_end_unittest.cc b/net/quic/quic_end_to_end_unittest.cc index b35021e..10cfc97 100644 --- a/net/quic/quic_end_to_end_unittest.cc +++ b/net/quic/quic_end_to_end_unittest.cc @@ -167,8 +167,7 @@ class QuicEndToEndTest : public ::testing::TestWithParam<TestParams> { // Starts the QUIC server listening on a random port. void StartServer() { - IPAddress ip; - CHECK(ip.AssignFromIPLiteral("127.0.0.1")); + IPAddress ip(127, 0, 0, 1); server_address_ = IPEndPoint(ip, 0); server_config_.SetInitialStreamFlowControlWindowToSend( kInitialStreamFlowControlWindowForTest); diff --git a/net/quic/quic_http_stream_test.cc b/net/quic/quic_http_stream_test.cc index 16cc99c..01796c4 100644 --- a/net/quic/quic_http_stream_test.cc +++ b/net/quic/quic_http_stream_test.cc @@ -143,8 +143,7 @@ class QuicHttpStreamTest : public ::testing::TestWithParam<QuicVersion> { stream_id_(kClientDataStreamId1), maker_(GetParam(), connection_id_, &clock_, kDefaultServerHostName), random_generator_(0) { - IPAddress ip; - CHECK(ip.AssignFromIPLiteral("192.0.2.33")); + IPAddress ip(192, 0, 2, 33); peer_addr_ = IPEndPoint(ip, 443); self_addr_ = IPEndPoint(ip, 8435); clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(20)); diff --git a/net/quic/test_tools/quic_test_utils.cc b/net/quic/test_tools/quic_test_utils.cc index eed392c..c94b092 100644 --- a/net/quic/test_tools/quic_test_utils.cc +++ b/net/quic/test_tools/quic_test_utils.cc @@ -449,9 +449,7 @@ QuicVersion QuicVersionMin() { } IPAddress Loopback4() { - IPAddress addr; - CHECK(addr.AssignFromIPLiteral("127.0.0.1")); - return addr; + return IPAddress(127, 0, 0, 1); } IPAddress Loopback6() { @@ -461,9 +459,7 @@ IPAddress Loopback6() { } IPAddress Any4() { - IPAddress any4; - CHECK(any4.AssignFromIPLiteral("0.0.0.0")); - return any4; + return IPAddress(0, 0, 0, 0); } void GenerateBody(string* body, int length) { diff --git a/net/tools/quic/end_to_end_test.cc b/net/tools/quic/end_to_end_test.cc index a2786aa..19ca2c0 100644 --- a/net/tools/quic/end_to_end_test.cc +++ b/net/tools/quic/end_to_end_test.cc @@ -1453,8 +1453,7 @@ TEST_P(EndToEndTest, StreamCancelErrorTest) { class WrongAddressWriter : public QuicPacketWriterWrapper { public: WrongAddressWriter() { - IPAddress ip; - CHECK(ip.AssignFromIPLiteral("127.0.0.2")); + IPAddress ip(127, 0, 0, 2); self_address_ = IPEndPoint(ip, 0); } @@ -1483,8 +1482,7 @@ TEST_P(EndToEndTest, ConnectionMigrationClientIPChanged) { IPAddress old_host = client_->client()->GetLatestClientAddress().address(); // Migrate socket to the new IP address. - IPAddress new_host; - CHECK(new_host.AssignFromIPLiteral("127.0.0.2")); + IPAddress new_host(127, 0, 0, 2); EXPECT_NE(old_host, new_host); ASSERT_TRUE(client_->client()->MigrateSocket(new_host)); diff --git a/net/tools/quic/quic_client.cc b/net/tools/quic/quic_client.cc index 14f412e..8c2c8e8 100644 --- a/net/tools/quic/quic_client.cc +++ b/net/tools/quic/quic_client.cc @@ -164,8 +164,7 @@ bool QuicClient::CreateUDPSocket() { if (bind_to_address_.size() != 0) { client_address = IPEndPoint(bind_to_address_, local_port_); } else if (address_family == AF_INET) { - IPAddress any4; - CHECK(any4.AssignFromIPLiteral("0.0.0.0")); + IPAddress any4(0, 0, 0, 0); client_address = IPEndPoint(any4, local_port_); } else { IPAddress any6; diff --git a/net/tools/quic/quic_simple_client.cc b/net/tools/quic/quic_simple_client.cc index 9378ae2..25bd93d 100644 --- a/net/tools/quic/quic_simple_client.cc +++ b/net/tools/quic/quic_simple_client.cc @@ -107,8 +107,7 @@ bool QuicSimpleClient::CreateUDPSocket() { if (bind_to_address_.size() != 0) { client_address_ = IPEndPoint(bind_to_address_, local_port_); } else if (address_family == AF_INET) { - IPAddress any4; - CHECK(any4.AssignFromIPLiteral("0.0.0.0")); + IPAddress any4(0, 0, 0, 0); client_address_ = IPEndPoint(any4, local_port_); } else { IPAddress any6; |