summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authorrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-13 22:37:16 +0000
committerrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-13 22:37:16 +0000
commitd9da5fe263e748c75d85816ee6bae46b2b9de9c9 (patch)
treef6dbf611550dc1118fcff2cfe9429ca721a5c1bf /net/socket
parenta691b8874c225cf530396661264a77159db38780 (diff)
downloadchromium_src-d9da5fe263e748c75d85816ee6bae46b2b9de9c9.zip
chromium_src-d9da5fe263e748c75d85816ee6bae46b2b9de9c9.tar.gz
chromium_src-d9da5fe263e748c75d85816ee6bae46b2b9de9c9.tar.bz2
Integrate the SpdyProxyClientSocket into the HttpStreamRequest
to support fetching HTTPS URLS over a SPDY Proxy. BUG=29625 TEST=HttpNetworkTransactionTest.HttpsProxySpdyConnect Review URL: http://codereview.chromium.org/3417010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62468 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/socket.h8
-rw-r--r--net/socket/socket_test_util.cc97
-rw-r--r--net/socket/socket_test_util.h61
-rw-r--r--net/socket/ssl_client_socket_pool_unittest.cc2
4 files changed, 11 insertions, 157 deletions
diff --git a/net/socket/socket.h b/net/socket/socket.h
index c3465ea..da17ce4 100644
--- a/net/socket/socket.h
+++ b/net/socket/socket.h
@@ -26,8 +26,8 @@ class Socket {
// case the result will be passed to the callback when available. If the
// operation is not completed immediately, the socket acquires a reference to
// the provided buffer until the callback is invoked or the socket is
- // destroyed. If the socket is closed before the read completes, the callback
- // will not be invoked.
+ // closed. If the socket is Disconnected before the read completes, the
+ // callback will not be invoked.
virtual int Read(IOBuffer* buf, int buf_len,
CompletionCallback* callback) = 0;
@@ -40,9 +40,9 @@ class Socket {
// case the result will be passed to the callback when available. If the
// operation is not completed immediately, the socket acquires a reference to
// the provided buffer until the callback is invoked or the socket is
- // destroyed. Implementations of this method should not modify the contents
+ // closed. Implementations of this method should not modify the contents
// of the actual buffer that is written to the socket. If the socket is
- // closed before the write completes, the callback will not be invoked.
+ // Disconnected before the write completes, the callback will not be invoked.
virtual int Write(IOBuffer* buf, int buf_len,
CompletionCallback* callback) = 0;
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index cba4b1c..414d395 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -127,7 +127,6 @@ void MockClientSocket::GetSSLInfo(net::SSLInfo* ssl_info) {
void MockClientSocket::GetSSLCertRequestInfo(
net::SSLCertRequestInfo* cert_request_info) {
- NOTREACHED();
}
SSLClientSocket::NextProtoStatus
@@ -1235,100 +1234,4 @@ const char kSOCKS5OkResponse[] =
{ 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 };
const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse);
-MockSSLClientSocketPool::MockSSLClientSocketPool(
- int max_sockets,
- int max_sockets_per_group,
- ClientSocketPoolHistograms* histograms,
- ClientSocketFactory* socket_factory,
- TCPClientSocketPool* tcp_pool)
- : SSLClientSocketPool(max_sockets, max_sockets_per_group, histograms,
- NULL, NULL, socket_factory,
- tcp_pool,
- NULL, NULL, NULL, NULL),
- client_socket_factory_(socket_factory),
- release_count_(0),
- cancel_count_(0) {
-}
-
-int MockSSLClientSocketPool::RequestSocket(const std::string& group_name,
- const void* socket_params,
- RequestPriority priority,
- ClientSocketHandle* handle,
- CompletionCallback* callback,
- const BoundNetLog& net_log) {
- ClientSocket* socket = client_socket_factory_->CreateTCPClientSocket(
- AddressList(), net_log.net_log(), net::NetLog::Source());
- MockConnectJob* job = new MockConnectJob(socket, handle, callback);
- job_list_.push_back(job);
- handle->set_pool_id(1);
- return job->Connect();
-}
-
-void MockSSLClientSocketPool::CancelRequest(const std::string& group_name,
- ClientSocketHandle* handle) {
- std::vector<MockConnectJob*>::iterator i;
- for (i = job_list_.begin(); i != job_list_.end(); ++i) {
- if ((*i)->CancelHandle(handle)) {
- cancel_count_++;
- break;
- }
- }
-}
-
-void MockSSLClientSocketPool::ReleaseSocket(const std::string& group_name,
- ClientSocket* socket, int id) {
- EXPECT_EQ(1, id);
- release_count_++;
- delete socket;
-}
-
-MockSSLClientSocketPool::~MockSSLClientSocketPool() {}
-
-MockSSLClientSocketPool::MockConnectJob::MockConnectJob(
- ClientSocket* socket,
- ClientSocketHandle* handle,
- CompletionCallback* callback)
- : socket_(socket),
- handle_(handle),
- user_callback_(callback),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- connect_callback_(this, &MockConnectJob::OnConnect)) {
-}
-
-int MockSSLClientSocketPool::MockConnectJob::Connect() {
- int rv = socket_->Connect(&connect_callback_);
- if (rv == OK) {
- user_callback_ = NULL;
- OnConnect(OK);
- }
- return rv;
-}
-
-bool MockSSLClientSocketPool::MockConnectJob::CancelHandle(
- const ClientSocketHandle* handle) {
- if (handle != handle_)
- return false;
- socket_.reset();
- handle_ = NULL;
- user_callback_ = NULL;
- return true;
-}
-
-void MockSSLClientSocketPool::MockConnectJob::OnConnect(int rv) {
- if (!socket_.get())
- return;
- if (rv == OK) {
- handle_->set_socket(socket_.release());
- } else {
- socket_.reset();
- }
-
- handle_ = NULL;
-
- if (user_callback_) {
- CompletionCallback* callback = user_callback_;
- user_callback_ = NULL;
- callback->Run(rv);
- }
-}
} // namespace net
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index 7293c05..eb54b84 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -92,6 +92,11 @@ struct MockRead {
result(0), data(data), data_len(data_len), sequence_number(0),
time_stamp(base::Time::Now()) { }
+ // Read success (inferred data length) with sequence information.
+ MockRead(bool async, int seq, const char* data) : async(async),
+ result(0), data(data), data_len(strlen(data)), sequence_number(seq),
+ time_stamp(base::Time::Now()) { }
+
// Read success with sequence information.
MockRead(bool async, const char* data, int data_len, int seq) : async(async),
result(0), data(data), data_len(data_len), sequence_number(seq),
@@ -923,62 +928,6 @@ extern const int kSOCKS5OkRequestLength;
extern const char kSOCKS5OkResponse[];
extern const int kSOCKS5OkResponseLength;
-class MockSSLClientSocketPool : public SSLClientSocketPool {
- public:
- class MockConnectJob {
- public:
- MockConnectJob(ClientSocket* socket, ClientSocketHandle* handle,
- CompletionCallback* callback);
-
- int Connect();
- bool CancelHandle(const ClientSocketHandle* handle);
-
- private:
- void OnConnect(int rv);
-
- scoped_ptr<ClientSocket> socket_;
- ClientSocketHandle* handle_;
- CompletionCallback* user_callback_;
- CompletionCallbackImpl<MockConnectJob> connect_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(MockConnectJob);
- };
-
- MockSSLClientSocketPool(
- int max_sockets,
- int max_sockets_per_group,
- ClientSocketPoolHistograms* histograms,
- ClientSocketFactory* socket_factory,
- TCPClientSocketPool* tcp_pool);
-
- virtual ~MockSSLClientSocketPool();
-
- int release_count() const { return release_count_; }
- int cancel_count() const { return cancel_count_; }
-
- // SSLClientSocketPool methods.
- virtual int RequestSocket(const std::string& group_name,
- const void* socket_params,
- RequestPriority priority,
- ClientSocketHandle* handle,
- CompletionCallback* callback,
- const BoundNetLog& net_log);
-
- virtual void CancelRequest(const std::string& group_name,
- ClientSocketHandle* handle);
- virtual void ReleaseSocket(const std::string& group_name,
- ClientSocket* socket, int id);
-
- private:
- ClientSocketFactory* client_socket_factory_;
- int release_count_;
- int cancel_count_;
- ScopedVector<MockConnectJob> job_list_;
-
- DISALLOW_COPY_AND_ASSIGN(MockSSLClientSocketPool);
-};
-
-
} // namespace net
#endif // NET_SOCKET_SOCKET_TEST_UTIL_H_
diff --git a/net/socket/ssl_client_socket_pool_unittest.cc b/net/socket/ssl_client_socket_pool_unittest.cc
index 2cc564bf..755bd44 100644
--- a/net/socket/ssl_client_socket_pool_unittest.cc
+++ b/net/socket/ssl_client_socket_pool_unittest.cc
@@ -71,6 +71,8 @@ class SSLClientSocketPoolTest : public testing::Test {
HostPortPair("host", 80),
session_->auth_cache(),
session_->http_auth_handler_factory(),
+ session_->spdy_session_pool(),
+ session_->mutable_spdy_settings(),
true)),
http_proxy_histograms_("MockHttpProxy"),
http_proxy_socket_pool_(