summaryrefslogtreecommitdiffstats
path: root/net/spdy
diff options
context:
space:
mode:
authorszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-07 21:44:56 +0000
committerszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-07 21:44:56 +0000
commit7054e78fe6a2fcda72b06dc196b5f91cfdc75872 (patch)
tree2efdd9b07a784a17905d737df9b762d88a6cd1c4 /net/spdy
parentcd46545164adf645d744f3955b256cf89412cdc6 (diff)
downloadchromium_src-7054e78fe6a2fcda72b06dc196b5f91cfdc75872.zip
chromium_src-7054e78fe6a2fcda72b06dc196b5f91cfdc75872.tar.gz
chromium_src-7054e78fe6a2fcda72b06dc196b5f91cfdc75872.tar.bz2
Reimplements net::AddressList without struct addrinfo.
net::AddressList extends std::vector<std::IPEndPoint> by canonical name. (Canonical name is planned to be removed as well.) Removes dependency on sys_addrinfo.h throughout the codebase. Introduces net::SockaddrStorage for convenience. BUG=125696 TEST=green waterfall Review URL: http://codereview.chromium.org/10309002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135731 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy')
-rw-r--r--net/spdy/spdy_http_stream.cc3
-rw-r--r--net/spdy/spdy_session_pool.cc23
-rw-r--r--net/spdy/spdy_session_pool.h2
-rw-r--r--net/spdy/spdy_session_spdy2_unittest.cc3
-rw-r--r--net/spdy/spdy_session_spdy3_unittest.cc3
-rw-r--r--net/spdy/spdy_test_util_spdy2.h3
-rw-r--r--net/spdy/spdy_test_util_spdy3.h3
7 files changed, 15 insertions, 25 deletions
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc
index cdda4f2..9a498b9 100644
--- a/net/spdy/spdy_http_stream.cc
+++ b/net/spdy/spdy_http_stream.cc
@@ -254,7 +254,8 @@ int SpdyHttpStream::SendRequest(const HttpRequestHeaders& request_headers,
int result = stream_->GetPeerAddress(&address);
if (result != OK)
return result;
- response_info_->socket_address = HostPortPair::FromAddrInfo(address.head());
+ response_info_->socket_address =
+ HostPortPair::FromIPEndPoint(address.front());
bool has_upload_data = request_body_stream_.get() != NULL;
result = stream_->SendRequest(has_upload_data);
diff --git a/net/spdy/spdy_session_pool.cc b/net/spdy/spdy_session_pool.cc
index 430a233..7fc617e 100644
--- a/net/spdy/spdy_session_pool.cc
+++ b/net/spdy/spdy_session_pool.cc
@@ -8,7 +8,6 @@
#include "base/metrics/histogram.h"
#include "base/values.h"
#include "net/base/address_list.h"
-#include "net/base/sys_addrinfo.h"
#include "net/http/http_network_session.h"
#include "net/http/http_server_properties.h"
#include "net/spdy/spdy_session.h"
@@ -173,7 +172,7 @@ net::Error SpdySessionPool::GetSpdySessionFromSocket(
if (g_enable_ip_pooling && host_port_proxy_pair.second.is_direct()) {
AddressList addresses;
if (connection->socket()->GetPeerAddress(&addresses) == OK)
- AddAlias(addresses.head(), host_port_proxy_pair);
+ AddAlias(addresses.front(), host_port_proxy_pair);
}
// Now we can initialize the session with the SSL socket.
@@ -275,18 +274,15 @@ scoped_refptr<SpdySession> SpdySessionPool::GetFromAlias(
AddressList addresses;
if (!LookupAddresses(host_port_proxy_pair, net_log, &addresses))
return NULL;
- const addrinfo* address = addresses.head();
- while (address) {
- IPEndPoint endpoint;
- endpoint.FromSockAddr(address->ai_addr, address->ai_addrlen);
- address = address->ai_next;
-
- SpdyAliasMap::const_iterator it = aliases_.find(endpoint);
- if (it == aliases_.end())
+ for (AddressList::const_iterator iter = addresses.begin();
+ iter != addresses.end();
+ ++iter) {
+ SpdyAliasMap::const_iterator alias_iter = aliases_.find(*iter);
+ if (alias_iter == aliases_.end())
continue;
// We found an alias.
- const HostPortProxyPair& alias_pair = it->second;
+ const HostPortProxyPair& alias_pair = alias_iter->second;
// If the proxy settings match, we can reuse this session.
if (!(alias_pair.second == host_port_proxy_pair.second))
@@ -382,12 +378,9 @@ bool SpdySessionPool::LookupAddresses(const HostPortProxyPair& pair,
return rv == OK;
}
-void SpdySessionPool::AddAlias(const addrinfo* address,
+void SpdySessionPool::AddAlias(const IPEndPoint& endpoint,
const HostPortProxyPair& pair) {
DCHECK(g_enable_ip_pooling);
- DCHECK(address);
- IPEndPoint endpoint;
- endpoint.FromSockAddr(address->ai_addr, address->ai_addrlen);
aliases_[endpoint] = pair;
}
diff --git a/net/spdy/spdy_session_pool.h b/net/spdy/spdy_session_pool.h
index 567f2d8..2ab32f0 100644
--- a/net/spdy/spdy_session_pool.h
+++ b/net/spdy/spdy_session_pool.h
@@ -182,7 +182,7 @@ class NET_EXPORT SpdySessionPool
AddressList* addresses) const;
// Add |address| as an IP-equivalent address for |pair|.
- void AddAlias(const addrinfo* address, const HostPortProxyPair& pair);
+ void AddAlias(const IPEndPoint& address, const HostPortProxyPair& pair);
// Remove all aliases for |pair| from the aliases table.
void RemoveAliases(const HostPortProxyPair& pair);
diff --git a/net/spdy/spdy_session_spdy2_unittest.cc b/net/spdy/spdy_session_spdy2_unittest.cc
index a4afe3a..03bb6ae 100644
--- a/net/spdy/spdy_session_spdy2_unittest.cc
+++ b/net/spdy/spdy_session_spdy2_unittest.cc
@@ -810,9 +810,8 @@ void IPPoolingTest(bool clean_via_close_current_sessions) {
// TODO(rtenneti): MockClientSocket::GetPeerAddress return's 0 as the port
// number. Fix it to return port 80 and then use GetPeerAddress to AddAlias.
- const addrinfo* address = test_hosts[0].addresses.head();
SpdySessionPoolPeer pool_peer(spdy_session_pool);
- pool_peer.AddAlias(address, test_hosts[0].pair);
+ pool_peer.AddAlias(test_hosts[0].addresses.front(), test_hosts[0].pair);
// Flush the SpdySession::OnReadComplete() task.
MessageLoop::current()->RunAllPending();
diff --git a/net/spdy/spdy_session_spdy3_unittest.cc b/net/spdy/spdy_session_spdy3_unittest.cc
index 7ac41c3..82b2342 100644
--- a/net/spdy/spdy_session_spdy3_unittest.cc
+++ b/net/spdy/spdy_session_spdy3_unittest.cc
@@ -810,9 +810,8 @@ void IPPoolingTest(bool clean_via_close_current_sessions) {
// TODO(rtenneti): MockClientSocket::GetPeerAddress return's 0 as the port
// number. Fix it to return port 80 and then use GetPeerAddress to AddAlias.
- const addrinfo* address = test_hosts[0].addresses.head();
SpdySessionPoolPeer pool_peer(spdy_session_pool);
- pool_peer.AddAlias(address, test_hosts[0].pair);
+ pool_peer.AddAlias(test_hosts[0].addresses.front(), test_hosts[0].pair);
// Flush the SpdySession::OnReadComplete() task.
MessageLoop::current()->RunAllPending();
diff --git a/net/spdy/spdy_test_util_spdy2.h b/net/spdy/spdy_test_util_spdy2.h
index 2dcd999..f20e07e 100644
--- a/net/spdy/spdy_test_util_spdy2.h
+++ b/net/spdy/spdy_test_util_spdy2.h
@@ -12,7 +12,6 @@
#include "net/base/mock_host_resolver.h"
#include "net/base/request_priority.h"
#include "net/base/ssl_config_service_defaults.h"
-#include "net/base/sys_addrinfo.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_cache.h"
#include "net/http/http_network_session.h"
@@ -392,7 +391,7 @@ class SpdySessionPoolPeer {
explicit SpdySessionPoolPeer(SpdySessionPool* pool)
: pool_(pool) {}
- void AddAlias(const addrinfo* address, const HostPortProxyPair& pair) {
+ void AddAlias(const IPEndPoint& address, const HostPortProxyPair& pair) {
pool_->AddAlias(address, pair);
}
diff --git a/net/spdy/spdy_test_util_spdy3.h b/net/spdy/spdy_test_util_spdy3.h
index 11d2e62..2b11041 100644
--- a/net/spdy/spdy_test_util_spdy3.h
+++ b/net/spdy/spdy_test_util_spdy3.h
@@ -12,7 +12,6 @@
#include "net/base/mock_host_resolver.h"
#include "net/base/request_priority.h"
#include "net/base/ssl_config_service_defaults.h"
-#include "net/base/sys_addrinfo.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_cache.h"
#include "net/http/http_network_session.h"
@@ -393,7 +392,7 @@ class SpdySessionPoolPeer {
explicit SpdySessionPoolPeer(SpdySessionPool* pool)
: pool_(pool) {}
- void AddAlias(const addrinfo* address, const HostPortProxyPair& pair) {
+ void AddAlias(const IPEndPoint& address, const HostPortProxyPair& pair) {
pool_->AddAlias(address, pair);
}