summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 15:01:16 +0000
committerthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 15:01:16 +0000
commit9f864b3e9d0650004a957035d08357c2bde81b99 (patch)
treec373f03088eae4d9688285165877660b814c5b87 /net
parent5f9a7f97780db19175a8549d39b97f62fa6c9afb (diff)
downloadchromium_src-9f864b3e9d0650004a957035d08357c2bde81b99.zip
chromium_src-9f864b3e9d0650004a957035d08357c2bde81b99.tar.gz
chromium_src-9f864b3e9d0650004a957035d08357c2bde81b99.tar.bz2
Turn GetPeerName into a pure virtual and provide local impls, this way any future bugs like the one referenced are compile time and not runtime so they won't wide waiting to be found.
BUG=32595 TEST=everything builds and tests pass Review URL: http://codereview.chromium.org/552048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36629 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/net.gyp1
-rw-r--r--net/socket/client_socket.cc20
-rw-r--r--net/socket/client_socket.h2
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc4
-rw-r--r--net/socket/socks_client_socket.cc2
-rw-r--r--net/socket/socks_client_socket.h3
-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_win.cc4
-rw-r--r--net/socket/ssl_client_socket_win.h1
-rw-r--r--net/socket/tcp_client_socket_pool_unittest.cc9
13 files changed, 26 insertions, 30 deletions
diff --git a/net/net.gyp b/net/net.gyp
index e13248a..8d47d08 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -416,7 +416,6 @@
'proxy/proxy_service.h',
'proxy/single_threaded_proxy_resolver.cc',
'proxy/single_threaded_proxy_resolver.h',
- 'socket/client_socket.cc',
'socket/client_socket.h',
'socket/client_socket_factory.cc',
'socket/client_socket_factory.h',
diff --git a/net/socket/client_socket.cc b/net/socket/client_socket.cc
deleted file mode 100644
index a3f204a..0000000
--- a/net/socket/client_socket.cc
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/socket/client_socket.h"
-
-#include "base/logging.h"
-#include "net/base/net_errors.h"
-
-namespace net {
-
-// Identical to BSD socket call getpeername().
-// Needed by ssl_client_socket_nss and ssl_client_socket_mac.
-int ClientSocket::GetPeerName(struct sockaddr* name, socklen_t* namelen) {
- // Default implementation just permits some unit tests to link.
- NOTREACHED();
- return ERR_UNEXPECTED;
-}
-
-} // namespace net
diff --git a/net/socket/client_socket.h b/net/socket/client_socket.h
index 0faab2c..e959d84 100644
--- a/net/socket/client_socket.h
+++ b/net/socket/client_socket.h
@@ -58,7 +58,7 @@ class ClientSocket : public Socket {
// Identical to BSD socket call getpeername().
// Needed by ssl_client_socket_nss and ssl_client_socket_mac.
- virtual int GetPeerName(struct sockaddr* name, socklen_t* namelen);
+ virtual int GetPeerName(struct sockaddr* name, socklen_t* namelen) = 0;
};
} // namespace net
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 6f3f5ef..7acebbd 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -57,12 +57,10 @@ class MockClientSocket : public ClientSocket {
virtual bool IsConnected() const { return connected_; }
virtual bool IsConnectedAndIdle() const { return connected_; }
-#if defined(OS_LINUX)
virtual int GetPeerName(struct sockaddr* /* name */,
socklen_t* /* namelen */) {
- return 0;
+ return ERR_UNEXPECTED;
}
-#endif
private:
bool connected_;
diff --git a/net/socket/socks_client_socket.cc b/net/socket/socks_client_socket.cc
index 4509bfa..5850da3 100644
--- a/net/socket/socks_client_socket.cc
+++ b/net/socket/socks_client_socket.cc
@@ -397,11 +397,9 @@ int SOCKSClientSocket::DoHandshakeReadComplete(int result) {
// Note: we ignore the last 6 bytes as specified by the SOCKS protocol
}
-#if defined(OS_LINUX)
int SOCKSClientSocket::GetPeerName(struct sockaddr* name,
socklen_t* namelen) {
return transport_->GetPeerName(name, namelen);
}
-#endif
} // namespace net
diff --git a/net/socket/socks_client_socket.h b/net/socket/socks_client_socket.h
index c099c4c..dc0b287 100644
--- a/net/socket/socks_client_socket.h
+++ b/net/socket/socks_client_socket.h
@@ -52,10 +52,7 @@ class SOCKSClientSocket : public ClientSocket {
virtual bool SetReceiveBufferSize(int32 size);
virtual bool SetSendBufferSize(int32 size);
-#if defined(OS_LINUX)
- // Needed by ssl_client_socket_nss.
virtual int GetPeerName(struct sockaddr* name, socklen_t* namelen);
-#endif
private:
FRIEND_TEST(SOCKSClientSocketTest, CompleteHandshake);
diff --git a/net/socket/ssl_client_socket_mac.cc b/net/socket/ssl_client_socket_mac.cc
index 37aec4d..2fb43d1 100644
--- a/net/socket/ssl_client_socket_mac.cc
+++ b/net/socket/ssl_client_socket_mac.cc
@@ -562,6 +562,10 @@ bool SSLClientSocketMac::IsConnectedAndIdle() const {
return completed_handshake_ && transport_->IsConnectedAndIdle();
}
+int SSLClientSocketMac::GetPeerName(struct sockaddr* name, socklen_t* namelen) {
+ return transport_->GetPeerName(name, namelen);
+}
+
int SSLClientSocketMac::Read(IOBuffer* buf, int buf_len,
CompletionCallback* callback) {
DCHECK(completed_handshake_);
diff --git a/net/socket/ssl_client_socket_mac.h b/net/socket/ssl_client_socket_mac.h
index fbfbdfd..3176116 100644
--- a/net/socket/ssl_client_socket_mac.h
+++ b/net/socket/ssl_client_socket_mac.h
@@ -43,6 +43,7 @@ class SSLClientSocketMac : public SSLClientSocket {
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
+ virtual int GetPeerName(struct sockaddr* name, socklen_t* namelen);
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc
index 05c61dd..350a4c9 100644
--- a/net/socket/ssl_client_socket_nss.cc
+++ b/net/socket/ssl_client_socket_nss.cc
@@ -447,6 +447,10 @@ bool SSLClientSocketNSS::IsConnectedAndIdle() const {
return ret;
}
+int SSLClientSocketNSS::GetPeerName(struct sockaddr* name, socklen_t* namelen) {
+ return transport_->GetPeerName(name, namelen);
+}
+
int SSLClientSocketNSS::Read(IOBuffer* buf, int buf_len,
CompletionCallback* callback) {
EnterFunction(buf_len);
diff --git a/net/socket/ssl_client_socket_nss.h b/net/socket/ssl_client_socket_nss.h
index 235f6ad..661fda8 100644
--- a/net/socket/ssl_client_socket_nss.h
+++ b/net/socket/ssl_client_socket_nss.h
@@ -48,6 +48,7 @@ class SSLClientSocketNSS : public SSLClientSocket {
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
+ virtual int GetPeerName(struct sockaddr* name, socklen_t* namelen);
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
diff --git a/net/socket/ssl_client_socket_win.cc b/net/socket/ssl_client_socket_win.cc
index 7c2e923..6e8d86d 100644
--- a/net/socket/ssl_client_socket_win.cc
+++ b/net/socket/ssl_client_socket_win.cc
@@ -566,6 +566,10 @@ bool SSLClientSocketWin::IsConnectedAndIdle() const {
return completed_handshake() && transport_->IsConnectedAndIdle();
}
+int SSLClientSocketWin::GetPeerName(struct sockaddr* name, socklen_t* namelen) {
+ return transport_->GetPeerName(name, namelen);
+}
+
int SSLClientSocketWin::Read(IOBuffer* buf, int buf_len,
CompletionCallback* callback) {
DCHECK(completed_handshake());
diff --git a/net/socket/ssl_client_socket_win.h b/net/socket/ssl_client_socket_win.h
index 5a83a24..c5d6cf7 100644
--- a/net/socket/ssl_client_socket_win.h
+++ b/net/socket/ssl_client_socket_win.h
@@ -46,6 +46,7 @@ class SSLClientSocketWin : public SSLClientSocket {
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
+ virtual int GetPeerName(struct sockaddr* name, socklen_t* namelen);
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/tcp_client_socket_pool_unittest.cc
index 8aa9ea0..500725a 100644
--- a/net/socket/tcp_client_socket_pool_unittest.cc
+++ b/net/socket/tcp_client_socket_pool_unittest.cc
@@ -42,6 +42,9 @@ class MockClientSocket : public ClientSocket {
virtual bool IsConnectedAndIdle() const {
return connected_;
}
+ virtual int GetPeerName(struct sockaddr* name, socklen_t* namelen) {
+ return ERR_UNEXPECTED;
+ }
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len,
@@ -76,6 +79,9 @@ class MockFailingClientSocket : public ClientSocket {
virtual bool IsConnectedAndIdle() const {
return false;
}
+ virtual int GetPeerName(struct sockaddr* name, socklen_t* namelen) {
+ return ERR_UNEXPECTED;
+ }
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len,
@@ -115,6 +121,9 @@ class MockPendingClientSocket : public ClientSocket {
virtual bool IsConnectedAndIdle() const {
return is_connected_;
}
+ virtual int GetPeerName(struct sockaddr* name, socklen_t* namelen) {
+ return ERR_UNEXPECTED;
+ }
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len,