summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/client_socket.h8
-rw-r--r--net/socket/client_socket_factory.cc6
-rw-r--r--net/socket/client_socket_factory.h5
-rw-r--r--net/socket/client_socket_pool_base.cc32
-rw-r--r--net/socket/client_socket_pool_base.h2
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc52
-rw-r--r--net/socket/socket_test_util.cc24
-rw-r--r--net/socket/socket_test_util.h23
-rw-r--r--net/socket/socks5_client_socket.cc19
-rw-r--r--net/socket/socks5_client_socket.h5
-rw-r--r--net/socket/socks5_client_socket_unittest.cc80
-rw-r--r--net/socket/socks_client_socket.cc19
-rw-r--r--net/socket/socks_client_socket.h5
-rw-r--r--net/socket/socks_client_socket_pool.cc2
-rw-r--r--net/socket/socks_client_socket_pool_unittest.cc8
-rw-r--r--net/socket/socks_client_socket_unittest.cc60
-rw-r--r--net/socket/ssl_client_socket_mac.cc17
-rw-r--r--net/socket/ssl_client_socket_mac.h5
-rw-r--r--net/socket/ssl_client_socket_nss.cc18
-rw-r--r--net/socket/ssl_client_socket_nss.h5
-rw-r--r--net/socket/ssl_client_socket_unittest.cc56
-rw-r--r--net/socket/ssl_client_socket_win.cc16
-rw-r--r--net/socket/ssl_client_socket_win.h5
-rw-r--r--net/socket/tcp_client_socket_libevent.cc29
-rw-r--r--net/socket/tcp_client_socket_libevent.h8
-rw-r--r--net/socket/tcp_client_socket_pool.cc5
-rw-r--r--net/socket/tcp_client_socket_pool_unittest.cc23
-rw-r--r--net/socket/tcp_client_socket_unittest.cc26
-rw-r--r--net/socket/tcp_client_socket_win.cc33
-rw-r--r--net/socket/tcp_client_socket_win.h7
-rw-r--r--net/socket/tcp_pinger.h6
31 files changed, 327 insertions, 282 deletions
diff --git a/net/socket/client_socket.h b/net/socket/client_socket.h
index 3005708..2bc1adb 100644
--- a/net/socket/client_socket.h
+++ b/net/socket/client_socket.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -28,8 +28,7 @@ class ClientSocket : public Socket {
//
// Connect may also be called again after a call to the Disconnect method.
//
- virtual int Connect(CompletionCallback* callback,
- const BoundNetLog& net_log) = 0;
+ virtual int Connect(CompletionCallback* callback) = 0;
// Called to disconnect a socket. Does nothing if the socket is already
// disconnected. After calling Disconnect it is possible to call Connect
@@ -51,6 +50,9 @@ class ClientSocket : public Socket {
// Copies the peer address to |address| and returns a network error code.
virtual int GetPeerAddress(AddressList* address) const = 0;
+
+ // Gets the NetLog for this socket.
+ virtual const BoundNetLog& NetLog() const = 0;
};
} // namespace net
diff --git a/net/socket/client_socket_factory.cc b/net/socket/client_socket_factory.cc
index 4f05575..24d9e39 100644
--- a/net/socket/client_socket_factory.cc
+++ b/net/socket/client_socket_factory.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -40,8 +40,8 @@ SSLClientSocketFactory g_ssl_factory = DefaultSSLClientSocketFactory;
class DefaultClientSocketFactory : public ClientSocketFactory {
public:
virtual ClientSocket* CreateTCPClientSocket(
- const AddressList& addresses) {
- return new TCPClientSocket(addresses);
+ const AddressList& addresses, NetLog* net_log) {
+ return new TCPClientSocket(addresses, net_log);
}
virtual SSLClientSocket* CreateSSLClientSocket(
diff --git a/net/socket/client_socket_factory.h b/net/socket/client_socket_factory.h
index 1c97cd6..b519b32 100644
--- a/net/socket/client_socket_factory.h
+++ b/net/socket/client_socket_factory.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -11,6 +11,7 @@ namespace net {
class AddressList;
class ClientSocket;
+class NetLog;
class SSLClientSocket;
struct SSLConfig;
@@ -27,7 +28,7 @@ class ClientSocketFactory {
virtual ~ClientSocketFactory() {}
virtual ClientSocket* CreateTCPClientSocket(
- const AddressList& addresses) = 0;
+ const AddressList& addresses, NetLog* net_log) = 0;
virtual SSLClientSocket* CreateSSLClientSocket(
ClientSocket* transport_socket,
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index 4b6cff0..af87eba 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -38,15 +38,16 @@ ConnectJob::ConnectJob(const std::string& group_name,
: group_name_(group_name),
timeout_duration_(timeout_duration),
delegate_(delegate),
- net_log_(net_log) {
+ net_log_(net_log),
+ idle_(true) {
DCHECK(!group_name.empty());
DCHECK(delegate);
}
ConnectJob::~ConnectJob() {
- if (delegate_) {
+ if (delegate_ && !idle_) {
// If the delegate was not NULLed, then NotifyDelegateOfCompletion has
- // not been called yet (hence we are cancelling).
+ // not been called yet. If we've started then we are cancelling.
net_log_.AddEvent(NetLog::TYPE_CANCELLED);
net_log_.EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB);
}
@@ -58,6 +59,7 @@ int ConnectJob::Connect() {
net_log_.BeginEventWithString(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB,
group_name_);
+ idle_ = false;
int rv = ConnectInternal();
@@ -231,20 +233,17 @@ int ClientSocketPoolBaseHelper::RequestSocketInternal(
// We couldn't find a socket to reuse, so allocate and connect a new one.
BoundNetLog job_net_log = BoundNetLog::Make(
request->net_log().net_log(), NetLog::SOURCE_CONNECT_JOB);
+ request->net_log().BeginEventWithInteger(
+ NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID, job_net_log.source().id);
scoped_ptr<ConnectJob> connect_job(
connect_job_factory_->NewConnectJob(group_name, *request, this,
job_net_log));
int rv = connect_job->Connect();
-
- if (rv != ERR_IO_PENDING) {
- request->net_log().AddEventWithInteger(
- NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
- job_net_log.source().id);
- }
-
if (rv == OK) {
+ request->net_log().EndEventWithInteger(
+ NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID, job_net_log.source().id);
HandOutSocket(connect_job->ReleaseSocket(), false /* not reused */,
handle, base::TimeDelta(), &group, request->net_log());
} else if (rv == ERR_IO_PENDING) {
@@ -263,8 +262,11 @@ int ClientSocketPoolBaseHelper::RequestSocketInternal(
ConnectJob* job = connect_job.release();
group.jobs.insert(job);
- } else if (group.IsEmpty()) {
- group_map_.erase(group_name);
+ } else {
+ request->net_log().EndEventWithInteger(
+ NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID, job_net_log.source().id);
+ if (group.IsEmpty())
+ group_map_.erase(group_name);
}
return rv;
@@ -566,7 +568,7 @@ void ClientSocketPoolBaseHelper::OnConnectJobComplete(
if (!group.pending_requests.empty()) {
scoped_ptr<const Request> r(RemoveRequestFromQueue(
group.pending_requests.begin(), &group.pending_requests));
- r->net_log().AddEventWithInteger(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
+ r->net_log().EndEventWithInteger(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
job_log.source().id);
r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL);
HandOutSocket(
@@ -582,7 +584,7 @@ void ClientSocketPoolBaseHelper::OnConnectJobComplete(
if (!group.pending_requests.empty()) {
scoped_ptr<const Request> r(RemoveRequestFromQueue(
group.pending_requests.begin(), &group.pending_requests));
- r->net_log().AddEventWithInteger(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
+ r->net_log().EndEventWithInteger(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
job_log.source().id);
r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL);
r->callback()->Run(result);
@@ -678,6 +680,8 @@ void ClientSocketPoolBaseHelper::HandOutSocket(
StringPrintf("Socket sat idle for %" PRId64 " milliseconds",
idle_time.InMilliseconds()));
}
+ net_log.AddEventWithInteger(NetLog::TYPE_SOCKET_POOL_SOCKET_ID,
+ socket->NetLog().source().id);
handed_out_socket_count_++;
group->active_socket_count++;
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index d1abd58..ce25463 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -109,6 +109,8 @@ class ConnectJob {
Delegate* delegate_;
scoped_ptr<ClientSocket> socket_;
BoundNetLog net_log_;
+ // A ConnectJob is idle until Connect() has been called.
+ bool idle_;
DISALLOW_COPY_AND_ASSIGN(ConnectJob);
};
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index a706df8..f9e555ca 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -50,7 +50,7 @@ class MockClientSocket : public ClientSocket {
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log) {
+ virtual int Connect(CompletionCallback* callback) {
connected_ = true;
return OK;
}
@@ -63,8 +63,13 @@ class MockClientSocket : public ClientSocket {
return ERR_UNEXPECTED;
}
+ virtual const BoundNetLog& NetLog() const {
+ return net_log_;
+ }
+
private:
bool connected_;
+ BoundNetLog net_log_;
DISALLOW_COPY_AND_ASSIGN(MockClientSocket);
};
@@ -75,7 +80,8 @@ class MockClientSocketFactory : public ClientSocketFactory {
public:
MockClientSocketFactory() : allocation_count_(0) {}
- virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses) {
+ virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses,
+ NetLog* /* net_log */) {
allocation_count_++;
return NULL;
}
@@ -133,7 +139,7 @@ class TestConnectJob : public ConnectJob {
virtual int ConnectInternal() {
AddressList ignored;
- client_socket_factory_->CreateTCPClientSocket(ignored);
+ client_socket_factory_->CreateTCPClientSocket(ignored, NULL);
set_socket(new MockClientSocket());
switch (job_type_) {
case kMockJob:
@@ -196,7 +202,7 @@ class TestConnectJob : public ConnectJob {
int result = ERR_CONNECTION_FAILED;
if (succeed) {
result = OK;
- socket()->Connect(NULL, NULL);
+ socket()->Connect(NULL);
} else {
set_socket(NULL);
}
@@ -520,18 +526,22 @@ TEST_F(ClientSocketPoolBaseTest, BasicSynchronous) {
EXPECT_TRUE(handle.socket());
handle.Reset();
- EXPECT_EQ(5u, log.entries().size());
+ EXPECT_EQ(7u, log.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(
log.entries(), 0, NetLog::TYPE_SOCKET_POOL));
EXPECT_TRUE(LogContainsBeginEvent(
- log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
- EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID));
+ EXPECT_TRUE(LogContainsBeginEvent(
log.entries(), 2, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 3, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 4, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID));
EXPECT_TRUE(LogContainsEvent(
- log.entries(), 3, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
+ log.entries(), 5, NetLog::TYPE_SOCKET_POOL_SOCKET_ID,
NetLog::PHASE_NONE));
EXPECT_TRUE(LogContainsEndEvent(
- log.entries(), 4, NetLog::TYPE_SOCKET_POOL));
+ log.entries(), 6, NetLog::TYPE_SOCKET_POOL));
}
TEST_F(ClientSocketPoolBaseTest, InitConnectionFailure) {
@@ -545,13 +555,13 @@ TEST_F(ClientSocketPoolBaseTest, InitConnectionFailure) {
InitHandle(req.handle(), "a", kDefaultPriority, &req, pool_,
log.bound()));
- EXPECT_EQ(5u, log.entries().size());
+ EXPECT_EQ(6u, log.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKET_POOL));
EXPECT_TRUE(LogContainsBeginEvent(
- log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
- EXPECT_TRUE(LogContainsEndEvent(
log.entries(), 2, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
- EXPECT_TRUE(LogContainsEndEvent(log.entries(), 4, NetLog::TYPE_SOCKET_POOL));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 3, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ EXPECT_TRUE(LogContainsEndEvent(log.entries(), 5, NetLog::TYPE_SOCKET_POOL));
}
TEST_F(ClientSocketPoolBaseTest, TotalLimit) {
@@ -1158,15 +1168,15 @@ TEST_F(ClientSocketPoolBaseTest, BasicAsynchronous) {
EXPECT_TRUE(req.handle()->socket());
req.handle()->Reset();
- EXPECT_EQ(5u, log.entries().size());
+ EXPECT_EQ(7u, log.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(
log.entries(), 0, NetLog::TYPE_SOCKET_POOL));
EXPECT_TRUE(LogContainsBeginEvent(
- log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
- EXPECT_TRUE(LogContainsEndEvent(
log.entries(), 2, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
EXPECT_TRUE(LogContainsEndEvent(
- log.entries(), 4, NetLog::TYPE_SOCKET_POOL));
+ log.entries(), 3, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 5, NetLog::TYPE_SOCKET_POOL));
}
TEST_F(ClientSocketPoolBaseTest,
@@ -1182,15 +1192,15 @@ TEST_F(ClientSocketPoolBaseTest,
EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", req.handle()));
EXPECT_EQ(ERR_CONNECTION_FAILED, req.WaitForResult());
- EXPECT_EQ(5u, log.entries().size());
+ EXPECT_EQ(6u, log.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(
log.entries(), 0, NetLog::TYPE_SOCKET_POOL));
EXPECT_TRUE(LogContainsBeginEvent(
- log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
- EXPECT_TRUE(LogContainsEndEvent(
log.entries(), 2, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
EXPECT_TRUE(LogContainsEndEvent(
- log.entries(), 4, NetLog::TYPE_SOCKET_POOL));
+ log.entries(), 3, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 5, NetLog::TYPE_SOCKET_POOL));
}
TEST_F(ClientSocketPoolBaseTest, TwoRequestsCancelOne) {
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index 18790be..9e74d88 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -18,9 +18,10 @@
namespace net {
-MockClientSocket::MockClientSocket()
+MockClientSocket::MockClientSocket(net::NetLog* net_log)
: ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
- connected_(false) {
+ connected_(false),
+ net_log_(NetLog::Source(), net_log) {
}
void MockClientSocket::GetSSLInfo(net::SSLInfo* ssl_info) {
@@ -69,8 +70,10 @@ void MockClientSocket::RunCallback(net::CompletionCallback* callback,
}
MockTCPClientSocket::MockTCPClientSocket(const net::AddressList& addresses,
+ net::NetLog* net_log,
net::SocketDataProvider* data)
- : addresses_(addresses),
+ : MockClientSocket(net_log),
+ addresses_(addresses),
data_(data),
read_offset_(0),
read_data_(false, net::ERR_UNEXPECTED),
@@ -83,8 +86,7 @@ MockTCPClientSocket::MockTCPClientSocket(const net::AddressList& addresses,
data_->Reset();
}
-int MockTCPClientSocket::Connect(net::CompletionCallback* callback,
- const BoundNetLog& net_log) {
+int MockTCPClientSocket::Connect(net::CompletionCallback* callback) {
if (connected_)
return net::OK;
connected_ = true;
@@ -244,7 +246,8 @@ MockSSLClientSocket::MockSSLClientSocket(
const std::string& hostname,
const net::SSLConfig& ssl_config,
net::SSLSocketDataProvider* data)
- : transport_(transport_socket),
+ : MockClientSocket(transport_socket->NetLog().net_log()),
+ transport_(transport_socket),
data_(data) {
DCHECK(data_);
}
@@ -257,11 +260,10 @@ void MockSSLClientSocket::GetSSLInfo(net::SSLInfo* ssl_info) {
ssl_info->Reset();
}
-int MockSSLClientSocket::Connect(net::CompletionCallback* callback,
- const BoundNetLog& net_log) {
+int MockSSLClientSocket::Connect(net::CompletionCallback* callback) {
ConnectCallback* connect_callback = new ConnectCallback(
this, callback, data_->connect.result);
- int rv = transport_->Connect(connect_callback, net_log);
+ int rv = transport_->Connect(connect_callback);
if (rv == net::OK) {
delete connect_callback;
if (data_->connect.async) {
@@ -412,10 +414,10 @@ MockSSLClientSocket* MockClientSocketFactory::GetMockSSLClientSocket(
}
ClientSocket* MockClientSocketFactory::CreateTCPClientSocket(
- const AddressList& addresses) {
+ const AddressList& addresses, net::NetLog* net_log) {
SocketDataProvider* data_provider = mock_data_.GetNext();
MockTCPClientSocket* socket =
- new MockTCPClientSocket(addresses, data_provider);
+ new MockTCPClientSocket(addresses, net_log, data_provider);
data_provider->set_socket(socket);
tcp_client_sockets_.push_back(socket);
return socket;
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index 91522ed..4358a72 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -17,6 +17,7 @@
#include "net/base/address_list.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/base/ssl_config_service.h"
#include "net/base/test_completion_callback.h"
#include "net/socket/client_socket_factory.h"
@@ -35,7 +36,6 @@ enum {
ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ = -10000,
};
-class BoundNetLog;
class ClientSocket;
class MockClientSocket;
class SSLClientSocket;
@@ -289,7 +289,8 @@ class MockClientSocketFactory : public ClientSocketFactory {
MockSSLClientSocket* GetMockSSLClientSocket(size_t index) const;
// ClientSocketFactory
- virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses);
+ virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses,
+ NetLog* net_log);
virtual SSLClientSocket* CreateSSLClientSocket(
ClientSocket* transport_socket,
const std::string& hostname,
@@ -306,15 +307,15 @@ class MockClientSocketFactory : public ClientSocketFactory {
class MockClientSocket : public net::SSLClientSocket {
public:
- MockClientSocket();
+ explicit MockClientSocket(net::NetLog* net_log);
// ClientSocket methods:
- virtual int Connect(net::CompletionCallback* callback,
- const BoundNetLog& net_log) = 0;
+ virtual int Connect(net::CompletionCallback* callback) = 0;
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(AddressList* address) const;
+ virtual const BoundNetLog& NetLog() const { return net_log_;}
// SSLClientSocket methods:
virtual void GetSSLInfo(net::SSLInfo* ssl_info);
@@ -345,16 +346,17 @@ class MockClientSocket : public net::SSLClientSocket {
// True if Connect completed successfully and Disconnect hasn't been called.
bool connected_;
+
+ net::BoundNetLog net_log_;
};
class MockTCPClientSocket : public MockClientSocket {
public:
- MockTCPClientSocket(const net::AddressList& addresses,
+ MockTCPClientSocket(const net::AddressList& addresses, net::NetLog* net_log,
net::SocketDataProvider* socket);
// ClientSocket methods:
- virtual int Connect(net::CompletionCallback* callback,
- const BoundNetLog& net_log);
+ virtual int Connect(net::CompletionCallback* callback);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const { return IsConnected(); }
@@ -401,8 +403,7 @@ class MockSSLClientSocket : public MockClientSocket {
virtual void GetSSLInfo(net::SSLInfo* ssl_info);
- virtual int Connect(net::CompletionCallback* callback,
- const BoundNetLog& net_log);
+ virtual int Connect(net::CompletionCallback* callback);
virtual void Disconnect();
// Socket methods:
diff --git a/net/socket/socks5_client_socket.cc b/net/socket/socks5_client_socket.cc
index eef3403..c960b80 100644
--- a/net/socket/socks5_client_socket.cc
+++ b/net/socket/socks5_client_socket.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -59,7 +59,8 @@ SOCKS5ClientSocket::SOCKS5ClientSocket(
bytes_sent_(0),
bytes_received_(0),
read_header_size(kReadHeaderSize),
- host_request_info_(req_info) {
+ host_request_info_(req_info),
+ net_log_(transport_socket->socket()->NetLog()) {
}
SOCKS5ClientSocket::SOCKS5ClientSocket(
@@ -74,7 +75,8 @@ SOCKS5ClientSocket::SOCKS5ClientSocket(
bytes_sent_(0),
bytes_received_(0),
read_header_size(kReadHeaderSize),
- host_request_info_(req_info) {
+ host_request_info_(req_info),
+ net_log_(transport_socket->NetLog()) {
transport_->set_socket(transport_socket);
}
@@ -82,8 +84,7 @@ SOCKS5ClientSocket::~SOCKS5ClientSocket() {
Disconnect();
}
-int SOCKS5ClientSocket::Connect(CompletionCallback* callback,
- const BoundNetLog& net_log) {
+int SOCKS5ClientSocket::Connect(CompletionCallback* callback) {
DCHECK(transport_.get());
DCHECK(transport_->socket());
DCHECK(transport_->socket()->IsConnected());
@@ -94,8 +95,7 @@ int SOCKS5ClientSocket::Connect(CompletionCallback* callback,
if (completed_handshake_)
return OK;
- net_log_ = net_log;
- net_log.BeginEvent(NetLog::TYPE_SOCKS5_CONNECT);
+ net_log_.BeginEvent(NetLog::TYPE_SOCKS5_CONNECT);
next_state_ = STATE_GREET_WRITE;
buffer_.clear();
@@ -104,8 +104,7 @@ int SOCKS5ClientSocket::Connect(CompletionCallback* callback,
if (rv == ERR_IO_PENDING) {
user_callback_ = callback;
} else {
- net_log.EndEvent(NetLog::TYPE_SOCKS5_CONNECT);
- net_log_ = BoundNetLog();
+ net_log_.EndEvent(NetLog::TYPE_SOCKS5_CONNECT);
}
return rv;
}
@@ -118,7 +117,6 @@ void SOCKS5ClientSocket::Disconnect() {
// These are the states initialized by Connect().
next_state_ = STATE_NONE;
user_callback_ = NULL;
- net_log_ = BoundNetLog();
}
bool SOCKS5ClientSocket::IsConnected() const {
@@ -175,7 +173,6 @@ void SOCKS5ClientSocket::OnIOComplete(int result) {
int rv = DoLoop(result);
if (rv != ERR_IO_PENDING) {
net_log_.EndEvent(NetLog::TYPE_SOCKS5_CONNECT);
- net_log_ = BoundNetLog();
DoCallback(rv);
}
}
diff --git a/net/socket/socks5_client_socket.h b/net/socket/socks5_client_socket.h
index 3e30c19..e6150f3 100644
--- a/net/socket/socks5_client_socket.h
+++ b/net/socket/socks5_client_socket.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -50,10 +50,11 @@ class SOCKS5ClientSocket : public ClientSocket {
// ClientSocket methods:
// Does the SOCKS handshake and completes the protocol.
- virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
+ virtual int Connect(CompletionCallback* callback);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
+ virtual const BoundNetLog& NetLog() const { return net_log_; }
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
diff --git a/net/socket/socks5_client_socket_unittest.cc b/net/socket/socks5_client_socket_unittest.cc
index d9d1012..eb4109a 100644
--- a/net/socket/socks5_client_socket_unittest.cc
+++ b/net/socket/socks5_client_socket_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -36,12 +36,14 @@ class SOCKS5ClientSocketTest : public PlatformTest {
MockWrite writes[],
size_t writes_count,
const std::string& hostname,
- int port);
+ int port,
+ NetLog* net_log);
virtual void SetUp();
protected:
const uint16 kNwPort;
+ CapturingNetLog net_log_;
scoped_ptr<SOCKS5ClientSocket> user_sock_;
AddressList address_list_;
ClientSocket* tcp_sock_;
@@ -54,7 +56,9 @@ class SOCKS5ClientSocketTest : public PlatformTest {
};
SOCKS5ClientSocketTest::SOCKS5ClientSocketTest()
- : kNwPort(htons(80)), host_resolver_(new MockHostResolver) {
+ : kNwPort(htons(80)),
+ net_log_(CapturingNetLog::kUnbounded),
+ host_resolver_(new MockHostResolver) {
}
// Set up platform before every test case
@@ -73,13 +77,14 @@ SOCKS5ClientSocket* SOCKS5ClientSocketTest::BuildMockSocket(
MockWrite writes[],
size_t writes_count,
const std::string& hostname,
- int port) {
+ int port,
+ NetLog* net_log) {
TestCompletionCallback callback;
data_.reset(new StaticSocketDataProvider(reads, reads_count,
writes, writes_count));
- tcp_sock_ = new MockTCPClientSocket(address_list_, data_.get());
+ tcp_sock_ = new MockTCPClientSocket(address_list_, net_log, data_.get());
- int rv = tcp_sock_->Connect(&callback, NULL);
+ int rv = tcp_sock_->Connect(&callback);
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
@@ -116,23 +121,24 @@ TEST_F(SOCKS5ClientSocketTest, CompleteHandshake) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- "localhost", 80));
+ "localhost", 80, &net_log_));
// At this state the TCP connection is completed but not the SOCKS handshake.
EXPECT_TRUE(tcp_sock_->IsConnected());
EXPECT_FALSE(user_sock_->IsConnected());
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = user_sock_->Connect(&callback_, log.bound());
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(net_log_.entries(), 0,
+ NetLog::TYPE_SOCKS5_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(log.entries(), -1, NetLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(net_log_.entries(), -1,
+ NetLog::TYPE_SOCKS5_CONNECT));
scoped_refptr<IOBuffer> buffer = new IOBuffer(payload_write.size());
memcpy(buffer->data(), payload_write.data(), payload_write.size());
@@ -180,9 +186,9 @@ TEST_F(SOCKS5ClientSocketTest, ConnectAndDisconnectTwice) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- hostname, 80));
+ hostname, 80, NULL));
- int rv = user_sock_->Connect(&callback_, NULL);
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
@@ -202,12 +208,12 @@ TEST_F(SOCKS5ClientSocketTest, LargeHostNameFails) {
MockRead data_reads[] = {MockRead()};
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- large_host_name, 80));
+ large_host_name, 80, NULL));
// Try to connect -- should fail (without having read/written anything to
// the transport socket first) because the hostname is too long.
TestCompletionCallback callback;
- int rv = user_sock_->Connect(&callback, NULL);
+ int rv = user_sock_->Connect(&callback);
EXPECT_EQ(ERR_SOCKS_CONNECTION_FAILED, rv);
}
@@ -238,15 +244,16 @@ TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) {
MockRead(true, kSOCKS5OkResponse, kSOCKS5OkResponseLength) };
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- hostname, 80));
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = user_sock_->Connect(&callback_, log.bound());
+ hostname, 80, &net_log_));
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(net_log_.entries(), 0,
+ NetLog::TYPE_SOCKS5_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(log.entries(), -1, NetLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(net_log_.entries(), -1,
+ NetLog::TYPE_SOCKS5_CONNECT));
}
// Test for partial greet response read
@@ -262,15 +269,16 @@ TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) {
MockRead(true, kSOCKS5OkResponse, kSOCKS5OkResponseLength) };
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- hostname, 80));
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = user_sock_->Connect(&callback_, log.bound());
+ hostname, 80, &net_log_));
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(net_log_.entries(), 0,
+ NetLog::TYPE_SOCKS5_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(log.entries(), -1, NetLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(net_log_.entries(), -1,
+ NetLog::TYPE_SOCKS5_CONNECT));
}
// Test for partial handshake request write.
@@ -287,15 +295,16 @@ TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) {
MockRead(true, kSOCKS5OkResponse, kSOCKS5OkResponseLength) };
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- hostname, 80));
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = user_sock_->Connect(&callback_, log.bound());
+ hostname, 80, &net_log_));
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(net_log_.entries(), 0,
+ NetLog::TYPE_SOCKS5_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(log.entries(), -1, NetLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(net_log_.entries(), -1,
+ NetLog::TYPE_SOCKS5_CONNECT));
}
// Test for partial handshake response read
@@ -314,15 +323,16 @@ TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- hostname, 80));
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = user_sock_->Connect(&callback_, log.bound());
+ hostname, 80, &net_log_));
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(net_log_.entries(), 0,
+ NetLog::TYPE_SOCKS5_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(log.entries(), -1, NetLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(net_log_.entries(), -1,
+ NetLog::TYPE_SOCKS5_CONNECT));
}
}
diff --git a/net/socket/socks_client_socket.cc b/net/socket/socks_client_socket.cc
index e5049ff..ec51099 100644
--- a/net/socket/socks_client_socket.cc
+++ b/net/socket/socks_client_socket.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -73,7 +73,8 @@ SOCKSClientSocket::SOCKSClientSocket(ClientSocketHandle* transport_socket,
bytes_sent_(0),
bytes_received_(0),
host_resolver_(host_resolver),
- host_request_info_(req_info) {
+ host_request_info_(req_info),
+ net_log_(transport_socket->socket()->NetLog()) {
}
SOCKSClientSocket::SOCKSClientSocket(ClientSocket* transport_socket,
@@ -89,7 +90,8 @@ SOCKSClientSocket::SOCKSClientSocket(ClientSocket* transport_socket,
bytes_sent_(0),
bytes_received_(0),
host_resolver_(host_resolver),
- host_request_info_(req_info) {
+ host_request_info_(req_info),
+ net_log_(transport_socket->NetLog()) {
transport_->set_socket(transport_socket);
}
@@ -97,8 +99,7 @@ SOCKSClientSocket::~SOCKSClientSocket() {
Disconnect();
}
-int SOCKSClientSocket::Connect(CompletionCallback* callback,
- const BoundNetLog& net_log) {
+int SOCKSClientSocket::Connect(CompletionCallback* callback) {
DCHECK(transport_.get());
DCHECK(transport_->socket());
DCHECK(transport_->socket()->IsConnected());
@@ -110,16 +111,14 @@ int SOCKSClientSocket::Connect(CompletionCallback* callback,
return OK;
next_state_ = STATE_RESOLVE_HOST;
- net_log_ = net_log;
- net_log.BeginEvent(NetLog::TYPE_SOCKS_CONNECT);
+ net_log_.BeginEvent(NetLog::TYPE_SOCKS_CONNECT);
int rv = DoLoop(OK);
if (rv == ERR_IO_PENDING) {
user_callback_ = callback;
} else {
- net_log.EndEvent(NetLog::TYPE_SOCKS_CONNECT);
- net_log_ = BoundNetLog();
+ net_log_.EndEvent(NetLog::TYPE_SOCKS_CONNECT);
}
return rv;
}
@@ -133,7 +132,6 @@ void SOCKSClientSocket::Disconnect() {
// These are the states initialized by Connect().
next_state_ = STATE_NONE;
user_callback_ = NULL;
- net_log_ = BoundNetLog();
}
bool SOCKSClientSocket::IsConnected() const {
@@ -191,7 +189,6 @@ void SOCKSClientSocket::OnIOComplete(int result) {
int rv = DoLoop(result);
if (rv != ERR_IO_PENDING) {
net_log_.EndEvent(NetLog::TYPE_SOCKS_CONNECT);
- net_log_ = BoundNetLog();
DoCallback(rv);
}
}
diff --git a/net/socket/socks_client_socket.h b/net/socket/socks_client_socket.h
index 7aabf5d..f99bff0 100644
--- a/net/socket/socks_client_socket.h
+++ b/net/socket/socks_client_socket.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -47,10 +47,11 @@ class SOCKSClientSocket : public ClientSocket {
// ClientSocket methods:
// Does the SOCKS handshake and completes the protocol.
- virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
+ virtual int Connect(CompletionCallback* callback);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
+ virtual const BoundNetLog& NetLog() const { return net_log_; }
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
diff --git a/net/socket/socks_client_socket_pool.cc b/net/socket/socks_client_socket_pool.cc
index 246cc20..b98f9fd 100644
--- a/net/socket/socks_client_socket_pool.cc
+++ b/net/socket/socks_client_socket_pool.cc
@@ -128,7 +128,7 @@ int SOCKSConnectJob::DoSOCKSConnect() {
socks_params_.destination(),
resolver_));
}
- return socket_->Connect(&callback_, net_log());
+ return socket_->Connect(&callback_);
}
int SOCKSConnectJob::DoSOCKSConnectComplete(int result) {
diff --git a/net/socket/socks_client_socket_pool_unittest.cc b/net/socket/socks_client_socket_pool_unittest.cc
index 4291f3c..e2e30a3 100644
--- a/net/socket/socks_client_socket_pool_unittest.cc
+++ b/net/socket/socks_client_socket_pool_unittest.cc
@@ -37,8 +37,8 @@ class MockTCPClientSocketPool : public TCPClientSocketPool {
ALLOW_THIS_IN_INITIALIZER_LIST(
connect_callback_(this, &MockConnectJob::OnConnect)) {}
- int Connect(const BoundNetLog& net_log) {
- int rv = socket_->Connect(&connect_callback_, net_log);
+ int Connect() {
+ int rv = socket_->Connect(&connect_callback_);
if (rv == OK) {
user_callback_ = NULL;
OnConnect(OK);
@@ -103,10 +103,10 @@ class MockTCPClientSocketPool : public TCPClientSocketPool {
CompletionCallback* callback,
const BoundNetLog& net_log) {
ClientSocket* socket = client_socket_factory_->CreateTCPClientSocket(
- AddressList());
+ AddressList(), net_log.net_log());
MockConnectJob* job = new MockConnectJob(socket, handle, callback);
job_list_.push_back(job);
- return job->Connect(net_log);
+ return job->Connect();
}
virtual void CancelRequest(const std::string& group_name,
diff --git a/net/socket/socks_client_socket_unittest.cc b/net/socket/socks_client_socket_unittest.cc
index ef11107..eb2ab6a 100644
--- a/net/socket/socks_client_socket_unittest.cc
+++ b/net/socket/socks_client_socket_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -32,7 +32,8 @@ class SOCKSClientSocketTest : public PlatformTest {
SOCKSClientSocket* BuildMockSocket(MockRead reads[], size_t reads_count,
MockWrite writes[], size_t writes_count,
HostResolver* host_resolver,
- const std::string& hostname, int port);
+ const std::string& hostname, int port,
+ NetLog* net_log);
virtual void SetUp();
protected:
@@ -63,14 +64,15 @@ SOCKSClientSocket* SOCKSClientSocketTest::BuildMockSocket(
size_t writes_count,
HostResolver* host_resolver,
const std::string& hostname,
- int port) {
+ int port,
+ NetLog* net_log) {
TestCompletionCallback callback;
data_.reset(new StaticSocketDataProvider(reads, reads_count,
writes, writes_count));
- tcp_sock_ = new MockTCPClientSocket(address_list_, data_.get());
+ tcp_sock_ = new MockTCPClientSocket(address_list_, net_log, data_.get());
- int rv = tcp_sock_->Connect(&callback, NULL);
+ int rv = tcp_sock_->Connect(&callback);
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
@@ -129,17 +131,17 @@ TEST_F(SOCKSClientSocketTest, CompleteHandshake) {
MockRead data_reads[] = {
MockRead(true, kSOCKSOkReply, arraysize(kSOCKSOkReply)),
MockRead(true, payload_read.data(), payload_read.size()) };
+ CapturingNetLog log(CapturingNetLog::kUnbounded);
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, "localhost", 80));
+ host_resolver_, "localhost", 80, &log));
// At this state the TCP connection is completed but not the SOCKS handshake.
EXPECT_TRUE(tcp_sock_->IsConnected());
EXPECT_FALSE(user_sock_->IsConnected());
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = user_sock_->Connect(&callback_, log.bound());
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_TRUE(
LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
@@ -197,13 +199,13 @@ TEST_F(SOCKSClientSocketTest, HandshakeFailures) {
MockWrite(false, kSOCKSOkRequest, arraysize(kSOCKSOkRequest)) };
MockRead data_reads[] = {
MockRead(false, tests[i].fail_reply, arraysize(tests[i].fail_reply)) };
+ CapturingNetLog log(CapturingNetLog::kUnbounded);
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, "localhost", 80));
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ host_resolver_, "localhost", 80, &log));
- int rv = user_sock_->Connect(&callback_, log.bound());
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_TRUE(LogContainsBeginEvent(
log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
@@ -227,14 +229,13 @@ TEST_F(SOCKSClientSocketTest, PartialServerReads) {
MockRead data_reads[] = {
MockRead(true, kSOCKSPartialReply1, arraysize(kSOCKSPartialReply1)),
MockRead(true, kSOCKSPartialReply2, arraysize(kSOCKSPartialReply2)) };
+ CapturingNetLog log(CapturingNetLog::kUnbounded);
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, "localhost", 80));
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ host_resolver_, "localhost", 80, &log));
-
- int rv = user_sock_->Connect(&callback_, log.bound());
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_TRUE(LogContainsBeginEvent(
log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
@@ -260,13 +261,13 @@ TEST_F(SOCKSClientSocketTest, PartialClientWrites) {
arraysize(kSOCKSPartialRequest2)) };
MockRead data_reads[] = {
MockRead(true, kSOCKSOkReply, arraysize(kSOCKSOkReply)) };
+ CapturingNetLog log(CapturingNetLog::kUnbounded);
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, "localhost", 80));
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ host_resolver_, "localhost", 80, &log));
- int rv = user_sock_->Connect(&callback_, log.bound());
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_TRUE(LogContainsBeginEvent(
log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
@@ -286,14 +287,13 @@ TEST_F(SOCKSClientSocketTest, FailedSocketRead) {
MockRead(true, kSOCKSOkReply, arraysize(kSOCKSOkReply) - 2),
// close connection unexpectedly
MockRead(false, 0) };
+ CapturingNetLog log(CapturingNetLog::kUnbounded);
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, "localhost", 80));
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
-
+ host_resolver_, "localhost", 80, &log));
- int rv = user_sock_->Connect(&callback_, log.bound());
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_TRUE(LogContainsBeginEvent(
log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
@@ -318,13 +318,13 @@ TEST_F(SOCKSClientSocketTest, SOCKS4AFailedDNS) {
MockWrite(false, request.data(), request.size()) };
MockRead data_reads[] = {
MockRead(false, kSOCKSOkReply, arraysize(kSOCKSOkReply)) };
+ CapturingNetLog log(CapturingNetLog::kUnbounded);
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, hostname, 80));
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ host_resolver_, hostname, 80, &log));
- int rv = user_sock_->Connect(&callback_, log.bound());
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_TRUE(LogContainsBeginEvent(
log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
@@ -351,13 +351,13 @@ TEST_F(SOCKSClientSocketTest, SOCKS4AIfDomainInIPv6) {
MockWrite(false, request.data(), request.size()) };
MockRead data_reads[] = {
MockRead(false, kSOCKSOkReply, arraysize(kSOCKSOkReply)) };
+ CapturingNetLog log(CapturingNetLog::kUnbounded);
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, hostname, 80));
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ host_resolver_, hostname, 80, &log));
- int rv = user_sock_->Connect(&callback_, log.bound());
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_TRUE(LogContainsBeginEvent(
log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
@@ -381,10 +381,10 @@ TEST_F(SOCKSClientSocketTest, DisconnectWhileHostResolveInProgress) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- hanging_resolver, "foo", 80));
+ hanging_resolver, "foo", 80, NULL));
// Start connecting (will get stuck waiting for the host to resolve).
- int rv = user_sock_->Connect(&callback_, NULL);
+ int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(user_sock_->IsConnected());
diff --git a/net/socket/ssl_client_socket_mac.cc b/net/socket/ssl_client_socket_mac.cc
index 9a51395..4c36009 100644
--- a/net/socket/ssl_client_socket_mac.cc
+++ b/net/socket/ssl_client_socket_mac.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -518,34 +518,33 @@ SSLClientSocketMac::SSLClientSocketMac(ClientSocket* transport_socket,
handshake_interrupted_(false),
client_cert_requested_(false),
ssl_context_(NULL),
- pending_send_error_(OK) {
+ pending_send_error_(OK),
+ net_log_(transport_socket->NetLog()) {
}
SSLClientSocketMac::~SSLClientSocketMac() {
Disconnect();
}
-int SSLClientSocketMac::Connect(CompletionCallback* callback,
- const BoundNetLog& net_log) {
+int SSLClientSocketMac::Connect(CompletionCallback* callback) {
DCHECK(transport_.get());
DCHECK(next_handshake_state_ == STATE_NONE);
DCHECK(!user_connect_callback_);
- net_log.BeginEvent(NetLog::TYPE_SSL_CONNECT);
+ net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT);
int rv = InitializeSSLContext();
if (rv != OK) {
- net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
+ net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
return rv;
}
next_handshake_state_ = STATE_HANDSHAKE_START;
rv = DoHandshakeLoop(OK);
if (rv == ERR_IO_PENDING) {
- net_log_ = net_log;
user_connect_callback_ = callback;
} else {
- net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
+ net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
}
return rv;
}
@@ -868,7 +867,6 @@ void SSLClientSocketMac::OnHandshakeIOComplete(int result) {
int rv = DoHandshakeLoop(result);
if (rv != ERR_IO_PENDING) {
net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
- net_log_ = BoundNetLog();
DoConnectCallback(rv);
}
}
@@ -885,7 +883,6 @@ void SSLClientSocketMac::OnTransportReadComplete(int result) {
int rv = DoHandshakeLoop(result);
if (rv != ERR_IO_PENDING) {
net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
- net_log_ = BoundNetLog();
DoConnectCallback(rv);
}
return;
diff --git a/net/socket/ssl_client_socket_mac.h b/net/socket/ssl_client_socket_mac.h
index 09a3bc3..bb25bda 100644
--- a/net/socket/ssl_client_socket_mac.h
+++ b/net/socket/ssl_client_socket_mac.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -39,11 +39,12 @@ class SSLClientSocketMac : public SSLClientSocket {
virtual NextProtoStatus GetNextProto(std::string* proto);
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
+ virtual int Connect(CompletionCallback* callback);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(AddressList* address) const;
+ virtual const BoundNetLog& NetLog() const { return net_log_; }
// 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 7fdc424..a033c79 100644
--- a/net/socket/ssl_client_socket_nss.cc
+++ b/net/socket/ssl_client_socket_nss.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -253,7 +253,8 @@ SSLClientSocketNSS::SSLClientSocketNSS(ClientSocket* transport_socket,
completed_handshake_(false),
next_handshake_state_(STATE_NONE),
nss_fd_(NULL),
- nss_bufs_(NULL) {
+ nss_bufs_(NULL),
+ net_log_(transport_socket->NetLog()) {
EnterFunction("");
}
@@ -281,8 +282,7 @@ int SSLClientSocketNSS::Init() {
return OK;
}
-int SSLClientSocketNSS::Connect(CompletionCallback* callback,
- const BoundNetLog& net_log) {
+int SSLClientSocketNSS::Connect(CompletionCallback* callback) {
EnterFunction("");
DCHECK(transport_.get());
DCHECK(next_handshake_state_ == STATE_NONE);
@@ -292,17 +292,17 @@ int SSLClientSocketNSS::Connect(CompletionCallback* callback,
DCHECK(!user_read_buf_);
DCHECK(!user_write_buf_);
- net_log.BeginEvent(NetLog::TYPE_SSL_CONNECT);
+ net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT);
int rv = Init();
if (rv != OK) {
- net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
+ net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
return rv;
}
rv = InitializeSSLOptions();
if (rv != OK) {
- net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
+ net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
return rv;
}
@@ -310,9 +310,8 @@ int SSLClientSocketNSS::Connect(CompletionCallback* callback,
rv = DoHandshakeLoop(OK);
if (rv == ERR_IO_PENDING) {
user_connect_callback_ = callback;
- net_log_ = net_log;
} else {
- net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
+ net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
}
LeaveFunction("");
@@ -819,7 +818,6 @@ void SSLClientSocketNSS::OnHandshakeIOComplete(int result) {
int rv = DoHandshakeLoop(result);
if (rv != ERR_IO_PENDING) {
net_log_.EndEvent(net::NetLog::TYPE_SSL_CONNECT);
- net_log_ = BoundNetLog();
DoConnectCallback(rv);
}
LeaveFunction("");
diff --git a/net/socket/ssl_client_socket_nss.h b/net/socket/ssl_client_socket_nss.h
index 7cac7fb..3543df7 100644
--- a/net/socket/ssl_client_socket_nss.h
+++ b/net/socket/ssl_client_socket_nss.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -45,11 +45,12 @@ class SSLClientSocketNSS : public SSLClientSocket {
virtual NextProtoStatus GetNextProto(std::string* proto);
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
+ virtual int Connect(CompletionCallback* callback);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(AddressList* address) const;
+ virtual const BoundNetLog& NetLog() const { return net_log_; }
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc
index 4984fc7..86243af 100644
--- a/net/socket/ssl_client_socket_unittest.cc
+++ b/net/socket/ssl_client_socket_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -68,8 +68,9 @@ TEST_F(SSLClientSocketTest, Connect) {
int rv = resolver_->Resolve(info, &addr, NULL, NULL, NULL);
EXPECT_EQ(net::OK, rv);
- net::ClientSocket *transport = new net::TCPClientSocket(addr);
- rv = transport->Connect(&callback, NULL);
+ net::CapturingNetLog log(net::CapturingNetLog::kUnbounded);
+ net::ClientSocket* transport = new net::TCPClientSocket(addr, &log);
+ rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
EXPECT_EQ(net::OK, rv);
@@ -80,10 +81,9 @@ TEST_F(SSLClientSocketTest, Connect) {
EXPECT_FALSE(sock->IsConnected());
- net::CapturingBoundNetLog log(net::CapturingNetLog::kUnbounded);
- rv = sock->Connect(&callback, log.bound());
+ rv = sock->Connect(&callback);
EXPECT_TRUE(net::LogContainsBeginEvent(
- log.entries(), 0, net::NetLog::TYPE_SSL_CONNECT));
+ log.entries(), 2, net::NetLog::TYPE_SSL_CONNECT));
if (rv != net::OK) {
ASSERT_EQ(net::ERR_IO_PENDING, rv);
EXPECT_FALSE(sock->IsConnected());
@@ -112,8 +112,9 @@ TEST_F(SSLClientSocketTest, ConnectExpired) {
int rv = resolver_->Resolve(info, &addr, NULL, NULL, NULL);
EXPECT_EQ(net::OK, rv);
- net::ClientSocket *transport = new net::TCPClientSocket(addr);
- rv = transport->Connect(&callback, NULL);
+ net::CapturingNetLog log(net::CapturingNetLog::kUnbounded);
+ net::ClientSocket* transport = new net::TCPClientSocket(addr, &log);
+ rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
EXPECT_EQ(net::OK, rv);
@@ -124,10 +125,9 @@ TEST_F(SSLClientSocketTest, ConnectExpired) {
EXPECT_FALSE(sock->IsConnected());
- net::CapturingBoundNetLog log(net::CapturingNetLog::kUnbounded);
- rv = sock->Connect(&callback, log.bound());
+ rv = sock->Connect(&callback);
EXPECT_TRUE(net::LogContainsBeginEvent(
- log.entries(), 0, net::NetLog::TYPE_SSL_CONNECT));
+ log.entries(), 2, net::NetLog::TYPE_SSL_CONNECT));
if (rv != net::OK) {
ASSERT_EQ(net::ERR_IO_PENDING, rv);
EXPECT_FALSE(sock->IsConnected());
@@ -157,8 +157,9 @@ TEST_F(SSLClientSocketTest, ConnectMismatched) {
int rv = resolver_->Resolve(info, &addr, NULL, NULL, NULL);
EXPECT_EQ(net::OK, rv);
- net::ClientSocket *transport = new net::TCPClientSocket(addr);
- rv = transport->Connect(&callback, NULL);
+ net::CapturingNetLog log(net::CapturingNetLog::kUnbounded);
+ net::ClientSocket* transport = new net::TCPClientSocket(addr, &log);
+ rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
EXPECT_EQ(net::OK, rv);
@@ -169,10 +170,9 @@ TEST_F(SSLClientSocketTest, ConnectMismatched) {
EXPECT_FALSE(sock->IsConnected());
- net::CapturingBoundNetLog log(net::CapturingNetLog::kUnbounded);
- rv = sock->Connect(&callback, log.bound());
+ rv = sock->Connect(&callback);
EXPECT_TRUE(net::LogContainsBeginEvent(
- log.entries(), 0, net::NetLog::TYPE_SSL_CONNECT));
+ log.entries(), 2, net::NetLog::TYPE_SSL_CONNECT));
if (rv != net::ERR_CERT_COMMON_NAME_INVALID) {
ASSERT_EQ(net::ERR_IO_PENDING, rv);
EXPECT_FALSE(sock->IsConnected());
@@ -209,8 +209,8 @@ TEST_F(SSLClientSocketTest, Read) {
rv = callback.WaitForResult();
EXPECT_EQ(net::OK, rv);
- net::ClientSocket *transport = new net::TCPClientSocket(addr);
- rv = transport->Connect(&callback, NULL);
+ net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL);
+ rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
EXPECT_EQ(net::OK, rv);
@@ -220,7 +220,7 @@ TEST_F(SSLClientSocketTest, Read) {
server_.kHostName,
kDefaultSSLConfig));
- rv = sock->Connect(&callback, NULL);
+ rv = sock->Connect(&callback);
if (rv != net::OK) {
ASSERT_EQ(net::ERR_IO_PENDING, rv);
@@ -271,8 +271,8 @@ TEST_F(SSLClientSocketTest, Read_FullDuplex) {
rv = callback.WaitForResult();
EXPECT_EQ(net::OK, rv);
- net::ClientSocket *transport = new net::TCPClientSocket(addr);
- rv = transport->Connect(&callback, NULL);
+ net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL);
+ rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
EXPECT_EQ(net::OK, rv);
@@ -282,7 +282,7 @@ TEST_F(SSLClientSocketTest, Read_FullDuplex) {
server_.kHostName,
kDefaultSSLConfig));
- rv = sock->Connect(&callback, NULL);
+ rv = sock->Connect(&callback);
if (rv != net::OK) {
ASSERT_EQ(net::ERR_IO_PENDING, rv);
@@ -330,8 +330,8 @@ TEST_F(SSLClientSocketTest, Read_SmallChunks) {
int rv = resolver_->Resolve(info, &addr, NULL, NULL, NULL);
EXPECT_EQ(net::OK, rv);
- net::ClientSocket *transport = new net::TCPClientSocket(addr);
- rv = transport->Connect(&callback, NULL);
+ net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL);
+ rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
EXPECT_EQ(net::OK, rv);
@@ -340,7 +340,7 @@ TEST_F(SSLClientSocketTest, Read_SmallChunks) {
socket_factory_->CreateSSLClientSocket(transport,
server_.kHostName, kDefaultSSLConfig));
- rv = sock->Connect(&callback, NULL);
+ rv = sock->Connect(&callback);
if (rv != net::OK) {
ASSERT_EQ(net::ERR_IO_PENDING, rv);
@@ -384,8 +384,8 @@ TEST_F(SSLClientSocketTest, Read_Interrupted) {
int rv = resolver_->Resolve(info, &addr, NULL, NULL, NULL);
EXPECT_EQ(net::OK, rv);
- net::ClientSocket *transport = new net::TCPClientSocket(addr);
- rv = transport->Connect(&callback, NULL);
+ net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL);
+ rv = transport->Connect(&callback);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
EXPECT_EQ(net::OK, rv);
@@ -394,7 +394,7 @@ TEST_F(SSLClientSocketTest, Read_Interrupted) {
socket_factory_->CreateSSLClientSocket(transport,
server_.kHostName, kDefaultSSLConfig));
- rv = sock->Connect(&callback, NULL);
+ rv = sock->Connect(&callback);
if (rv != net::OK) {
ASSERT_EQ(net::ERR_IO_PENDING, rv);
diff --git a/net/socket/ssl_client_socket_win.cc b/net/socket/ssl_client_socket_win.cc
index 6a4ed8f..1502a65 100644
--- a/net/socket/ssl_client_socket_win.cc
+++ b/net/socket/ssl_client_socket_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -322,7 +322,8 @@ SSLClientSocketWin::SSLClientSocketWin(ClientSocket* transport_socket,
writing_first_token_(false),
ignore_ok_result_(false),
renegotiating_(false),
- need_more_data_(false) {
+ need_more_data_(false),
+ net_log_(transport_socket->NetLog()) {
memset(&stream_sizes_, 0, sizeof(stream_sizes_));
memset(in_buffers_, 0, sizeof(in_buffers_));
memset(&send_buffer_, 0, sizeof(send_buffer_));
@@ -430,17 +431,16 @@ SSLClientSocketWin::GetNextProto(std::string* proto) {
return kNextProtoUnsupported;
}
-int SSLClientSocketWin::Connect(CompletionCallback* callback,
- const BoundNetLog& net_log) {
+int SSLClientSocketWin::Connect(CompletionCallback* callback) {
DCHECK(transport_.get());
DCHECK(next_state_ == STATE_NONE);
DCHECK(!user_connect_callback_);
- net_log.BeginEvent(NetLog::TYPE_SSL_CONNECT);
+ net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT);
int rv = InitializeSSLContext();
if (rv != OK) {
- net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
+ net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
return rv;
}
@@ -449,9 +449,8 @@ int SSLClientSocketWin::Connect(CompletionCallback* callback,
rv = DoLoop(OK);
if (rv == ERR_IO_PENDING) {
user_connect_callback_ = callback;
- net_log_ = net_log;
} else {
- net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
+ net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
}
return rv;
}
@@ -656,7 +655,6 @@ void SSLClientSocketWin::OnHandshakeIOComplete(int result) {
return;
}
net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
- net_log_ = BoundNetLog();
CompletionCallback* c = user_connect_callback_;
user_connect_callback_ = NULL;
c->Run(rv);
diff --git a/net/socket/ssl_client_socket_win.h b/net/socket/ssl_client_socket_win.h
index 40bc3c1..3a273fe0 100644
--- a/net/socket/ssl_client_socket_win.h
+++ b/net/socket/ssl_client_socket_win.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -43,11 +43,12 @@ class SSLClientSocketWin : public SSLClientSocket {
virtual NextProtoStatus GetNextProto(std::string* proto);
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
+ virtual int Connect(CompletionCallback* callback);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(AddressList* address) const;
+ virtual const BoundNetLog& NetLog() const { return net_log_; }
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc
index db00c55..b64523d 100644
--- a/net/socket/tcp_client_socket_libevent.cc
+++ b/net/socket/tcp_client_socket_libevent.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -122,7 +122,8 @@ bool ShouldTryNextAddress(int os_error) {
//-----------------------------------------------------------------------------
-TCPClientSocketLibevent::TCPClientSocketLibevent(const AddressList& addresses)
+TCPClientSocketLibevent::TCPClientSocketLibevent(const AddressList& addresses,
+ net::NetLog* net_log)
: socket_(kInvalidSocket),
addresses_(addresses),
current_ai_(addresses_.head()),
@@ -130,25 +131,25 @@ TCPClientSocketLibevent::TCPClientSocketLibevent(const AddressList& addresses)
read_watcher_(this),
write_watcher_(this),
read_callback_(NULL),
- write_callback_(NULL) {
+ write_callback_(NULL),
+ net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) {
}
TCPClientSocketLibevent::~TCPClientSocketLibevent() {
Disconnect();
+ net_log_.AddEvent(NetLog::TYPE_TCP_SOCKET_DONE);
}
-int TCPClientSocketLibevent::Connect(CompletionCallback* callback,
- const BoundNetLog& net_log) {
+int TCPClientSocketLibevent::Connect(CompletionCallback* callback) {
// If already connected, then just return OK.
if (socket_ != kInvalidSocket)
return OK;
DCHECK(!waiting_connect_);
- DCHECK(!net_log_.net_log());
TRACE_EVENT_BEGIN("socket.connect", this, "");
- net_log.BeginEvent(NetLog::TYPE_TCP_CONNECT);
+ net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT);
int rv = DoConnect();
@@ -156,12 +157,11 @@ int TCPClientSocketLibevent::Connect(CompletionCallback* callback,
// Synchronous operation not supported.
DCHECK(callback);
- net_log_ = net_log;
waiting_connect_ = true;
write_callback_ = callback;
} else {
TRACE_EVENT_END("socket.connect", this, "");
- net_log.EndEvent(NetLog::TYPE_TCP_CONNECT);
+ net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT);
}
return rv;
@@ -277,6 +277,7 @@ int TCPClientSocketLibevent::Read(IOBuffer* buf,
int nread = HANDLE_EINTR(read(socket_, buf->data(), buf_len));
if (nread >= 0) {
TRACE_EVENT_END("socket.read", this, StringPrintf("%d bytes", nread));
+ net_log_.AddEventWithInteger(NetLog::TYPE_SOCKET_BYTES_RECEIVED, nread);
return nread;
}
if (errno != EAGAIN && errno != EWOULDBLOCK) {
@@ -311,6 +312,7 @@ int TCPClientSocketLibevent::Write(IOBuffer* buf,
int nwrite = HANDLE_EINTR(write(socket_, buf->data(), buf_len));
if (nwrite >= 0) {
TRACE_EVENT_END("socket.write", this, StringPrintf("%d bytes", nwrite));
+ net_log_.AddEventWithInteger(NetLog::TYPE_SOCKET_BYTES_SENT, nwrite);
return nwrite;
}
if (errno != EAGAIN && errno != EWOULDBLOCK)
@@ -403,11 +405,9 @@ void TCPClientSocketLibevent::DidCompleteConnect() {
const addrinfo* next = current_ai_->ai_next;
Disconnect();
current_ai_ = next;
- BoundNetLog net_log = net_log_;
- net_log_ = BoundNetLog();
TRACE_EVENT_END("socket.connect", this, "");
- net_log.EndEvent(NetLog::TYPE_TCP_CONNECT);
- result = Connect(write_callback_, net_log);
+ net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT);
+ result = Connect(write_callback_);
} else {
result = MapConnectError(os_error);
bool ok = write_socket_watcher_.StopWatchingFileDescriptor();
@@ -415,7 +415,6 @@ void TCPClientSocketLibevent::DidCompleteConnect() {
waiting_connect_ = false;
TRACE_EVENT_END("socket.connect", this, "");
net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT);
- net_log_ = BoundNetLog();
}
if (result != ERR_IO_PENDING) {
@@ -433,6 +432,7 @@ void TCPClientSocketLibevent::DidCompleteRead() {
TRACE_EVENT_END("socket.read", this,
StringPrintf("%d bytes", bytes_transferred));
result = bytes_transferred;
+ net_log_.AddEventWithInteger(NetLog::TYPE_SOCKET_BYTES_RECEIVED, result);
} else {
result = MapPosixError(errno);
}
@@ -456,6 +456,7 @@ void TCPClientSocketLibevent::DidCompleteWrite() {
result = bytes_transferred;
TRACE_EVENT_END("socket.write", this,
StringPrintf("%d bytes", bytes_transferred));
+ net_log_.AddEventWithInteger(NetLog::TYPE_SOCKET_BYTES_SENT, result);
} else {
result = MapPosixError(errno);
}
diff --git a/net/socket/tcp_client_socket_libevent.h b/net/socket/tcp_client_socket_libevent.h
index 211149a..699ddc7 100644
--- a/net/socket/tcp_client_socket_libevent.h
+++ b/net/socket/tcp_client_socket_libevent.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -25,16 +25,18 @@ class TCPClientSocketLibevent : public ClientSocket {
// 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);
+ explicit TCPClientSocketLibevent(const AddressList& addresses,
+ net::NetLog* net_log);
virtual ~TCPClientSocketLibevent();
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
+ virtual int Connect(CompletionCallback* callback);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(AddressList* address) const;
+ virtual const BoundNetLog& NetLog() const { return net_log_; }
// Socket methods:
// Multiple outstanding requests are not supported.
diff --git a/net/socket/tcp_client_socket_pool.cc b/net/socket/tcp_client_socket_pool.cc
index a833e01..5cf1fa1 100644
--- a/net/socket/tcp_client_socket_pool.cc
+++ b/net/socket/tcp_client_socket_pool.cc
@@ -124,9 +124,10 @@ int TCPConnectJob::DoResolveHostComplete(int result) {
int TCPConnectJob::DoTCPConnect() {
next_state_ = kStateTCPConnectComplete;
- set_socket(client_socket_factory_->CreateTCPClientSocket(addresses_));
+ set_socket(client_socket_factory_->CreateTCPClientSocket(
+ addresses_, net_log().net_log()));
connect_start_time_ = base::TimeTicks::Now();
- return socket()->Connect(&callback_, net_log());
+ return socket()->Connect(&callback_);
}
int TCPConnectJob::DoTCPConnectComplete(int result) {
diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/tcp_client_socket_pool_unittest.cc
index e7c8a9f..aed9052 100644
--- a/net/socket/tcp_client_socket_pool_unittest.cc
+++ b/net/socket/tcp_client_socket_pool_unittest.cc
@@ -30,7 +30,7 @@ class MockClientSocket : public ClientSocket {
MockClientSocket() : connected_(false) {}
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, const BoundNetLog& /* net_log */) {
+ virtual int Connect(CompletionCallback* callback) {
connected_ = true;
return OK;
}
@@ -46,6 +46,9 @@ class MockClientSocket : public ClientSocket {
virtual int GetPeerAddress(AddressList* address) const {
return ERR_UNEXPECTED;
}
+ virtual const BoundNetLog& NetLog() const {
+ return net_log_;
+ }
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len,
@@ -61,6 +64,7 @@ class MockClientSocket : public ClientSocket {
private:
bool connected_;
+ BoundNetLog net_log_;
};
class MockFailingClientSocket : public ClientSocket {
@@ -68,7 +72,7 @@ class MockFailingClientSocket : public ClientSocket {
MockFailingClientSocket() {}
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, const BoundNetLog& /* net_log */) {
+ virtual int Connect(CompletionCallback* callback) {
return ERR_CONNECTION_FAILED;
}
@@ -83,6 +87,9 @@ class MockFailingClientSocket : public ClientSocket {
virtual int GetPeerAddress(AddressList* address) const {
return ERR_UNEXPECTED;
}
+ virtual const BoundNetLog& NetLog() const {
+ return net_log_;
+ }
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len,
@@ -96,6 +103,9 @@ class MockFailingClientSocket : public ClientSocket {
}
virtual bool SetReceiveBufferSize(int32 size) { return true; }
virtual bool SetSendBufferSize(int32 size) { return true; }
+
+ private:
+ BoundNetLog net_log_;
};
class MockPendingClientSocket : public ClientSocket {
@@ -112,7 +122,7 @@ class MockPendingClientSocket : public ClientSocket {
is_connected_(false) {}
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, const BoundNetLog& /* net_log */) {
+ virtual int Connect(CompletionCallback* callback) {
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
method_factory_.NewRunnableMethod(
@@ -131,6 +141,9 @@ class MockPendingClientSocket : public ClientSocket {
virtual int GetPeerAddress(AddressList* address) const{
return ERR_UNEXPECTED;
}
+ virtual const BoundNetLog& NetLog() const {
+ return net_log_;
+ }
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len,
@@ -164,6 +177,7 @@ class MockPendingClientSocket : public ClientSocket {
bool should_stall_;
int delay_ms_;
bool is_connected_;
+ BoundNetLog net_log_;
};
class MockClientSocketFactory : public ClientSocketFactory {
@@ -183,7 +197,8 @@ class MockClientSocketFactory : public ClientSocketFactory {
: allocation_count_(0), client_socket_type_(MOCK_CLIENT_SOCKET),
client_socket_types_(NULL), client_socket_index_(0) {}
- virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses) {
+ virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses,
+ NetLog* /* net_log */) {
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 01a0783..53ec97b 100644
--- a/net/socket/tcp_client_socket_unittest.cc
+++ b/net/socket/tcp_client_socket_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -26,7 +26,7 @@ const char kServerReply[] = "HTTP/1.1 404 Not Found";
class TCPClientSocketTest
: public PlatformTest, public ListenSocket::ListenSocketDelegate {
public:
- TCPClientSocketTest() {
+ TCPClientSocketTest() : net_log_(CapturingNetLog::kUnbounded) {
}
// Implement ListenSocketDelegate methods
@@ -59,6 +59,7 @@ class TCPClientSocketTest
protected:
int listen_port_;
+ CapturingNetLog net_log_;
scoped_ptr<TCPClientSocket> sock_;
private:
@@ -92,21 +93,20 @@ void TCPClientSocketTest::SetUp() {
HostResolver::RequestInfo info("localhost", listen_port_);
int rv = resolver->Resolve(info, &addr, NULL, NULL, NULL);
CHECK_EQ(rv, OK);
- sock_.reset(new TCPClientSocket(addr));
+ sock_.reset(new TCPClientSocket(addr, &net_log_));
}
TEST_F(TCPClientSocketTest, Connect) {
TestCompletionCallback callback;
EXPECT_FALSE(sock_->IsConnected());
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = sock_->Connect(&callback, log.bound());
+ int rv = sock_->Connect(&callback);
EXPECT_TRUE(net::LogContainsBeginEvent(
- log.entries(), 0, net::NetLog::TYPE_TCP_CONNECT));
+ net_log_.entries(), 0, net::NetLog::TYPE_TCP_CONNECT));
if (rv != OK) {
ASSERT_EQ(rv, ERR_IO_PENDING);
EXPECT_FALSE(net::LogContainsEndEvent(
- log.entries(), -1, net::NetLog::TYPE_TCP_CONNECT));
+ net_log_.entries(), -1, net::NetLog::TYPE_TCP_CONNECT));
rv = callback.WaitForResult();
EXPECT_EQ(rv, OK);
@@ -114,7 +114,7 @@ TEST_F(TCPClientSocketTest, Connect) {
EXPECT_TRUE(sock_->IsConnected());
EXPECT_TRUE(net::LogContainsEndEvent(
- log.entries(), -1, net::NetLog::TYPE_TCP_CONNECT));
+ net_log_.entries(), -1, net::NetLog::TYPE_TCP_CONNECT));
sock_->Disconnect();
EXPECT_FALSE(sock_->IsConnected());
@@ -126,7 +126,7 @@ TEST_F(TCPClientSocketTest, Connect) {
TEST_F(TCPClientSocketTest, Read) {
TestCompletionCallback callback;
- int rv = sock_->Connect(&callback, NULL);
+ int rv = sock_->Connect(&callback);
if (rv != OK) {
ASSERT_EQ(rv, ERR_IO_PENDING);
@@ -171,7 +171,7 @@ TEST_F(TCPClientSocketTest, Read) {
TEST_F(TCPClientSocketTest, Read_SmallChunks) {
TestCompletionCallback callback;
- int rv = sock_->Connect(&callback, NULL);
+ int rv = sock_->Connect(&callback);
if (rv != OK) {
ASSERT_EQ(rv, ERR_IO_PENDING);
@@ -216,7 +216,7 @@ TEST_F(TCPClientSocketTest, Read_SmallChunks) {
TEST_F(TCPClientSocketTest, Read_Interrupted) {
TestCompletionCallback callback;
- int rv = sock_->Connect(&callback, NULL);
+ int rv = sock_->Connect(&callback);
if (rv != OK) {
ASSERT_EQ(ERR_IO_PENDING, rv);
@@ -250,7 +250,7 @@ TEST_F(TCPClientSocketTest, Read_Interrupted) {
TEST_F(TCPClientSocketTest, DISABLED_FullDuplex_ReadFirst) {
TestCompletionCallback callback;
- int rv = sock_->Connect(&callback, NULL);
+ int rv = sock_->Connect(&callback);
if (rv != OK) {
ASSERT_EQ(rv, ERR_IO_PENDING);
@@ -292,7 +292,7 @@ TEST_F(TCPClientSocketTest, DISABLED_FullDuplex_ReadFirst) {
TEST_F(TCPClientSocketTest, DISABLED_FullDuplex_WriteFirst) {
TestCompletionCallback callback;
- int rv = sock_->Connect(&callback, NULL);
+ int rv = sock_->Connect(&callback);
if (rv != OK) {
ASSERT_EQ(ERR_IO_PENDING, rv);
diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc
index 8d8cdd4..24c3eca 100644
--- a/net/socket/tcp_client_socket_win.cc
+++ b/net/socket/tcp_client_socket_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -272,7 +272,8 @@ void TCPClientSocketWin::Core::WriteDelegate::OnObjectSignaled(
//-----------------------------------------------------------------------------
-TCPClientSocketWin::TCPClientSocketWin(const AddressList& addresses)
+TCPClientSocketWin::TCPClientSocketWin(const AddressList& addresses,
+ net::NetLog* net_log)
: socket_(INVALID_SOCKET),
addresses_(addresses),
current_ai_(addresses_.head()),
@@ -280,28 +281,27 @@ TCPClientSocketWin::TCPClientSocketWin(const AddressList& addresses)
waiting_read_(false),
waiting_write_(false),
read_callback_(NULL),
- write_callback_(NULL) {
+ write_callback_(NULL),
+ net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) {
EnsureWinsockInit();
}
TCPClientSocketWin::~TCPClientSocketWin() {
Disconnect();
+ net_log_.AddEvent(NetLog::TYPE_TCP_SOCKET_DONE);
}
-int TCPClientSocketWin::Connect(CompletionCallback* callback,
- const BoundNetLog& net_log) {
+int TCPClientSocketWin::Connect(CompletionCallback* callback) {
// If already connected, then just return OK.
if (socket_ != INVALID_SOCKET)
return OK;
- DCHECK(!net_log_.net_log());
-
static StatsCounter connects("tcp.connect");
connects.Increment();
TRACE_EVENT_BEGIN("socket.connect", this, "");
- net_log.BeginEvent(NetLog::TYPE_TCP_CONNECT);
+ net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT);
int rv = DoConnect();
@@ -309,12 +309,11 @@ int TCPClientSocketWin::Connect(CompletionCallback* callback,
// Synchronous operation not supported.
DCHECK(callback);
- net_log_ = net_log;
waiting_connect_ = true;
read_callback_ = callback;
} else {
TRACE_EVENT_END("socket.connect", this, "");
- net_log.EndEvent(NetLog::TYPE_TCP_CONNECT);
+ net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT);
if (rv == OK)
UpdateConnectionTypeHistograms(CONNECTION_ANY);
}
@@ -478,6 +477,7 @@ int TCPClientSocketWin::Read(IOBuffer* buf,
base::MemoryDebug::MarkAsInitialized(core_->read_buffer_.buf, num);
static StatsCounter read_bytes("tcp.read_bytes");
read_bytes.Add(num);
+ net_log_.AddEventWithInteger(NetLog::TYPE_SOCKET_BYTES_RECEIVED, num);
return static_cast<int>(num);
}
} else {
@@ -528,6 +528,7 @@ int TCPClientSocketWin::Write(IOBuffer* buf,
TRACE_EVENT_END("socket.write", this, StringPrintf("%d bytes", rv));
static StatsCounter write_bytes("tcp.write_bytes");
write_bytes.Add(rv);
+ net_log_.AddEventWithInteger(NetLog::TYPE_SOCKET_BYTES_SENT, rv);
return rv;
}
} else {
@@ -659,23 +660,19 @@ void TCPClientSocketWin::DidCompleteConnect() {
const struct addrinfo* next = current_ai_->ai_next;
Disconnect();
current_ai_ = next;
- BoundNetLog net_log(net_log_);
- net_log_ = BoundNetLog();
TRACE_EVENT_END("socket.connect", this, "");
- net_log.EndEvent(NetLog::TYPE_TCP_CONNECT);
- result = Connect(read_callback_, net_log);
+ net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT);
+ result = Connect(read_callback_);
} else {
result = MapConnectError(os_error);
TRACE_EVENT_END("socket.connect", this, "");
net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT);
- net_log_ = BoundNetLog();
}
} else {
NOTREACHED();
result = ERR_UNEXPECTED;
TRACE_EVENT_END("socket.connect", this, "");
net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT);
- net_log_ = BoundNetLog();
}
if (result != ERR_IO_PENDING) {
@@ -694,6 +691,8 @@ void TCPClientSocketWin::DidCompleteRead() {
TRACE_EVENT_END("socket.read", this, StringPrintf("%d bytes", num_bytes));
waiting_read_ = false;
core_->read_iobuffer_ = NULL;
+ if (ok)
+ net_log_.AddEventWithInteger(NetLog::TYPE_SOCKET_BYTES_RECEIVED, num_bytes);
DoReadCallback(ok ? num_bytes : MapWinsockError(WSAGetLastError()));
}
@@ -718,6 +717,8 @@ void TCPClientSocketWin::DidCompleteWrite() {
<< core_->write_buffer_length_ << " bytes, but " << rv
<< " bytes reported.";
rv = ERR_WINSOCK_UNEXPECTED_WRITTEN_BYTES;
+ } else {
+ net_log_.AddEventWithInteger(NetLog::TYPE_SOCKET_BYTES_SENT, rv);
}
}
core_->write_iobuffer_ = NULL;
diff --git a/net/socket/tcp_client_socket_win.h b/net/socket/tcp_client_socket_win.h
index 128b72e..7e4eb8f 100644
--- a/net/socket/tcp_client_socket_win.h
+++ b/net/socket/tcp_client_socket_win.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -22,16 +22,17 @@ class TCPClientSocketWin : public ClientSocket {
// 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 TCPClientSocketWin(const AddressList& addresses);
+ TCPClientSocketWin(const AddressList& addresses, net::NetLog* net_log);
~TCPClientSocketWin();
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
+ virtual int Connect(CompletionCallback* callback);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
virtual int GetPeerAddress(AddressList* address) const;
+ virtual const BoundNetLog& NetLog() const { return net_log_; }
// Socket methods:
// Multiple outstanding requests are not supported.
diff --git a/net/socket/tcp_pinger.h b/net/socket/tcp_pinger.h
index 94fdeea..f557e25 100644
--- a/net/socket/tcp_pinger.h
+++ b/net/socket/tcp_pinger.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -86,8 +86,8 @@ class TCPPinger {
}
void DoConnect() {
- sock_.reset(new TCPClientSocket(addr_));
- int rv = sock_->Connect(&connect_callback_, NULL);
+ sock_.reset(new TCPClientSocket(addr_, NULL));
+ int rv = sock_->Connect(&connect_callback_);
// Regardless of success or failure, if we're done now,
// signal the customer.
if (rv != ERR_IO_PENDING)