summaryrefslogtreecommitdiffstats
path: root/net/spdy
diff options
context:
space:
mode:
authorrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-25 21:09:38 +0000
committerrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-25 21:09:38 +0000
commit02b0c3408a241a812a46b20c1cc361cba5d2bf9b (patch)
treeccafc9271ba932fd8596326172755b75f08108fb /net/spdy
parent76aece4cb1cd2983e4653a0a5afc95bc8496adf5 (diff)
downloadchromium_src-02b0c3408a241a812a46b20c1cc361cba5d2bf9b.zip
chromium_src-02b0c3408a241a812a46b20c1cc361cba5d2bf9b.tar.gz
chromium_src-02b0c3408a241a812a46b20c1cc361cba5d2bf9b.tar.bz2
Remove SpdySession::Connect(). This methods was only
being called from a handful of unit tests. I modified those tests to call SpdySession::InitializeWithSocket() instead. This added a bit of code to these tests. BUG=56848 TEST=none Review URL: http://codereview.chromium.org/3435029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60589 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy')
-rw-r--r--net/spdy/spdy_http_stream_unittest.cc9
-rw-r--r--net/spdy/spdy_session.cc97
-rw-r--r--net/spdy/spdy_session.h14
-rw-r--r--net/spdy/spdy_session_unittest.cc8
-rw-r--r--net/spdy/spdy_stream_unittest.cc8
5 files changed, 20 insertions, 116 deletions
diff --git a/net/spdy/spdy_http_stream_unittest.cc b/net/spdy/spdy_http_stream_unittest.cc
index fbc2a8b..c3a6fdc 100644
--- a/net/spdy/spdy_http_stream_unittest.cc
+++ b/net/spdy/spdy_http_stream_unittest.cc
@@ -34,7 +34,14 @@ class SpdyHttpStreamTest : public testing::Test {
tcp_params_ = new TCPSocketParams(host_port_pair.host(),
host_port_pair.port(),
MEDIUM, GURL(), false);
- return session_->Connect(host_port_pair.host(), tcp_params_, MEDIUM);
+ TestCompletionCallback callback;
+ scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
+ EXPECT_EQ(ERR_IO_PENDING,
+ connection->Init(host_port_pair.ToString(), tcp_params_, MEDIUM,
+ &callback, http_session_->tcp_socket_pool(),
+ BoundNetLog()));
+ EXPECT_EQ(OK, callback.WaitForResult());
+ return session_->InitializeWithSocket(connection.release(), false, OK);
}
SpdySessionDependencies session_deps_;
scoped_refptr<OrderedSocketData> data_;
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 0f72b6e..304562b 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -17,13 +17,9 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "net/base/connection_type_histograms.h"
-#include "net/base/load_flags.h"
#include "net/base/net_log.h"
#include "net/base/net_util.h"
#include "net/http/http_network_session.h"
-#include "net/socket/client_socket.h"
-#include "net/socket/client_socket_factory.h"
-#include "net/socket/ssl_client_socket.h"
#include "net/spdy/spdy_frame_builder.h"
#include "net/spdy/spdy_protocol.h"
#include "net/spdy/spdy_settings_storage.h"
@@ -223,10 +219,6 @@ SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair,
HttpNetworkSession* session,
NetLog* net_log)
: ALLOW_THIS_IN_INITIALIZER_LIST(
- connect_callback_(this, &SpdySession::OnTCPConnect)),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- ssl_connect_callback_(this, &SpdySession::OnSSLConnect)),
- ALLOW_THIS_IN_INITIALIZER_LIST(
read_callback_(this, &SpdySession::OnReadComplete)),
ALLOW_THIS_IN_INITIALIZER_LIST(
write_callback_(this, &SpdySession::OnWriteComplete)),
@@ -262,8 +254,6 @@ SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair,
spdy_framer_.set_visitor(this);
- session_->ssl_config_service()->GetSSLConfig(&ssl_config_);
-
SendSettings();
}
@@ -310,34 +300,6 @@ net::Error SpdySession::InitializeWithSocket(
return error;
}
-net::Error SpdySession::Connect(
- const std::string& group_name,
- const scoped_refptr<TCPSocketParams>& destination,
- RequestPriority priority) {
- DCHECK(priority >= net::HIGHEST && priority < net::NUM_PRIORITIES);
-
- // If the connect process is started, let the caller continue.
- if (state_ > IDLE)
- return net::OK;
-
- state_ = CONNECTING;
-
- static StatsCounter spdy_sessions("spdy.sessions");
- spdy_sessions.Increment();
-
- int rv = connection_->Init(group_name, destination, priority,
- &connect_callback_, session_->tcp_socket_pool(),
- net_log_);
- DCHECK(rv <= 0);
-
- // If the connect is pending, we still return ok. The APIs enqueue
- // work until after the connect completes asynchronously later.
- if (rv == net::ERR_IO_PENDING)
- return net::OK;
- OnTCPConnect(rv);
- return static_cast<net::Error>(rv);
-}
-
int SpdySession::GetPushStream(
const GURL& url,
scoped_refptr<SpdyStream>* stream,
@@ -591,65 +553,6 @@ LoadState SpdySession::GetLoadState() const {
return LOAD_STATE_IDLE;
}
-void SpdySession::OnTCPConnect(int result) {
- // We shouldn't be coming through this path if we didn't just open a fresh
- // socket (or have an error trying to do so).
- DCHECK(!connection_->socket() || !connection_->is_reused());
-
- if (result != net::OK) {
- DCHECK_LT(result, 0);
- CloseSessionOnError(static_cast<net::Error>(result), true);
- return;
- } else {
- UpdateConnectionTypeHistograms(CONNECTION_SPDY);
- }
-
- AdjustSocketBufferSizes(connection_->socket());
-
- if (use_ssl_) {
- // Add a SSL socket on top of our existing transport socket.
- ClientSocket* socket = connection_->release_socket();
- // TODO(mbelshe): Fix the hostname. This is BROKEN without having
- // a real hostname.
- socket = session_->socket_factory()->CreateSSLClientSocket(
- socket, "" /* request_->url.HostNoBrackets() */ , ssl_config_);
- connection_->set_socket(socket);
- is_secure_ = true;
- int status = connection_->socket()->Connect(&ssl_connect_callback_);
- if (status != ERR_IO_PENDING)
- OnSSLConnect(status);
- } else {
- DCHECK_EQ(state_, CONNECTING);
- state_ = CONNECTED;
-
- // Make sure we get any pending data sent.
- WriteSocketLater();
- // Start reading
- ReadSocket();
- }
-}
-
-void SpdySession::OnSSLConnect(int result) {
- // TODO(mbelshe): We need to replicate the functionality of
- // HttpNetworkTransaction::DoSSLConnectComplete here, where it calls
- // HandleCertificateError() and such.
- if (IsCertificateError(result))
- result = OK; // TODO(mbelshe): pretend we're happy anyway.
-
- if (result == OK) {
- DCHECK_EQ(state_, CONNECTING);
- state_ = CONNECTED;
-
- // After we've connected, send any data to the server, and then issue
- // our read.
- WriteSocketLater();
- ReadSocket();
- } else {
- DCHECK_LT(result, 0); // It should be an error, not a byte count.
- CloseSessionOnError(static_cast<net::Error>(result), true);
- }
-}
-
void SpdySession::OnReadComplete(int bytes_read) {
// Parse a frame. For now this code requires that the frame fit into our
// buffer (32KB).
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h
index 76f105c..e98a478 100644
--- a/net/spdy/spdy_session.h
+++ b/net/spdy/spdy_session.h
@@ -63,14 +63,6 @@ class SpdySession : public base::RefCounted<SpdySession>,
return host_port_proxy_pair_;
}
- // Connect the Spdy Socket.
- // Returns net::Error::OK on success.
- // Note that this call does not wait for the connect to complete. Callers can
- // immediately start using the SpdySession while it connects.
- net::Error Connect(const std::string& group_name,
- const scoped_refptr<TCPSocketParams>& destination,
- RequestPriority priority);
-
// Get a pushed stream for a given |url|.
// If the server initiates a stream, it might already exist for a given path.
// The server might also not have initiated the stream yet, but indicated it
@@ -237,8 +229,6 @@ class SpdySession : public base::RefCounted<SpdySession>,
void OnWindowUpdate(const spdy::SpdyWindowUpdateControlFrame& frame);
// IO Callbacks
- void OnTCPConnect(int result);
- void OnSSLConnect(int result);
void OnReadComplete(int result);
void OnWriteComplete(int result);
@@ -290,16 +280,12 @@ class SpdySession : public base::RefCounted<SpdySession>,
void CloseAllStreams(net::Error status);
// Callbacks for the Spdy session.
- CompletionCallbackImpl<SpdySession> connect_callback_;
- CompletionCallbackImpl<SpdySession> ssl_connect_callback_;
CompletionCallbackImpl<SpdySession> read_callback_;
CompletionCallbackImpl<SpdySession> write_callback_;
// The domain this session is connected to.
const HostPortProxyPair host_port_proxy_pair_;
- SSLConfig ssl_config_;
-
scoped_refptr<HttpNetworkSession> session_;
// The socket handle for this session.
diff --git a/net/spdy/spdy_session_unittest.cc b/net/spdy/spdy_session_unittest.cc
index f53d022..faa8433 100644
--- a/net/spdy/spdy_session_unittest.cc
+++ b/net/spdy/spdy_session_unittest.cc
@@ -91,8 +91,12 @@ TEST_F(SpdySessionTest, GoAway) {
scoped_refptr<TCPSocketParams> tcp_params =
new TCPSocketParams(kTestHost, kTestPort, MEDIUM, GURL(), false);
- int rv = session->Connect(kTestHost, tcp_params, MEDIUM);
- ASSERT_EQ(OK, rv);
+ scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
+ EXPECT_EQ(OK,
+ connection->Init(test_host_port_pair.ToString(), tcp_params, MEDIUM,
+ NULL, http_session->tcp_socket_pool(),
+ BoundNetLog()));
+ EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
// Flush the SpdySession::OnReadComplete() task.
MessageLoop::current()->RunAllPending();
diff --git a/net/spdy/spdy_stream_unittest.cc b/net/spdy/spdy_stream_unittest.cc
index 392fb3b..54ea82d 100644
--- a/net/spdy/spdy_stream_unittest.cc
+++ b/net/spdy/spdy_stream_unittest.cc
@@ -192,8 +192,12 @@ TEST_F(SpdyStreamTest, SendDataAfterOpen) {
HostPortPair host_port_pair("www.google.com", 80);
scoped_refptr<TCPSocketParams> tcp_params =
new TCPSocketParams(host_port_pair, LOWEST, GURL(), false);
- EXPECT_EQ(OK, session->Connect("spdy.www.google.com", tcp_params,
- LOWEST));
+
+ scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
+ EXPECT_EQ(OK,
+ connection->Init(host_port_pair.ToString(), tcp_params, LOWEST,
+ NULL, session_->tcp_socket_pool(), BoundNetLog()));
+ session->InitializeWithSocket(connection.release(), false, OK);
scoped_refptr<SpdyStream> stream;
ASSERT_EQ(