summaryrefslogtreecommitdiffstats
path: root/net/socket/socks_client_socket_unittest.cc
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-23 16:44:02 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-23 16:44:02 +0000
commita2006ecefa10d259d0a85ac4146b913eb0f9d02f (patch)
tree67fc5e5f6339f2fa5e53735a30324e47de22005a /net/socket/socks_client_socket_unittest.cc
parentf044ce8e4aeef63eb7686345f407bf5640045c18 (diff)
downloadchromium_src-a2006ecefa10d259d0a85ac4146b913eb0f9d02f.zip
chromium_src-a2006ecefa10d259d0a85ac4146b913eb0f9d02f.tar.gz
chromium_src-a2006ecefa10d259d0a85ac4146b913eb0f9d02f.tar.bz2
Add net log entries that summarize transmit and receive byte counts.
Tx/Rx summaries are integrated into the net log at the last point that bytes were transmitted or received. Hopefully this will help resolve http://crbug.com/37729 by showing if we've received bytes over the network when we hit the "Waiting for cache" bug. This change also modernizes the use of NetLog: - ClientSocket now has a net_log() accessor - ClientSocket::Connect no longer takes a NetLog, instead the TCPClientSocket constructor takes one, others use their transport socket's NetLog - TCPClientSocket creates a new source id with source type SOCKET Also updates PassiveLogCollector infrastructure: - The LiveRequestsObserver lets a RequestTracker update a RequestInfo just before it is displayed. This allows ConnectJobs to be associated with URLRequests while connecting and then reassociated if they are late-bound to a different request. BUG=37729 TEST=tx/rx lines show up in chrome://net-internals/ Review URL: http://codereview.chromium.org/1696005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45449 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/socks_client_socket_unittest.cc')
-rw-r--r--net/socket/socks_client_socket_unittest.cc60
1 files changed, 30 insertions, 30 deletions
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());