summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-16 19:32:28 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-16 19:32:28 +0000
commitb442da35fcf0bb0069390e819365bc7c9df37978 (patch)
tree5b66697e84c90964ea25b30fa36a8354f3b6e1f9 /net/socket
parent63e627dc079238661c337c71e0061f06f49fbb41 (diff)
downloadchromium_src-b442da35fcf0bb0069390e819365bc7c9df37978.zip
chromium_src-b442da35fcf0bb0069390e819365bc7c9df37978.tar.gz
chromium_src-b442da35fcf0bb0069390e819365bc7c9df37978.tar.bz2
Implement PPB_Flash_TCPSocket.InitiateSSL.
BUG=None TEST=None Review URL: http://codereview.chromium.org/7535007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97005 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/client_socket_factory.h3
-rw-r--r--net/socket/ssl_client_socket_unittest.cc37
2 files changed, 40 insertions, 0 deletions
diff --git a/net/socket/client_socket_factory.h b/net/socket/client_socket_factory.h
index b8e8d65..0f35194 100644
--- a/net/socket/client_socket_factory.h
+++ b/net/socket/client_socket_factory.h
@@ -47,6 +47,9 @@ class NET_EXPORT ClientSocketFactory {
NetLog* net_log,
const NetLog::Source& source) = 0;
+ // It is allowed to pass in a |transport_socket| that is not obtained from a
+ // socket pool. The caller could create a ClientSocketHandle directly and call
+ // set_socket() on it to set a valid StreamSocket instance.
virtual SSLClientSocket* CreateSSLClientSocket(
ClientSocketHandle* transport_socket,
const HostPortPair& host_and_port,
diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc
index 02dd8f0..b835342 100644
--- a/net/socket/ssl_client_socket_unittest.cc
+++ b/net/socket/ssl_client_socket_unittest.cc
@@ -14,6 +14,7 @@
#include "net/base/ssl_config_service.h"
#include "net/base/test_completion_callback.h"
#include "net/socket/client_socket_factory.h"
+#include "net/socket/client_socket_handle.h"
#include "net/socket/socket_test_util.h"
#include "net/socket/tcp_client_socket.h"
#include "net/test/test_server.h"
@@ -705,3 +706,39 @@ TEST_F(SSLClientSocketTest, CipherSuiteDisables) {
EXPECT_TRUE(LogContainsSSLConnectEndEvent(entries, -1) ||
LogContainsSSLConnectEndEvent(entries, -2));
}
+
+// When creating an SSLClientSocket, it is allowed to pass in a
+// ClientSocketHandle that is not obtained from a client socket pool.
+// Here we verify that such a simple ClientSocketHandle, not associated with any
+// client socket pool, can be destroyed safely.
+TEST_F(SSLClientSocketTest, ClientSocketHandleNotFromPool) {
+ net::TestServer test_server(net::TestServer::TYPE_HTTPS, FilePath());
+ ASSERT_TRUE(test_server.Start());
+
+ net::AddressList addr;
+ ASSERT_TRUE(test_server.GetAddressList(&addr));
+
+ TestCompletionCallback callback;
+ net::StreamSocket* transport = new net::TCPClientSocket(
+ addr, NULL, net::NetLog::Source());
+ int rv = transport->Connect(&callback);
+ if (rv == net::ERR_IO_PENDING)
+ rv = callback.WaitForResult();
+ EXPECT_EQ(net::OK, rv);
+
+ net::ClientSocketHandle* socket_handle = new net::ClientSocketHandle();
+ socket_handle->set_socket(transport);
+
+ net::SSLClientSocketContext context;
+ context.cert_verifier = cert_verifier_.get();
+ scoped_ptr<net::SSLClientSocket> ssl_socket(
+ socket_factory_->CreateSSLClientSocket(
+ socket_handle, test_server.host_port_pair(), kDefaultSSLConfig,
+ NULL, context));
+
+ EXPECT_FALSE(ssl_socket->IsConnected());
+ rv = ssl_socket->Connect(&callback);
+ if (rv == net::ERR_IO_PENDING)
+ rv = callback.WaitForResult();
+ EXPECT_EQ(net::OK, rv);
+}