summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 18:19:36 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 18:19:36 +0000
commit635909faccd2bcabd0999e086a2d10c5b34d8062 (patch)
treebfd0c804d4e9df92bc4e2dbe30c95e2cd5908f57 /net
parentcefc3bf5b4cc3bd7db35d3e274173cf1563a9372 (diff)
downloadchromium_src-635909faccd2bcabd0999e086a2d10c5b34d8062.zip
chromium_src-635909faccd2bcabd0999e086a2d10c5b34d8062.tar.gz
chromium_src-635909faccd2bcabd0999e086a2d10c5b34d8062.tar.bz2
Plumb NetLog into SpdySession.
TODO(willchan): Start logging events for SpdySession. Review URL: http://codereview.chromium.org/2059004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47047 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/http/http_network_transaction.cc7
-rw-r--r--net/http/http_network_transaction_unittest.cc5
-rw-r--r--net/spdy/spdy_network_transaction.cc8
-rw-r--r--net/spdy/spdy_session.cc20
-rw-r--r--net/spdy/spdy_session.h14
-rw-r--r--net/spdy/spdy_session_pool.cc10
-rw-r--r--net/spdy/spdy_session_pool.h7
-rw-r--r--net/spdy/spdy_session_unittest.cc13
-rw-r--r--net/spdy/spdy_stream_unittest.cc3
9 files changed, 50 insertions, 37 deletions
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 90763a0..2381450 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -1359,14 +1359,14 @@ int HttpNetworkTransaction::DoSpdySendRequest() {
scoped_refptr<SpdySession> spdy_session;
if (spdy_pool->HasSession(endpoint_)) {
- spdy_session = spdy_pool->Get(endpoint_, session_);
+ spdy_session = spdy_pool->Get(endpoint_, session_, net_log_);
} else {
// SPDY is negotiated using the TLS next protocol negotiation (NPN)
// extension, so |connection_| must contain an SSLClientSocket.
DCHECK(using_ssl_);
CHECK(connection_->socket());
spdy_session = spdy_pool->GetSpdySessionFromSSLSocket(
- endpoint_, session_, connection_.release());
+ endpoint_, session_, connection_.release(), net_log_);
}
CHECK(spdy_session.get());
@@ -1379,8 +1379,7 @@ int HttpNetworkTransaction::DoSpdySendRequest() {
return error_code;
}
headers_valid_ = false;
- spdy_stream_ = spdy_session->GetOrCreateStream(
- *request_, upload_data, net_log_);
+ spdy_stream_ = spdy_session->GetOrCreateStream(*request_, upload_data);
return spdy_stream_->SendRequest(upload_data, &response_, &io_callback_);
}
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 8464442..eac14e2 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -5216,10 +5216,9 @@ TEST_F(HttpNetworkTransactionTest,
// Set up an initial SpdySession in the pool to reuse.
scoped_refptr<SpdySession> spdy_session =
session->spdy_session_pool()->Get(HostPortPair("www.google.com", 443),
- session);
+ session, BoundNetLog());
TCPSocketParams tcp_params("www.google.com", 443, MEDIUM, GURL(), false);
- spdy_session->Connect(
- "www.google.com:443", tcp_params, MEDIUM, BoundNetLog());
+ spdy_session->Connect("www.google.com:443", tcp_params, MEDIUM);
trans.reset(new HttpNetworkTransaction(session));
diff --git a/net/spdy/spdy_network_transaction.cc b/net/spdy/spdy_network_transaction.cc
index b0f35af..3ad1702 100644
--- a/net/spdy/spdy_network_transaction.cc
+++ b/net/spdy/spdy_network_transaction.cc
@@ -12,6 +12,7 @@
#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/base/net_util.h"
#include "net/base/upload_data_stream.h"
#include "net/http/http_network_session.h"
@@ -229,11 +230,12 @@ int SpdyNetworkTransaction::DoInitConnection() {
TCPSocketParams tcp_params(host_port_pair, request_->priority,
request_->referrer, false);
- spdy_ = session_->spdy_session_pool()->Get(host_port_pair, session_);
+ spdy_ = session_->spdy_session_pool()->Get(
+ host_port_pair, session_, net_log_);
DCHECK(spdy_);
return spdy_->Connect(
- connection_group, tcp_params, request_->priority, net_log_);
+ connection_group, tcp_params, request_->priority);
}
int SpdyNetworkTransaction::DoInitConnectionComplete(int result) {
@@ -254,7 +256,7 @@ int SpdyNetworkTransaction::DoSendRequest() {
if (!upload_data)
return error_code;
}
- stream_ = spdy_->GetOrCreateStream(*request_, upload_data, net_log_);
+ stream_ = spdy_->GetOrCreateStream(*request_, upload_data);
// Release the reference to |spdy_| since we don't need it anymore.
spdy_ = NULL;
return stream_->SendRequest(upload_data, &response_, &io_callback_);
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 902ef79..d80d874 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -187,7 +187,8 @@ void AdjustSocketBufferSizes(ClientSocket* socket) {
bool SpdySession::use_ssl_ = true;
SpdySession::SpdySession(const HostPortPair& host_port_pair,
- HttpNetworkSession* session)
+ HttpNetworkSession* session,
+ const BoundNetLog& net_log)
: ALLOW_THIS_IN_INITIALIZER_LIST(
connect_callback_(this, &SpdySession::OnTCPConnect)),
ALLOW_THIS_IN_INITIALIZER_LIST(
@@ -211,7 +212,8 @@ SpdySession::SpdySession(const HostPortPair& host_port_pair,
streams_pushed_count_(0),
streams_pushed_and_claimed_count_(0),
streams_abandoned_count_(0),
- in_session_pool_(true) {
+ in_session_pool_(true),
+ net_log_(net_log) {
// TODO(mbelshe): consider randomization of the stream_hi_water_mark.
spdy_framer_.set_visitor(this);
@@ -263,8 +265,7 @@ void SpdySession::InitializeWithSSLSocket(ClientSocketHandle* connection) {
net::Error SpdySession::Connect(const std::string& group_name,
const TCPSocketParams& destination,
- RequestPriority priority,
- const BoundNetLog& net_log) {
+ RequestPriority priority) {
DCHECK(priority >= SPDY_PRIORITY_HIGHEST && priority <= SPDY_PRIORITY_LOWEST);
// If the connect process is started, let the caller continue.
@@ -278,7 +279,7 @@ net::Error SpdySession::Connect(const std::string& group_name,
int rv = connection_->Init(group_name, destination, priority,
&connect_callback_, session_->tcp_socket_pool(),
- net_log);
+ net_log_);
DCHECK(rv <= 0);
// If the connect is pending, we still return ok. The APIs enqueue
@@ -291,8 +292,7 @@ net::Error SpdySession::Connect(const std::string& group_name,
scoped_refptr<SpdyStream> SpdySession::GetOrCreateStream(
const HttpRequestInfo& request,
- const UploadDataStream* upload_data,
- const BoundNetLog& log) {
+ const UploadDataStream* upload_data) {
const GURL& url = request.url;
const std::string& path = url.PathForRequest();
@@ -331,8 +331,8 @@ scoped_refptr<SpdyStream> SpdySession::GetOrCreateStream(
DCHECK(!it->second);
// Server will assign a stream id when the push stream arrives. Use 0 for
// now.
- log.AddEvent(NetLog::TYPE_SPDY_STREAM_ADOPTED_PUSH_STREAM, NULL);
- SpdyStream* stream = new SpdyStream(this, 0, true, log);
+ net_log_.AddEvent(NetLog::TYPE_SPDY_STREAM_ADOPTED_PUSH_STREAM, NULL);
+ SpdyStream* stream = new SpdyStream(this, 0, true, net_log_);
stream->SetRequestInfo(request);
stream->set_path(path);
it->second = stream;
@@ -342,7 +342,7 @@ scoped_refptr<SpdyStream> SpdySession::GetOrCreateStream(
const spdy::SpdyStreamId stream_id = GetNewStreamId();
// If we still don't have a stream, activate one now.
- stream = new SpdyStream(this, stream_id, false, log);
+ stream = new SpdyStream(this, stream_id, false, net_log_);
stream->SetRequestInfo(request);
stream->set_priority(request.priority);
stream->set_path(path);
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h
index cff7b82..5382867 100644
--- a/net/spdy/spdy_session.h
+++ b/net/spdy/spdy_session.h
@@ -15,6 +15,7 @@
#include "net/base/io_buffer.h"
#include "net/base/load_states.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/base/request_priority.h"
#include "net/base/ssl_config_service.h"
#include "net/base/upload_data_stream.h"
@@ -41,8 +42,10 @@ class SpdySession : public base::RefCounted<SpdySession>,
public:
// Create a new SpdySession.
// |host_port_pair| is the host/port that this session connects to.
- // |session| is the HttpNetworkSession
- SpdySession(const HostPortPair& host_port_pair, HttpNetworkSession* session);
+ // |session| is the HttpNetworkSession. |net_log| is the NetLog that we log
+ // network events to.
+ SpdySession(const HostPortPair& host_port_pair, HttpNetworkSession* session,
+ const BoundNetLog& net_log);
const HostPortPair& host_port_pair() const { return host_port_pair_; }
@@ -52,8 +55,7 @@ class SpdySession : public base::RefCounted<SpdySession>,
// immediately start using the SpdySession while it connects.
net::Error Connect(const std::string& group_name,
const TCPSocketParams& destination,
- RequestPriority priority,
- const BoundNetLog& net_log);
+ RequestPriority priority);
// Get a stream for a given |request|. In the typical case, this will involve
// the creation of a new stream (and will send the SYN frame). If the server
@@ -62,7 +64,7 @@ class SpdySession : public base::RefCounted<SpdySession>,
// X-Associated-Content.
// Returns the new or existing stream. Never returns NULL.
scoped_refptr<SpdyStream> GetOrCreateStream(const HttpRequestInfo& request,
- const UploadDataStream* upload_data, const BoundNetLog& log);
+ const UploadDataStream* upload_data);
// Used by SpdySessionPool to initialize with a pre-existing SSL socket.
void InitializeWithSSLSocket(ClientSocketHandle* connection);
@@ -247,6 +249,8 @@ class SpdySession : public base::RefCounted<SpdySession>,
bool in_session_pool_; // True if the session is currently in the pool.
+ BoundNetLog net_log_;
+
static bool use_ssl_;
};
diff --git a/net/spdy/spdy_session_pool.cc b/net/spdy/spdy_session_pool.cc
index 15028f9..af397c7 100644
--- a/net/spdy/spdy_session_pool.cc
+++ b/net/spdy/spdy_session_pool.cc
@@ -20,7 +20,8 @@ SpdySessionPool::~SpdySessionPool() {
}
scoped_refptr<SpdySession> SpdySessionPool::Get(
- const HostPortPair& host_port_pair, HttpNetworkSession* session) {
+ const HostPortPair& host_port_pair, HttpNetworkSession* session,
+ const BoundNetLog& net_log) {
scoped_refptr<SpdySession> spdy_session;
SpdySessionList* list = GetSessionList(host_port_pair);
if (list) {
@@ -34,7 +35,7 @@ scoped_refptr<SpdySession> SpdySessionPool::Get(
DCHECK(list);
if (!spdy_session)
- spdy_session = new SpdySession(host_port_pair, session);
+ spdy_session = new SpdySession(host_port_pair, session, net_log);
DCHECK(spdy_session);
list->push_back(spdy_session);
@@ -45,13 +46,14 @@ scoped_refptr<SpdySession> SpdySessionPool::Get(
scoped_refptr<SpdySession> SpdySessionPool::GetSpdySessionFromSSLSocket(
const HostPortPair& host_port_pair,
HttpNetworkSession* session,
- ClientSocketHandle* connection) {
+ ClientSocketHandle* connection,
+ const BoundNetLog& net_log) {
SpdySessionList* list = GetSessionList(host_port_pair);
if (!list)
list = AddSessionList(host_port_pair);
DCHECK(list->empty());
scoped_refptr<SpdySession> spdy_session(
- new SpdySession(host_port_pair, session));
+ new SpdySession(host_port_pair, session, net_log));
spdy_session->InitializeWithSSLSocket(connection);
list->push_back(spdy_session);
return spdy_session;
diff --git a/net/spdy/spdy_session_pool.h b/net/spdy/spdy_session_pool.h
index 3a77bc0..d7569ba 100644
--- a/net/spdy/spdy_session_pool.h
+++ b/net/spdy/spdy_session_pool.h
@@ -18,6 +18,7 @@ namespace net {
class ClientSocketHandle;
class HttpNetworkSession;
+class BoundNetLog;
class SpdySession;
// This is a very simple pool for open SpdySessions.
@@ -29,7 +30,8 @@ class SpdySessionPool : public base::RefCounted<SpdySessionPool> {
// Either returns an existing SpdySession or creates a new SpdySession for
// use.
scoped_refptr<SpdySession> Get(
- const HostPortPair& host_port_pair, HttpNetworkSession* session);
+ const HostPortPair& host_port_pair, HttpNetworkSession* session,
+ const BoundNetLog& net_log);
// Set the maximum concurrent sessions per domain.
static void set_max_sessions_per_domain(int max) {
@@ -44,7 +46,8 @@ class SpdySessionPool : public base::RefCounted<SpdySessionPool> {
scoped_refptr<SpdySession> GetSpdySessionFromSSLSocket(
const HostPortPair& host_port_pair,
HttpNetworkSession* session,
- ClientSocketHandle* connection);
+ ClientSocketHandle* connection,
+ const BoundNetLog& net_log);
// TODO(willchan): Consider renaming to HasReusableSession, since perhaps we
// should be creating a new session.
diff --git a/net/spdy/spdy_session_unittest.cc b/net/spdy/spdy_session_unittest.cc
index 980311a..ab7b12c 100644
--- a/net/spdy/spdy_session_unittest.cc
+++ b/net/spdy/spdy_session_unittest.cc
@@ -130,11 +130,12 @@ TEST_F(SpdySessionTest, GoAway) {
http_session->spdy_session_pool());
EXPECT_FALSE(spdy_session_pool->HasSession(test_host_port_pair));
scoped_refptr<SpdySession> session =
- spdy_session_pool->Get(test_host_port_pair, http_session.get());
+ spdy_session_pool->Get(
+ test_host_port_pair, http_session.get(), BoundNetLog());
EXPECT_TRUE(spdy_session_pool->HasSession(test_host_port_pair));
TCPSocketParams tcp_params(kTestHost, kTestPort, MEDIUM, GURL(), false);
- int rv = session->Connect(kTestHost, tcp_params, MEDIUM, BoundNetLog());
+ int rv = session->Connect(kTestHost, tcp_params, MEDIUM);
ASSERT_EQ(OK, rv);
// Flush the SpdySession::OnReadComplete() task.
@@ -143,7 +144,8 @@ TEST_F(SpdySessionTest, GoAway) {
EXPECT_FALSE(spdy_session_pool->HasSession(test_host_port_pair));
scoped_refptr<SpdySession> session2 =
- spdy_session_pool->Get(test_host_port_pair, http_session.get());
+ spdy_session_pool->Get(
+ test_host_port_pair, http_session.get(), BoundNetLog());
// Delete the first session.
session = NULL;
@@ -203,7 +205,8 @@ TEST_F(SpdySessionTest, GetPushStream) {
http_session->spdy_session_pool());
EXPECT_FALSE(spdy_session_pool->HasSession(test_host_port_pair));
scoped_refptr<SpdySession> session =
- spdy_session_pool->Get(test_host_port_pair, http_session.get());
+ spdy_session_pool->Get(
+ test_host_port_pair, http_session.get(), BoundNetLog());
EXPECT_TRUE(spdy_session_pool->HasSession(test_host_port_pair));
// No push streams should exist in the beginning.
@@ -214,7 +217,7 @@ TEST_F(SpdySessionTest, GetPushStream) {
// Read in the data which contains a server-issued SYN_STREAM.
TCPSocketParams tcp_params(test_host_port_pair, MEDIUM, GURL(), false);
- int rv = session->Connect(kTestHost, tcp_params, MEDIUM, BoundNetLog());
+ int rv = session->Connect(kTestHost, tcp_params, MEDIUM);
ASSERT_EQ(OK, rv);
MessageLoop::current()->RunAllPending();
diff --git a/net/spdy/spdy_stream_unittest.cc b/net/spdy/spdy_stream_unittest.cc
index 7a0d9b3..64f3a8b 100644
--- a/net/spdy/spdy_stream_unittest.cc
+++ b/net/spdy/spdy_stream_unittest.cc
@@ -90,7 +90,8 @@ class SpdyStreamTest : public testing::Test {
scoped_refptr<SpdySession> CreateSpdySession() {
HostPortPair host_port_pair("www.google.com", 80);
scoped_refptr<SpdySession> session(
- session_->spdy_session_pool()->Get(host_port_pair, session_));
+ session_->spdy_session_pool()->Get(
+ host_port_pair, session_, BoundNetLog()));
return session;
}