summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-25 17:08:07 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-25 17:08:07 +0000
commit0a0b768baf188195cea0e58bf61313cb948f1ddd (patch)
tree96188cae26746d1673e11c29dc493c1538332210 /net
parent18c0b57df5cf6a7cf06edc35261af82b9f6c6e8e (diff)
downloadchromium_src-0a0b768baf188195cea0e58bf61313cb948f1ddd.zip
chromium_src-0a0b768baf188195cea0e58bf61313cb948f1ddd.tar.gz
chromium_src-0a0b768baf188195cea0e58bf61313cb948f1ddd.tar.bz2
In about:net-internals, each SOCKET created by a CONNECT_JOB holds a reference to the CONNECT_JOB that spawned it.
BUG=47082 TEST=manual Review URL: http://codereview.chromium.org/3164005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57339 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/ftp/ftp_network_transaction.cc4
-rw-r--r--net/socket/client_socket_factory.cc6
-rw-r--r--net/socket/client_socket_factory.h9
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc9
-rw-r--r--net/socket/socket_test_util.cc10
-rw-r--r--net/socket/socket_test_util.h9
-rw-r--r--net/socket/ssl_client_socket_unittest.cc27
-rw-r--r--net/socket/tcp_client_socket_libevent.cc11
-rw-r--r--net/socket/tcp_client_socket_libevent.h5
-rw-r--r--net/socket/tcp_client_socket_pool.cc2
-rw-r--r--net/socket/tcp_client_socket_pool_unittest.cc6
-rw-r--r--net/socket/tcp_client_socket_unittest.cc2
-rw-r--r--net/socket/tcp_client_socket_win.cc9
-rw-r--r--net/socket/tcp_client_socket_win.h4
-rw-r--r--net/socket/tcp_pinger.h2
-rw-r--r--net/socket_stream/socket_stream.cc3
16 files changed, 80 insertions, 38 deletions
diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc
index f4de8ab..f66ab0d 100644
--- a/net/ftp/ftp_network_transaction.cc
+++ b/net/ftp/ftp_network_transaction.cc
@@ -631,7 +631,7 @@ int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) {
int FtpNetworkTransaction::DoCtrlConnect() {
next_state_ = STATE_CTRL_CONNECT_COMPLETE;
ctrl_socket_.reset(socket_factory_->CreateTCPClientSocket(
- addresses_, net_log_.net_log()));
+ addresses_, net_log_.net_log(), net_log_.source()));
return ctrl_socket_->Connect(&io_callback_);
}
@@ -1183,7 +1183,7 @@ int FtpNetworkTransaction::DoDataConnect() {
return Stop(rv);
data_address.SetPort(data_connection_port_);
data_socket_.reset(socket_factory_->CreateTCPClientSocket(
- data_address, net_log_.net_log()));
+ data_address, net_log_.net_log(), net_log_.source()));
return data_socket_->Connect(&io_callback_);
}
diff --git a/net/socket/client_socket_factory.cc b/net/socket/client_socket_factory.cc
index 5fb9970..5fd06bf 100644
--- a/net/socket/client_socket_factory.cc
+++ b/net/socket/client_socket_factory.cc
@@ -48,8 +48,10 @@ SSLClientSocketFactory g_ssl_factory = DefaultSSLClientSocketFactory;
class DefaultClientSocketFactory : public ClientSocketFactory {
public:
virtual ClientSocket* CreateTCPClientSocket(
- const AddressList& addresses, NetLog* net_log) {
- return new TCPClientSocket(addresses, net_log);
+ const AddressList& addresses,
+ NetLog* net_log,
+ const NetLog::Source& source) {
+ return new TCPClientSocket(addresses, net_log, source);
}
virtual SSLClientSocket* CreateSSLClientSocket(
diff --git a/net/socket/client_socket_factory.h b/net/socket/client_socket_factory.h
index d0f1581..97fb361 100644
--- a/net/socket/client_socket_factory.h
+++ b/net/socket/client_socket_factory.h
@@ -8,12 +8,13 @@
#include <string>
+#include "net/base/net_log.h"
+
namespace net {
class AddressList;
class ClientSocket;
class ClientSocketHandle;
-class NetLog;
class SSLClientSocket;
struct SSLConfig;
@@ -29,8 +30,12 @@ class ClientSocketFactory {
public:
virtual ~ClientSocketFactory() {}
+ // |source| is the NetLog::Source for the entity trying to create the socket,
+ // if it has one.
virtual ClientSocket* CreateTCPClientSocket(
- const AddressList& addresses, NetLog* net_log) = 0;
+ const AddressList& addresses,
+ NetLog* net_log,
+ const NetLog::Source& source) = 0;
virtual SSLClientSocket* CreateSSLClientSocket(
ClientSocketHandle* transport_socket,
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index e9a675c..d8ea1d9 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -89,8 +89,10 @@ class MockClientSocketFactory : public ClientSocketFactory {
public:
MockClientSocketFactory() : allocation_count_(0) {}
- virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses,
- NetLog* /* net_log */) {
+ virtual ClientSocket* CreateTCPClientSocket(
+ const AddressList& addresses,
+ NetLog* /* net_log */,
+ const NetLog::Source& /*source*/) {
allocation_count_++;
return NULL;
}
@@ -168,7 +170,8 @@ class TestConnectJob : public ConnectJob {
virtual int ConnectInternal() {
AddressList ignored;
- client_socket_factory_->CreateTCPClientSocket(ignored, NULL);
+ client_socket_factory_->CreateTCPClientSocket(
+ ignored, NULL, net::NetLog::Source());
set_socket(new MockClientSocket());
switch (job_type_) {
case kMockJob:
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index 5ffd1d4..74f5f4f 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -903,7 +903,9 @@ MockSSLClientSocket* MockClientSocketFactory::GetMockSSLClientSocket(
}
ClientSocket* MockClientSocketFactory::CreateTCPClientSocket(
- const AddressList& addresses, net::NetLog* net_log) {
+ const AddressList& addresses,
+ net::NetLog* net_log,
+ const NetLog::Source& source) {
SocketDataProvider* data_provider = mock_data_.GetNext();
MockTCPClientSocket* socket =
new MockTCPClientSocket(addresses, net_log, data_provider);
@@ -945,7 +947,9 @@ MockSSLClientSocket* DeterministicMockClientSocketFactory::
}
ClientSocket* DeterministicMockClientSocketFactory::CreateTCPClientSocket(
- const AddressList& addresses, net::NetLog* net_log) {
+ const AddressList& addresses,
+ net::NetLog* net_log,
+ const net::NetLog::Source& source) {
DeterministicSocketData* data_provider = mock_data().GetNext();
DeterministicMockTCPClientSocket* socket =
new DeterministicMockTCPClientSocket(net_log, data_provider);
@@ -1100,7 +1104,7 @@ int MockTCPClientSocketPool::RequestSocket(const std::string& group_name,
CompletionCallback* callback,
const BoundNetLog& net_log) {
ClientSocket* socket = client_socket_factory_->CreateTCPClientSocket(
- AddressList(), net_log.net_log());
+ AddressList(), net_log.net_log(), net::NetLog::Source());
MockConnectJob* job = new MockConnectJob(socket, handle, callback);
job_list_.push_back(job);
handle->set_pool_id(1);
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index 533a18d..d2557b8 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -481,8 +481,10 @@ class MockClientSocketFactory : public ClientSocketFactory {
MockSSLClientSocket* GetMockSSLClientSocket(size_t index) const;
// ClientSocketFactory
- virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses,
- NetLog* net_log);
+ virtual ClientSocket* CreateTCPClientSocket(
+ const AddressList& addresses,
+ NetLog* net_log,
+ const NetLog::Source& source);
virtual SSLClientSocket* CreateSSLClientSocket(
ClientSocketHandle* transport_socket,
const std::string& hostname,
@@ -802,7 +804,8 @@ class DeterministicMockClientSocketFactory : public ClientSocketFactory {
// ClientSocketFactory
virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses,
- NetLog* net_log);
+ NetLog* net_log,
+ const NetLog::Source& source);
virtual SSLClientSocket* CreateSSLClientSocket(
ClientSocketHandle* transport_socket,
const std::string& hostname,
diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc
index 33cf0c0..45bfd23 100644
--- a/net/socket/ssl_client_socket_unittest.cc
+++ b/net/socket/ssl_client_socket_unittest.cc
@@ -48,7 +48,8 @@ TEST_F(SSLClientSocketTest, Connect) {
TestCompletionCallback callback;
net::CapturingNetLog log(net::CapturingNetLog::kUnbounded);
- net::ClientSocket* transport = new net::TCPClientSocket(addr, &log);
+ net::ClientSocket* transport = new net::TCPClientSocket(
+ addr, &log, net::NetLog::Source());
int rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
@@ -91,7 +92,8 @@ TEST_F(SSLClientSocketTest, ConnectExpired) {
TestCompletionCallback callback;
net::CapturingNetLog log(net::CapturingNetLog::kUnbounded);
- net::ClientSocket* transport = new net::TCPClientSocket(addr, &log);
+ net::ClientSocket* transport = new net::TCPClientSocket(
+ addr, &log, net::NetLog::Source());
int rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
@@ -134,7 +136,8 @@ TEST_F(SSLClientSocketTest, ConnectMismatched) {
TestCompletionCallback callback;
net::CapturingNetLog log(net::CapturingNetLog::kUnbounded);
- net::ClientSocket* transport = new net::TCPClientSocket(addr, &log);
+ net::ClientSocket* transport = new net::TCPClientSocket(
+ addr, &log, net::NetLog::Source());
int rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
@@ -180,7 +183,8 @@ TEST_F(SSLClientSocketTest, ConnectClientAuthCertRequested) {
TestCompletionCallback callback;
net::CapturingNetLog log(net::CapturingNetLog::kUnbounded);
- net::ClientSocket* transport = new net::TCPClientSocket(addr, &log);
+ net::ClientSocket* transport = new net::TCPClientSocket(
+ addr, &log, net::NetLog::Source());
int rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
@@ -227,7 +231,8 @@ TEST_F(SSLClientSocketTest, ConnectClientAuthSendNullCert) {
TestCompletionCallback callback;
net::CapturingNetLog log(net::CapturingNetLog::kUnbounded);
- net::ClientSocket* transport = new net::TCPClientSocket(addr, &log);
+ net::ClientSocket* transport = new net::TCPClientSocket(
+ addr, &log, net::NetLog::Source());
int rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
@@ -279,7 +284,8 @@ TEST_F(SSLClientSocketTest, Read) {
ASSERT_TRUE(test_server.GetAddressList(&addr));
TestCompletionCallback callback;
- net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL);
+ net::ClientSocket* transport = new net::TCPClientSocket(
+ addr, NULL, net::NetLog::Source());
int rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
@@ -337,7 +343,8 @@ TEST_F(SSLClientSocketTest, Read_FullDuplex) {
TestCompletionCallback callback; // Used for everything except Write.
TestCompletionCallback callback2; // Used for Write only.
- net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL);
+ net::ClientSocket* transport = new net::TCPClientSocket(
+ addr, NULL, net::NetLog::Source());
int rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
@@ -394,7 +401,8 @@ TEST_F(SSLClientSocketTest, Read_SmallChunks) {
ASSERT_TRUE(test_server.GetAddressList(&addr));
TestCompletionCallback callback;
- net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL);
+ net::ClientSocket* transport = new net::TCPClientSocket(
+ addr, NULL, net::NetLog::Source());
int rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
@@ -446,7 +454,8 @@ TEST_F(SSLClientSocketTest, Read_Interrupted) {
ASSERT_TRUE(test_server.GetAddressList(&addr));
TestCompletionCallback callback;
- net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL);
+ net::ClientSocket* transport = new net::TCPClientSocket(
+ addr, NULL, net::NetLog::Source());
int rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc
index 93593d9..55c4190 100644
--- a/net/socket/tcp_client_socket_libevent.cc
+++ b/net/socket/tcp_client_socket_libevent.cc
@@ -99,8 +99,10 @@ int MapConnectError(int os_error) {
//-----------------------------------------------------------------------------
-TCPClientSocketLibevent::TCPClientSocketLibevent(const AddressList& addresses,
- net::NetLog* net_log)
+TCPClientSocketLibevent::TCPClientSocketLibevent(
+ const AddressList& addresses,
+ net::NetLog* net_log,
+ const net::NetLog::Source& source)
: socket_(kInvalidSocket),
addresses_(addresses),
current_ai_(NULL),
@@ -111,7 +113,10 @@ TCPClientSocketLibevent::TCPClientSocketLibevent(const AddressList& addresses,
next_connect_state_(CONNECT_STATE_NONE),
connect_os_error_(0),
net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) {
- net_log_.BeginEvent(NetLog::TYPE_SOCKET_ALIVE, NULL);
+ scoped_refptr<NetLog::EventParameters> params;
+ if (source.is_valid())
+ params = new NetLogSourceParameter("source_dependency", source);
+ net_log_.BeginEvent(NetLog::TYPE_SOCKET_ALIVE, params);
}
TCPClientSocketLibevent::~TCPClientSocketLibevent() {
diff --git a/net/socket/tcp_client_socket_libevent.h b/net/socket/tcp_client_socket_libevent.h
index b72e632..ec4b5aa 100644
--- a/net/socket/tcp_client_socket_libevent.h
+++ b/net/socket/tcp_client_socket_libevent.h
@@ -27,8 +27,9 @@ class TCPClientSocketLibevent : public ClientSocket, NonThreadSafe {
// The IP address(es) and port number to connect to. The TCP socket will try
// each IP address in the list until it succeeds in establishing a
// connection.
- explicit TCPClientSocketLibevent(const AddressList& addresses,
- net::NetLog* net_log);
+ TCPClientSocketLibevent(const AddressList& addresses,
+ net::NetLog* net_log,
+ const net::NetLog::Source& source);
virtual ~TCPClientSocketLibevent();
diff --git a/net/socket/tcp_client_socket_pool.cc b/net/socket/tcp_client_socket_pool.cc
index f51196f..dce14dc 100644
--- a/net/socket/tcp_client_socket_pool.cc
+++ b/net/socket/tcp_client_socket_pool.cc
@@ -143,7 +143,7 @@ int TCPConnectJob::DoResolveHostComplete(int result) {
int TCPConnectJob::DoTCPConnect() {
next_state_ = kStateTCPConnectComplete;
set_socket(client_socket_factory_->CreateTCPClientSocket(
- addresses_, net_log().net_log()));
+ addresses_, net_log().net_log(), net_log().source()));
connect_start_time_ = base::TimeTicks::Now();
return socket()->Connect(&callback_);
}
diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/tcp_client_socket_pool_unittest.cc
index 9516f9f..7c2df9a 100644
--- a/net/socket/tcp_client_socket_pool_unittest.cc
+++ b/net/socket/tcp_client_socket_pool_unittest.cc
@@ -198,8 +198,10 @@ class MockClientSocketFactory : public ClientSocketFactory {
client_socket_types_(NULL), client_socket_index_(0),
client_socket_index_max_(0) {}
- virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses,
- NetLog* /* net_log */) {
+ virtual ClientSocket* CreateTCPClientSocket(
+ const AddressList& addresses,
+ NetLog* /* net_log */,
+ const NetLog::Source& /* source */) {
allocation_count_++;
ClientSocketType type = client_socket_type_;
diff --git a/net/socket/tcp_client_socket_unittest.cc b/net/socket/tcp_client_socket_unittest.cc
index 6117fae..9d50d83 100644
--- a/net/socket/tcp_client_socket_unittest.cc
+++ b/net/socket/tcp_client_socket_unittest.cc
@@ -97,7 +97,7 @@ void TCPClientSocketTest::SetUp() {
HostResolver::RequestInfo info("localhost", listen_port_);
int rv = resolver->Resolve(info, &addr, NULL, NULL, BoundNetLog());
CHECK_EQ(rv, OK);
- sock_.reset(new TCPClientSocket(addr, &net_log_));
+ sock_.reset(new TCPClientSocket(addr, &net_log_, NetLog::Source()));
}
TEST_F(TCPClientSocketTest, Connect) {
diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc
index 3da856b..d2f7e04 100644
--- a/net/socket/tcp_client_socket_win.cc
+++ b/net/socket/tcp_client_socket_win.cc
@@ -271,7 +271,8 @@ void TCPClientSocketWin::Core::WriteDelegate::OnObjectSignaled(
//-----------------------------------------------------------------------------
TCPClientSocketWin::TCPClientSocketWin(const AddressList& addresses,
- net::NetLog* net_log)
+ net::NetLog* net_log,
+ const net::NetLog::Source& source)
: socket_(INVALID_SOCKET),
addresses_(addresses),
current_ai_(NULL),
@@ -282,7 +283,11 @@ TCPClientSocketWin::TCPClientSocketWin(const AddressList& addresses,
next_connect_state_(CONNECT_STATE_NONE),
connect_os_error_(0),
net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) {
- net_log_.BeginEvent(NetLog::TYPE_SOCKET_ALIVE, NULL);
+
+ scoped_refptr<NetLog::EventParameters> params;
+ if (source.is_valid())
+ params = new NetLogSourceParameter("source_dependency", source);
+ net_log_.BeginEvent(NetLog::TYPE_SOCKET_ALIVE, params);
EnsureWinsockInit();
}
diff --git a/net/socket/tcp_client_socket_win.h b/net/socket/tcp_client_socket_win.h
index c46a14e..8940978 100644
--- a/net/socket/tcp_client_socket_win.h
+++ b/net/socket/tcp_client_socket_win.h
@@ -24,7 +24,9 @@ class TCPClientSocketWin : public ClientSocket, NonThreadSafe {
// The IP address(es) and port number to connect to. The TCP socket will try
// each IP address in the list until it succeeds in establishing a
// connection.
- TCPClientSocketWin(const AddressList& addresses, net::NetLog* net_log);
+ TCPClientSocketWin(const AddressList& addresses,
+ net::NetLog* net_log,
+ const net::NetLog::Source& source);
~TCPClientSocketWin();
diff --git a/net/socket/tcp_pinger.h b/net/socket/tcp_pinger.h
index 9c7163c..8b0f416 100644
--- a/net/socket/tcp_pinger.h
+++ b/net/socket/tcp_pinger.h
@@ -87,7 +87,7 @@ class TCPPinger {
}
void DoConnect() {
- sock_.reset(new TCPClientSocket(addr_, NULL));
+ sock_.reset(new TCPClientSocket(addr_, NULL, net::NetLog::Source()));
int rv = sock_->Connect(&connect_callback_);
// Regardless of success or failure, if we're done now,
// signal the customer.
diff --git a/net/socket_stream/socket_stream.cc b/net/socket_stream/socket_stream.cc
index 5439a6c..ce82c9b 100644
--- a/net/socket_stream/socket_stream.cc
+++ b/net/socket_stream/socket_stream.cc
@@ -549,7 +549,8 @@ int SocketStream::DoTcpConnect(int result) {
next_state_ = STATE_TCP_CONNECT_COMPLETE;
DCHECK(factory_);
socket_.reset(factory_->CreateTCPClientSocket(addresses_,
- net_log_.net_log()));
+ net_log_.net_log(),
+ net_log_.source()));
metrics_->OnStartConnection();
return socket_->Connect(&io_callback_);
}