summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/renderer_host/p2p/socket_host_tcp.cc19
-rw-r--r--jingle/glue/stream_socket_adapter.cc4
-rw-r--r--jingle/glue/stream_socket_adapter.h1
-rw-r--r--jingle/notifier/base/fake_ssl_client_socket.cc4
-rw-r--r--jingle/notifier/base/fake_ssl_client_socket.h1
-rw-r--r--jingle/notifier/base/fake_ssl_client_socket_unittest.cc1
-rw-r--r--jingle/notifier/base/proxy_resolving_client_socket.cc8
-rw-r--r--jingle/notifier/base/proxy_resolving_client_socket.h1
-rw-r--r--net/http/http_proxy_client_socket.cc4
-rw-r--r--net/http/http_proxy_client_socket.h1
-rw-r--r--net/socket/client_socket.h6
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc4
-rw-r--r--net/socket/socket_test_util.cc8
-rw-r--r--net/socket/socket_test_util.h1
-rw-r--r--net/socket/socks5_client_socket.cc4
-rw-r--r--net/socket/socks5_client_socket.h1
-rw-r--r--net/socket/socks_client_socket.cc4
-rw-r--r--net/socket/socks_client_socket.h1
-rw-r--r--net/socket/ssl_client_socket_mac.cc4
-rw-r--r--net/socket/ssl_client_socket_mac.h1
-rw-r--r--net/socket/ssl_client_socket_nss.cc4
-rw-r--r--net/socket/ssl_client_socket_nss.h1
-rw-r--r--net/socket/ssl_client_socket_openssl.cc4
-rw-r--r--net/socket/ssl_client_socket_openssl.h2
-rw-r--r--net/socket/ssl_client_socket_win.cc4
-rw-r--r--net/socket/ssl_client_socket_win.h1
-rw-r--r--net/socket/ssl_server_socket_unittest.cc7
-rw-r--r--net/socket/tcp_client_socket_libevent.cc18
-rw-r--r--net/socket/tcp_client_socket_libevent.h1
-rw-r--r--net/socket/tcp_client_socket_win.cc17
-rw-r--r--net/socket/tcp_client_socket_win.h1
-rw-r--r--net/socket/transport_client_socket_pool_unittest.cc9
-rw-r--r--net/spdy/spdy_proxy_client_socket.cc6
-rw-r--r--net/spdy/spdy_proxy_client_socket.h1
-rw-r--r--net/spdy/spdy_session.cc8
-rw-r--r--net/spdy/spdy_session.h5
-rw-r--r--net/spdy/spdy_stream.cc4
-rw-r--r--net/spdy/spdy_stream.h2
-rw-r--r--remoting/jingle_glue/ssl_socket_adapter.cc10
-rw-r--r--remoting/jingle_glue/ssl_socket_adapter.h1
40 files changed, 168 insertions, 16 deletions
diff --git a/content/browser/renderer_host/p2p/socket_host_tcp.cc b/content/browser/renderer_host/p2p/socket_host_tcp.cc
index 618043c..c5bfb65 100644
--- a/content/browser/renderer_host/p2p/socket_host_tcp.cc
+++ b/content/browser/renderer_host/p2p/socket_host_tcp.cc
@@ -86,22 +86,17 @@ void P2PSocketHostTcp::OnConnected(int result) {
}
net::IPEndPoint address;
- // TODO(sergeyu): Add GetLocalAddress() in TCPClientSocket.
- //
- // result = socket_->GetLocalAddress(&address);
- // if (result < 0) {
- // LOG(ERROR) << "P2PSocket::Init(): unable to get local address: "
- // << result;
- // OnError();
- // return false;
- // }
+ result = socket_->GetLocalAddress(&address);
+ if (result < 0) {
+ LOG(ERROR) << "P2PSocket::Init(): unable to get local address: "
+ << result;
+ OnError();
+ return;
+ }
VLOG(1) << "Local address: " << address.ToString();
-
state_ = STATE_OPEN;
-
message_sender_->Send(new P2PMsg_OnSocketCreated(routing_id_, id_, address));
-
DoRead();
}
diff --git a/jingle/glue/stream_socket_adapter.cc b/jingle/glue/stream_socket_adapter.cc
index ea38aef..315dc53 100644
--- a/jingle/glue/stream_socket_adapter.cc
+++ b/jingle/glue/stream_socket_adapter.cc
@@ -55,6 +55,10 @@ int StreamSocketAdapter::GetPeerAddress(net::AddressList* address) const {
return net::OK;
}
+int StreamSocketAdapter::GetLocalAddress(net::IPEndPoint* address) const {
+ return net::ERR_UNEXPECTED;
+}
+
const net::BoundNetLog& StreamSocketAdapter::NetLog() const {
DCHECK_EQ(MessageLoop::current(), message_loop_);
return net_log_;
diff --git a/jingle/glue/stream_socket_adapter.h b/jingle/glue/stream_socket_adapter.h
index 910aa57..14a6bfc 100644
--- a/jingle/glue/stream_socket_adapter.h
+++ b/jingle/glue/stream_socket_adapter.h
@@ -34,6 +34,7 @@ class StreamSocketAdapter : public net::ClientSocket,
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(net::AddressList* address) const;
+ virtual int GetLocalAddress(net::IPEndPoint* address) const;
virtual const net::BoundNetLog& NetLog() const;
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
diff --git a/jingle/notifier/base/fake_ssl_client_socket.cc b/jingle/notifier/base/fake_ssl_client_socket.cc
index 2cc643d..ebbad07 100644
--- a/jingle/notifier/base/fake_ssl_client_socket.cc
+++ b/jingle/notifier/base/fake_ssl_client_socket.cc
@@ -312,6 +312,10 @@ int FakeSSLClientSocket::GetPeerAddress(net::AddressList* address) const {
return transport_socket_->GetPeerAddress(address);
}
+int FakeSSLClientSocket::GetLocalAddress(net::IPEndPoint* address) const {
+ return transport_socket_->GetLocalAddress(address);
+}
+
const net::BoundNetLog& FakeSSLClientSocket::NetLog() const {
return transport_socket_->NetLog();
}
diff --git a/jingle/notifier/base/fake_ssl_client_socket.h b/jingle/notifier/base/fake_ssl_client_socket.h
index 3dc0406..14c539b 100644
--- a/jingle/notifier/base/fake_ssl_client_socket.h
+++ b/jingle/notifier/base/fake_ssl_client_socket.h
@@ -56,6 +56,7 @@ class FakeSSLClientSocket : public net::ClientSocket {
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(net::AddressList* address) const;
+ virtual int GetLocalAddress(net::IPEndPoint* address) const;
virtual const net::BoundNetLog& NetLog() const;
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
diff --git a/jingle/notifier/base/fake_ssl_client_socket_unittest.cc b/jingle/notifier/base/fake_ssl_client_socket_unittest.cc
index 6f9ac1d..7b0b58f 100644
--- a/jingle/notifier/base/fake_ssl_client_socket_unittest.cc
+++ b/jingle/notifier/base/fake_ssl_client_socket_unittest.cc
@@ -56,6 +56,7 @@ class MockClientSocket : public net::ClientSocket {
MOCK_CONST_METHOD0(IsConnected, bool());
MOCK_CONST_METHOD0(IsConnectedAndIdle, bool());
MOCK_CONST_METHOD1(GetPeerAddress, int(net::AddressList*));
+ MOCK_CONST_METHOD1(GetLocalAddress, int(net::IPEndPoint*));
MOCK_CONST_METHOD0(NetLog, const net::BoundNetLog&());
MOCK_METHOD0(SetSubresourceSpeculation, void());
MOCK_METHOD0(SetOmniboxSpeculation, void());
diff --git a/jingle/notifier/base/proxy_resolving_client_socket.cc b/jingle/notifier/base/proxy_resolving_client_socket.cc
index 82c300e..bdf3766 100644
--- a/jingle/notifier/base/proxy_resolving_client_socket.cc
+++ b/jingle/notifier/base/proxy_resolving_client_socket.cc
@@ -293,6 +293,14 @@ int ProxyResolvingClientSocket::GetPeerAddress(
return net::ERR_SOCKET_NOT_CONNECTED;
}
+int ProxyResolvingClientSocket::GetLocalAddress(
+ net::IPEndPoint* address) const {
+ if (transport_.get() && transport_->socket())
+ return transport_->socket()->GetLocalAddress(address);
+ NOTREACHED();
+ return net::ERR_SOCKET_NOT_CONNECTED;
+}
+
const net::BoundNetLog& ProxyResolvingClientSocket::NetLog() const {
if (transport_.get() && transport_->socket())
return transport_->socket()->NetLog();
diff --git a/jingle/notifier/base/proxy_resolving_client_socket.h b/jingle/notifier/base/proxy_resolving_client_socket.h
index 3622923..2b1b90e 100644
--- a/jingle/notifier/base/proxy_resolving_client_socket.h
+++ b/jingle/notifier/base/proxy_resolving_client_socket.h
@@ -51,6 +51,7 @@ class ProxyResolvingClientSocket : public net::ClientSocket {
virtual bool IsConnected() const OVERRIDE;
virtual bool IsConnectedAndIdle() const OVERRIDE;
virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE;
+ virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE;
virtual const net::BoundNetLog& NetLog() const OVERRIDE;
virtual void SetSubresourceSpeculation() OVERRIDE;
virtual void SetOmniboxSpeculation() OVERRIDE;
diff --git a/net/http/http_proxy_client_socket.cc b/net/http/http_proxy_client_socket.cc
index 23efcb9..0a41c1f 100644
--- a/net/http/http_proxy_client_socket.cc
+++ b/net/http/http_proxy_client_socket.cc
@@ -205,6 +205,10 @@ int HttpProxyClientSocket::GetPeerAddress(AddressList* address) const {
return transport_->socket()->GetPeerAddress(address);
}
+int HttpProxyClientSocket::GetLocalAddress(IPEndPoint* address) const {
+ return transport_->socket()->GetLocalAddress(address);
+}
+
int HttpProxyClientSocket::PrepareForAuthRestart() {
if (!response_.headers.get())
return ERR_CONNECTION_RESET;
diff --git a/net/http/http_proxy_client_socket.h b/net/http/http_proxy_client_socket.h
index f44a7eb..7410fac 100644
--- a/net/http/http_proxy_client_socket.h
+++ b/net/http/http_proxy_client_socket.h
@@ -85,6 +85,7 @@ class HttpProxyClientSocket : public ProxyClientSocket {
virtual bool SetReceiveBufferSize(int32 size);
virtual bool SetSendBufferSize(int32 size);
virtual int GetPeerAddress(AddressList* address) const;
+ virtual int GetLocalAddress(IPEndPoint* address) const;
private:
enum State {
diff --git a/net/socket/client_socket.h b/net/socket/client_socket.h
index 358716c..f57fe3f 100644
--- a/net/socket/client_socket.h
+++ b/net/socket/client_socket.h
@@ -12,6 +12,7 @@
namespace net {
class AddressList;
+class IPEndPoint;
class ClientSocket : public Socket {
public:
@@ -53,8 +54,13 @@ class ClientSocket : public Socket {
// Copies the peer address to |address| and returns a network error code.
// ERR_SOCKET_NOT_CONNECTED will be returned if the socket is not connected.
+ // TODO(sergeyu): Use IPEndPoint instead of AddressList.
virtual int GetPeerAddress(AddressList* address) const = 0;
+ // Copies the local address to |address| and returns a network error code.
+ // ERR_SOCKET_NOT_CONNECTED will be returned if the socket is not connected.
+ virtual int GetLocalAddress(IPEndPoint* address) const = 0;
+
// Gets the NetLog for this socket.
virtual const BoundNetLog& NetLog() const = 0;
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 8fc42c3..eb83289 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -76,6 +76,10 @@ class MockClientSocket : public ClientSocket {
return ERR_UNEXPECTED;
}
+ virtual int GetLocalAddress(IPEndPoint* /* address */) const {
+ return ERR_UNEXPECTED;
+ }
+
virtual const BoundNetLog& NetLog() const {
return net_log_;
}
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index 43cdf03..577c7d2 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -648,6 +648,14 @@ int MockClientSocket::GetPeerAddress(AddressList* address) const {
0, address, NULL);
}
+int MockClientSocket::GetLocalAddress(IPEndPoint* address) const {
+ IPAddressNumber ip;
+ if (!ParseIPLiteralToNumber("192.0.2.33", &ip))
+ return ERR_FAILED;
+ *address = IPEndPoint(ip, 123);
+ return OK;
+}
+
const BoundNetLog& MockClientSocket::NetLog() const {
return net_log_;
}
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index 21301f7..823c3b8 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -580,6 +580,7 @@ class MockClientSocket : public net::SSLClientSocket {
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(AddressList* address) const;
+ virtual int GetLocalAddress(IPEndPoint* address) const;
virtual const BoundNetLog& NetLog() const;
virtual void SetSubresourceSpeculation() {}
virtual void SetOmniboxSpeculation() {}
diff --git a/net/socket/socks5_client_socket.cc b/net/socket/socks5_client_socket.cc
index 42c8603..80b335e 100644
--- a/net/socket/socks5_client_socket.cc
+++ b/net/socket/socks5_client_socket.cc
@@ -483,4 +483,8 @@ int SOCKS5ClientSocket::GetPeerAddress(AddressList* address) const {
return transport_->socket()->GetPeerAddress(address);
}
+int SOCKS5ClientSocket::GetLocalAddress(IPEndPoint* address) const {
+ return transport_->socket()->GetLocalAddress(address);
+}
+
} // namespace net
diff --git a/net/socket/socks5_client_socket.h b/net/socket/socks5_client_socket.h
index 81804492..1981990 100644
--- a/net/socket/socks5_client_socket.h
+++ b/net/socket/socks5_client_socket.h
@@ -69,6 +69,7 @@ class SOCKS5ClientSocket : public ClientSocket {
virtual bool SetSendBufferSize(int32 size);
virtual int GetPeerAddress(AddressList* address) const;
+ virtual int GetLocalAddress(IPEndPoint* address) const;
private:
enum State {
diff --git a/net/socket/socks_client_socket.cc b/net/socket/socks_client_socket.cc
index a47861e..1afeaa6 100644
--- a/net/socket/socks_client_socket.cc
+++ b/net/socket/socks_client_socket.cc
@@ -414,4 +414,8 @@ int SOCKSClientSocket::GetPeerAddress(AddressList* address) const {
return transport_->socket()->GetPeerAddress(address);
}
+int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const {
+ return transport_->socket()->GetLocalAddress(address);
+}
+
} // namespace net
diff --git a/net/socket/socks_client_socket.h b/net/socket/socks_client_socket.h
index 9d4fba9..1d2cb8d 100644
--- a/net/socket/socks_client_socket.h
+++ b/net/socket/socks_client_socket.h
@@ -66,6 +66,7 @@ class SOCKSClientSocket : public ClientSocket {
virtual bool SetSendBufferSize(int32 size);
virtual int GetPeerAddress(AddressList* address) const;
+ virtual int GetLocalAddress(IPEndPoint* address) const;
private:
FRIEND_TEST_ALL_PREFIXES(SOCKSClientSocketTest, CompleteHandshake);
diff --git a/net/socket/ssl_client_socket_mac.cc b/net/socket/ssl_client_socket_mac.cc
index 09103ce..9a40e45 100644
--- a/net/socket/ssl_client_socket_mac.cc
+++ b/net/socket/ssl_client_socket_mac.cc
@@ -618,6 +618,10 @@ int SSLClientSocketMac::GetPeerAddress(AddressList* address) const {
return transport_->socket()->GetPeerAddress(address);
}
+int SSLClientSocketMac::GetLocalAddress(IPEndPoint* address) const {
+ return transport_->socket()->GetLocalAddress(address);
+}
+
const BoundNetLog& SSLClientSocketMac::NetLog() const {
return net_log_;
}
diff --git a/net/socket/ssl_client_socket_mac.h b/net/socket/ssl_client_socket_mac.h
index 058d1a3..d465cce 100644
--- a/net/socket/ssl_client_socket_mac.h
+++ b/net/socket/ssl_client_socket_mac.h
@@ -51,6 +51,7 @@ class SSLClientSocketMac : public SSLClientSocket {
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(AddressList* address) const;
+ virtual int GetLocalAddress(IPEndPoint* address) const;
virtual const BoundNetLog& NetLog() const;
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc
index a2396b1..4142acb 100644
--- a/net/socket/ssl_client_socket_nss.cc
+++ b/net/socket/ssl_client_socket_nss.cc
@@ -715,6 +715,10 @@ int SSLClientSocketNSS::GetPeerAddress(AddressList* address) const {
return transport_->socket()->GetPeerAddress(address);
}
+int SSLClientSocketNSS::GetLocalAddress(IPEndPoint* address) const {
+ return transport_->socket()->GetLocalAddress(address);
+}
+
const BoundNetLog& SSLClientSocketNSS::NetLog() const {
return net_log_;
}
diff --git a/net/socket/ssl_client_socket_nss.h b/net/socket/ssl_client_socket_nss.h
index 88f1f79..bbda8b9 100644
--- a/net/socket/ssl_client_socket_nss.h
+++ b/net/socket/ssl_client_socket_nss.h
@@ -70,6 +70,7 @@ class SSLClientSocketNSS : public SSLClientSocket {
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(AddressList* address) const;
+ virtual int GetLocalAddress(IPEndPoint* address) const;
virtual const BoundNetLog& NetLog() const;
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
diff --git a/net/socket/ssl_client_socket_openssl.cc b/net/socket/ssl_client_socket_openssl.cc
index 395c067..bea8efd 100644
--- a/net/socket/ssl_client_socket_openssl.cc
+++ b/net/socket/ssl_client_socket_openssl.cc
@@ -1058,6 +1058,10 @@ int SSLClientSocketOpenSSL::GetPeerAddress(AddressList* addressList) const {
return transport_->socket()->GetPeerAddress(addressList);
}
+int SSLClientSocketOpenSSL::GetLocalAddress(IPEndPoint* addressList) const {
+ return transport_->socket()->GetLocalAddress(addressList);
+}
+
const BoundNetLog& SSLClientSocketOpenSSL::NetLog() const {
return net_log_;
}
diff --git a/net/socket/ssl_client_socket_openssl.h b/net/socket/ssl_client_socket_openssl.h
index c4fb8dc..82d11fb 100644
--- a/net/socket/ssl_client_socket_openssl.h
+++ b/net/socket/ssl_client_socket_openssl.h
@@ -63,6 +63,7 @@ class SSLClientSocketOpenSSL : public SSLClientSocket {
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(AddressList* address) const;
+ virtual int GetLocalAddress(IPEndPoint* address) const;
virtual const BoundNetLog& NetLog() const;
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
@@ -163,4 +164,3 @@ class SSLClientSocketOpenSSL : public SSLClientSocket {
} // namespace net
#endif // NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_
-
diff --git a/net/socket/ssl_client_socket_win.cc b/net/socket/ssl_client_socket_win.cc
index 2ae8673..7dd5abf 100644
--- a/net/socket/ssl_client_socket_win.cc
+++ b/net/socket/ssl_client_socket_win.cc
@@ -695,6 +695,10 @@ int SSLClientSocketWin::GetPeerAddress(AddressList* address) const {
return transport_->socket()->GetPeerAddress(address);
}
+int SSLClientSocketWin::GetLocalAddress(IPEndPoint* address) const {
+ return transport_->socket()->GetLocalAddress(address);
+}
+
void SSLClientSocketWin::SetSubresourceSpeculation() {
if (transport_.get() && transport_->socket()) {
transport_->socket()->SetSubresourceSpeculation();
diff --git a/net/socket/ssl_client_socket_win.h b/net/socket/ssl_client_socket_win.h
index f9a6f94..30fab5f 100644
--- a/net/socket/ssl_client_socket_win.h
+++ b/net/socket/ssl_client_socket_win.h
@@ -56,6 +56,7 @@ class SSLClientSocketWin : public SSLClientSocket {
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(AddressList* address) const;
+ virtual int GetLocalAddress(IPEndPoint* address) const;
virtual const BoundNetLog& NetLog() const { return net_log_; }
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
diff --git a/net/socket/ssl_server_socket_unittest.cc b/net/socket/ssl_server_socket_unittest.cc
index 6269282..4ff7481 100644
--- a/net/socket/ssl_server_socket_unittest.cc
+++ b/net/socket/ssl_server_socket_unittest.cc
@@ -27,6 +27,7 @@
#include "net/base/cert_verifier.h"
#include "net/base/host_port_pair.h"
#include "net/base/io_buffer.h"
+#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
#include "net/base/ssl_config_service.h"
@@ -148,6 +149,12 @@ class FakeSocket : public ClientSocket {
return net::OK;
}
+ virtual int GetLocalAddress(IPEndPoint* address) const {
+ net::IPAddressNumber ip_address(4);
+ *address = net::IPEndPoint(ip_address, 0);
+ return net::OK;
+ }
+
virtual const BoundNetLog& NetLog() const {
return net_log_;
}
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc
index 1c7cdc0..d386bae 100644
--- a/net/socket/tcp_client_socket_libevent.cc
+++ b/net/socket/tcp_client_socket_libevent.cc
@@ -21,6 +21,7 @@
#include "net/base/address_list_net_log_param.h"
#include "net/base/connection_type_histograms.h"
#include "net/base/io_buffer.h"
+#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
#include "net/base/net_util.h"
@@ -618,6 +619,23 @@ int TCPClientSocketLibevent::GetPeerAddress(AddressList* address) const {
return OK;
}
+int TCPClientSocketLibevent::GetLocalAddress(IPEndPoint* address) const {
+ DCHECK(CalledOnValidThread());
+ DCHECK(address);
+ if (!IsConnected())
+ return ERR_SOCKET_NOT_CONNECTED;
+
+ struct sockaddr_storage addr_storage;
+ socklen_t addr_len = sizeof(addr_storage);
+ struct sockaddr* addr = reinterpret_cast<struct sockaddr*>(&addr_storage);
+ if (getsockname(socket_, addr, &addr_len))
+ return MapSystemError(errno);
+ if (!address->FromSockAddr(addr, addr_len))
+ return ERR_FAILED;
+
+ return OK;
+}
+
const BoundNetLog& TCPClientSocketLibevent::NetLog() const {
return net_log_;
}
diff --git a/net/socket/tcp_client_socket_libevent.h b/net/socket/tcp_client_socket_libevent.h
index 796a4a8..89ffac1 100644
--- a/net/socket/tcp_client_socket_libevent.h
+++ b/net/socket/tcp_client_socket_libevent.h
@@ -46,6 +46,7 @@ class TCPClientSocketLibevent : public ClientSocket, base::NonThreadSafe {
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(AddressList* address) const;
+ virtual int GetLocalAddress(IPEndPoint* address) const;
virtual const BoundNetLog& NetLog() const;
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc
index eec7dbb..de5ff61 100644
--- a/net/socket/tcp_client_socket_win.cc
+++ b/net/socket/tcp_client_socket_win.cc
@@ -16,6 +16,7 @@
#include "net/base/address_list_net_log_param.h"
#include "net/base/connection_type_histograms.h"
#include "net/base/io_buffer.h"
+#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
#include "net/base/net_util.h"
@@ -471,6 +472,22 @@ int TCPClientSocketWin::GetPeerAddress(AddressList* address) const {
return OK;
}
+int TCPClientSocketWin::GetLocalAddress(IPEndPoint* address) const {
+ DCHECK(CalledOnValidThread());
+ DCHECK(address);
+ if (!IsConnected())
+ return ERR_SOCKET_NOT_CONNECTED;
+
+ struct sockaddr_storage addr_storage;
+ socklen_t addr_len = sizeof(addr_storage);
+ struct sockaddr* addr = reinterpret_cast<struct sockaddr*>(&addr_storage);
+ if (getsockname(socket_, addr, &addr_len))
+ return MapSystemError(WSAGetLastError());
+ if (!address->FromSockAddr(addr, addr_len))
+ return ERR_FAILED;
+ return OK;
+}
+
void TCPClientSocketWin::SetSubresourceSpeculation() {
use_history_.set_subresource_speculation();
}
diff --git a/net/socket/tcp_client_socket_win.h b/net/socket/tcp_client_socket_win.h
index bca0d30..8beb983 100644
--- a/net/socket/tcp_client_socket_win.h
+++ b/net/socket/tcp_client_socket_win.h
@@ -42,6 +42,7 @@ class TCPClientSocketWin : public ClientSocket, base::NonThreadSafe {
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(AddressList* address) const;
+ virtual int GetLocalAddress(IPEndPoint* address) const;
virtual const BoundNetLog& NetLog() const { return net_log_; }
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
diff --git a/net/socket/transport_client_socket_pool_unittest.cc b/net/socket/transport_client_socket_pool_unittest.cc
index 889cc5b..ae937e9 100644
--- a/net/socket/transport_client_socket_pool_unittest.cc
+++ b/net/socket/transport_client_socket_pool_unittest.cc
@@ -50,6 +50,9 @@ class MockClientSocket : public ClientSocket {
virtual int GetPeerAddress(AddressList* address) const {
return ERR_UNEXPECTED;
}
+ virtual int GetLocalAddress(IPEndPoint* address) const {
+ return ERR_UNEXPECTED;
+ }
virtual const BoundNetLog& NetLog() const {
return net_log_;
}
@@ -96,6 +99,9 @@ class MockFailingClientSocket : public ClientSocket {
virtual int GetPeerAddress(AddressList* address) const {
return ERR_UNEXPECTED;
}
+ virtual int GetLocalAddress(IPEndPoint* address) const {
+ return ERR_UNEXPECTED;
+ }
virtual const BoundNetLog& NetLog() const {
return net_log_;
}
@@ -155,6 +161,9 @@ class MockPendingClientSocket : public ClientSocket {
virtual int GetPeerAddress(AddressList* address) const {
return ERR_UNEXPECTED;
}
+ virtual int GetLocalAddress(IPEndPoint* address) const {
+ return ERR_UNEXPECTED;
+ }
virtual const BoundNetLog& NetLog() const {
return net_log_;
}
diff --git a/net/spdy/spdy_proxy_client_socket.cc b/net/spdy/spdy_proxy_client_socket.cc
index f451868..d34743e 100644
--- a/net/spdy/spdy_proxy_client_socket.cc
+++ b/net/spdy/spdy_proxy_client_socket.cc
@@ -245,6 +245,12 @@ int SpdyProxyClientSocket::GetPeerAddress(AddressList* address) const {
return spdy_stream_->GetPeerAddress(address);
}
+int SpdyProxyClientSocket::GetLocalAddress(IPEndPoint* address) const {
+ if (!IsConnected())
+ return ERR_SOCKET_NOT_CONNECTED;
+ return spdy_stream_->GetLocalAddress(address);
+}
+
void SpdyProxyClientSocket::OnIOComplete(int result) {
DCHECK_NE(STATE_DISCONNECTED, next_state_);
int rv = DoLoop(result);
diff --git a/net/spdy/spdy_proxy_client_socket.h b/net/spdy/spdy_proxy_client_socket.h
index d57b10f..6f506d7 100644
--- a/net/spdy/spdy_proxy_client_socket.h
+++ b/net/spdy/spdy_proxy_client_socket.h
@@ -84,6 +84,7 @@ class SpdyProxyClientSocket : public ProxyClientSocket,
virtual bool SetReceiveBufferSize(int32 size);
virtual bool SetSendBufferSize(int32 size);
virtual int GetPeerAddress(AddressList* address) const;
+ virtual int GetLocalAddress(IPEndPoint* address) const;
// SpdyStream::Delegate methods:
virtual bool OnSendHeadersComplete(int status);
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 305ee35..d4629a0 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -899,6 +899,14 @@ Value* SpdySession::GetInfoAsValue() const {
return dict;
}
+int SpdySession::GetPeerAddress(AddressList* address) const {
+ return connection_->socket()->GetPeerAddress(address);
+}
+
+int SpdySession::GetLocalAddress(IPEndPoint* address) const {
+ return connection_->socket()->GetLocalAddress(address);
+}
+
void SpdySession::ActivateStream(SpdyStream* stream) {
const spdy::SpdyStreamId id = stream->stream_id();
DCHECK(!IsStreamActive(id));
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h
index a4e1edc..46d1903 100644
--- a/net/spdy/spdy_session.h
+++ b/net/spdy/spdy_session.h
@@ -198,9 +198,8 @@ class SpdySession : public base::RefCounted<SpdySession>,
const BoundNetLog& net_log() const { return net_log_; }
- int GetPeerAddress(AddressList* address) const {
- return connection_->socket()->GetPeerAddress(address);
- }
+ int GetPeerAddress(AddressList* address) const;
+ int GetLocalAddress(IPEndPoint* address) const;
private:
friend class base::RefCounted<SpdySession>;
diff --git a/net/spdy/spdy_stream.cc b/net/spdy/spdy_stream.cc
index e948b33..5808907 100644
--- a/net/spdy/spdy_stream.cc
+++ b/net/spdy/spdy_stream.cc
@@ -218,6 +218,10 @@ int SpdyStream::GetPeerAddress(AddressList* address) const {
return session_->GetPeerAddress(address);
}
+int SpdyStream::GetLocalAddress(IPEndPoint* address) const {
+ return session_->GetLocalAddress(address);
+}
+
bool SpdyStream::WasEverUsed() const {
return session_->WasEverUsed();
}
diff --git a/net/spdy/spdy_stream.h b/net/spdy/spdy_stream.h
index 186d0ec..a2fefd9 100644
--- a/net/spdy/spdy_stream.h
+++ b/net/spdy/spdy_stream.h
@@ -24,6 +24,7 @@
namespace net {
class AddressList;
+class IPEndPoint;
class SpdySession;
class SSLCertRequestInfo;
class SSLInfo;
@@ -143,6 +144,7 @@ class SpdyStream
void DecreaseSendWindowSize(int delta_window_size);
int GetPeerAddress(AddressList* address) const;
+ int GetLocalAddress(IPEndPoint* address) const;
// Returns true if the underlying transport socket ever had any reads or
// writes.
diff --git a/remoting/jingle_glue/ssl_socket_adapter.cc b/remoting/jingle_glue/ssl_socket_adapter.cc
index 251f771..51273f5 100644
--- a/remoting/jingle_glue/ssl_socket_adapter.cc
+++ b/remoting/jingle_glue/ssl_socket_adapter.cc
@@ -7,6 +7,7 @@
#include "base/base64.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
+#include "jingle/glue/utils.h"
#include "net/base/address_list.h"
#include "net/base/cert_verifier.h"
#include "net/base/host_port_pair.h"
@@ -276,6 +277,15 @@ int TransportSocket::GetPeerAddress(net::AddressList* address) const {
return net::OK;
}
+int TransportSocket::GetLocalAddress(net::IPEndPoint* address) const {
+ talk_base::SocketAddress socket_address = socket_->GetLocalAddress();
+ if (jingle_glue::SocketAddressToIPEndPoint(socket_address, address)) {
+ return net::OK;
+ } else {
+ return net::ERR_FAILED;
+ }
+}
+
const net::BoundNetLog& TransportSocket::NetLog() const {
return net_log_;
}
diff --git a/remoting/jingle_glue/ssl_socket_adapter.h b/remoting/jingle_glue/ssl_socket_adapter.h
index 1c778a8..c4111c8 100644
--- a/remoting/jingle_glue/ssl_socket_adapter.h
+++ b/remoting/jingle_glue/ssl_socket_adapter.h
@@ -46,6 +46,7 @@ class TransportSocket : public net::ClientSocket, public sigslot::has_slots<> {
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(net::AddressList* address) const;
+ virtual int GetLocalAddress(net::IPEndPoint* address) const;
virtual const net::BoundNetLog& NetLog() const;
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();