OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/socket/ssl_client_socket.h" | 5 #include "net/socket/ssl_client_socket.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1827 TestCompletionCallback callback; | 1827 TestCompletionCallback callback; |
1828 scoped_ptr<StreamSocket> real_transport( | 1828 scoped_ptr<StreamSocket> real_transport( |
1829 new TCPClientSocket(addr, NULL, NetLog::Source())); | 1829 new TCPClientSocket(addr, NULL, NetLog::Source())); |
1830 scoped_ptr<SynchronousErrorStreamSocket> transport( | 1830 scoped_ptr<SynchronousErrorStreamSocket> transport( |
1831 new SynchronousErrorStreamSocket(real_transport.Pass())); | 1831 new SynchronousErrorStreamSocket(real_transport.Pass())); |
1832 int rv = callback.GetResult(transport->Connect(callback.callback())); | 1832 int rv = callback.GetResult(transport->Connect(callback.callback())); |
1833 EXPECT_EQ(OK, rv); | 1833 EXPECT_EQ(OK, rv); |
1834 | 1834 |
1835 SynchronousErrorStreamSocket* raw_transport = transport.get(); | 1835 SynchronousErrorStreamSocket* raw_transport = transport.get(); |
1836 scoped_ptr<SSLClientSocket> sock( | 1836 scoped_ptr<SSLClientSocket> sock( |
1837 CreateSSLClientSocket(transport.PassAs<StreamSocket>(), | 1837 CreateSSLClientSocket(transport.Pass(), |
1838 test_server.host_port_pair(), | 1838 test_server.host_port_pair(), |
1839 kDefaultSSLConfig)); | 1839 kDefaultSSLConfig)); |
1840 | 1840 |
1841 raw_transport->SetNextReadError(0); | 1841 raw_transport->SetNextReadError(0); |
1842 | 1842 |
1843 rv = callback.GetResult(sock->Connect(callback.callback())); | 1843 rv = callback.GetResult(sock->Connect(callback.callback())); |
1844 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); | 1844 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); |
1845 EXPECT_FALSE(sock->IsConnected()); | 1845 EXPECT_FALSE(sock->IsConnected()); |
1846 } | 1846 } |
1847 | 1847 |
(...skipping 16 matching lines...) Expand all Loading... |
1864 new SynchronousErrorStreamSocket(real_transport.Pass())); | 1864 new SynchronousErrorStreamSocket(real_transport.Pass())); |
1865 int rv = callback.GetResult(transport->Connect(callback.callback())); | 1865 int rv = callback.GetResult(transport->Connect(callback.callback())); |
1866 EXPECT_EQ(OK, rv); | 1866 EXPECT_EQ(OK, rv); |
1867 | 1867 |
1868 // Disable TLS False Start to ensure the handshake has completed. | 1868 // Disable TLS False Start to ensure the handshake has completed. |
1869 SSLConfig ssl_config; | 1869 SSLConfig ssl_config; |
1870 ssl_config.false_start_enabled = false; | 1870 ssl_config.false_start_enabled = false; |
1871 | 1871 |
1872 SynchronousErrorStreamSocket* raw_transport = transport.get(); | 1872 SynchronousErrorStreamSocket* raw_transport = transport.get(); |
1873 scoped_ptr<SSLClientSocket> sock( | 1873 scoped_ptr<SSLClientSocket> sock( |
1874 CreateSSLClientSocket(transport.PassAs<StreamSocket>(), | 1874 CreateSSLClientSocket(transport.Pass(), |
1875 test_server.host_port_pair(), | 1875 test_server.host_port_pair(), |
1876 ssl_config)); | 1876 ssl_config)); |
1877 | 1877 |
1878 rv = callback.GetResult(sock->Connect(callback.callback())); | 1878 rv = callback.GetResult(sock->Connect(callback.callback())); |
1879 EXPECT_EQ(OK, rv); | 1879 EXPECT_EQ(OK, rv); |
1880 EXPECT_TRUE(sock->IsConnected()); | 1880 EXPECT_TRUE(sock->IsConnected()); |
1881 | 1881 |
1882 raw_transport->SetNextReadError(0); | 1882 raw_transport->SetNextReadError(0); |
1883 scoped_refptr<IOBuffer> buf(new IOBuffer(4096)); | 1883 scoped_refptr<IOBuffer> buf(new IOBuffer(4096)); |
1884 rv = callback.GetResult(sock->Read(buf.get(), 4096, callback.callback())); | 1884 rv = callback.GetResult(sock->Read(buf.get(), 4096, callback.callback())); |
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3037 ssl_config.channel_id_enabled = true; | 3037 ssl_config.channel_id_enabled = true; |
3038 | 3038 |
3039 int rv; | 3039 int rv; |
3040 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); | 3040 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); |
3041 | 3041 |
3042 EXPECT_EQ(ERR_UNEXPECTED, rv); | 3042 EXPECT_EQ(ERR_UNEXPECTED, rv); |
3043 EXPECT_FALSE(sock_->IsConnected()); | 3043 EXPECT_FALSE(sock_->IsConnected()); |
3044 } | 3044 } |
3045 | 3045 |
3046 } // namespace net | 3046 } // namespace net |
OLD | NEW |