Commit ca076ee8 authored by mshelley@chromium.org's avatar mshelley@chromium.org

This CL is a follow up to https://codereview.chromium.org/353713005.

It removes the transport connect states from MockSSLCLientSocket Connect()
and renames some member variables for clarity.

R=wtc@chromium.org,rsleevi@chromium.org

BUG=398967

Review URL: https://codereview.chromium.org/454513002

Cr-Commit-Position: refs/heads/master@{#288277}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288277 0039d316-1c4b-4281-b951-d872f2087c98
parent f2cff816
......@@ -279,7 +279,7 @@ SSLSocketDataProvider::SSLSocketDataProvider(IoMode mode, int result)
cert_request_info(NULL),
channel_id_sent(false),
connection_status(0),
should_block_on_connect(false),
should_pause_on_connect(false),
is_in_session_cache(false) {
SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_TLS1_2,
&connection_status);
......@@ -1349,7 +1349,7 @@ int MockSSLClientSocket::Write(IOBuffer* buf, int buf_len,
}
int MockSSLClientSocket::Connect(const CompletionCallback& callback) {
next_connect_state_ = STATE_TRANSPORT_CONNECT;
next_connect_state_ = STATE_SSL_CONNECT;
reached_connect_ = true;
int rv = DoConnectLoop(OK);
if (rv == ERR_IO_PENDING)
......@@ -1460,7 +1460,7 @@ void MockSSLClientSocket::OnConnectComplete(const MockConnect& data) {
}
void MockSSLClientSocket::RestartPausedConnect() {
DCHECK(data_->should_block_on_connect);
DCHECK(data_->should_pause_on_connect);
DCHECK_EQ(next_connect_state_, STATE_SSL_CONNECT_COMPLETE);
OnIOComplete(data_->connect.result);
}
......@@ -1479,12 +1479,6 @@ int MockSSLClientSocket::DoConnectLoop(int result) {
ConnectState state = next_connect_state_;
next_connect_state_ = STATE_NONE;
switch (state) {
case STATE_TRANSPORT_CONNECT:
rv = DoTransportConnect();
break;
case STATE_TRANSPORT_CONNECT_COMPLETE:
rv = DoTransportConnectComplete(rv);
break;
case STATE_SSL_CONNECT:
rv = DoSSLConnect();
break;
......@@ -1501,22 +1495,10 @@ int MockSSLClientSocket::DoConnectLoop(int result) {
return rv;
}
int MockSSLClientSocket::DoTransportConnect() {
next_connect_state_ = STATE_TRANSPORT_CONNECT_COMPLETE;
return transport_->socket()->Connect(
base::Bind(&MockSSLClientSocket::OnIOComplete, base::Unretained(this)));
}
int MockSSLClientSocket::DoTransportConnectComplete(int result) {
if (result == OK)
next_connect_state_ = STATE_SSL_CONNECT;
return result;
}
int MockSSLClientSocket::DoSSLConnect() {
next_connect_state_ = STATE_SSL_CONNECT_COMPLETE;
if (data_->should_block_on_connect)
if (data_->should_pause_on_connect)
return ERR_IO_PENDING;
if (data_->connect.mode == ASYNC) {
......
......@@ -334,8 +334,8 @@ struct SSLSocketDataProvider {
bool channel_id_sent;
ChannelIDService* channel_id_service;
int connection_status;
// Indicates that the socket should block in the Connect method.
bool should_block_on_connect;
// Indicates that the socket should pause in the Connect method.
bool should_pause_on_connect;
// Whether or not the Socket should behave like there is a pre-existing
// session to resume. Whether or not such a session is reported as
// resumed is controlled by |connection_status|.
......@@ -990,8 +990,6 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket {
private:
enum ConnectState {
STATE_NONE,
STATE_TRANSPORT_CONNECT,
STATE_TRANSPORT_CONNECT_COMPLETE,
STATE_SSL_CONNECT,
STATE_SSL_CONNECT_COMPLETE,
};
......@@ -1001,8 +999,6 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket {
// Runs the state transistion loop.
int DoConnectLoop(int result);
int DoTransportConnect();
int DoTransportConnectComplete(int result);
int DoSSLConnect();
int DoSSLConnectComplete(int result);
......
......@@ -134,7 +134,7 @@ class SSLConnectJobMessenger {
// Adds |socket| to the list of sockets waiting to Connect(). When
// the messenger has determined that it's an appropriate time for |socket|
// to connect, it will asynchronously invoke |callback|.
// to connect, it will invoke |callback|.
//
// Note: It is an error to call AddPendingSocket() without having first
// called MonitorConnectionResult() and configuring a socket that WILL
......
......@@ -331,13 +331,13 @@ TEST_P(SSLClientSocketPoolTest, SocketsConnectWithoutFlag) {
SSLSocketDataProvider ssl(ASYNC, OK);
ssl.is_in_session_cache = false;
ssl.should_block_on_connect = true;
ssl.should_pause_on_connect = true;
SSLSocketDataProvider ssl2(ASYNC, OK);
ssl2.is_in_session_cache = false;
ssl2.should_block_on_connect = true;
ssl2.should_pause_on_connect = true;
SSLSocketDataProvider ssl3(ASYNC, OK);
ssl3.is_in_session_cache = false;
ssl3.should_block_on_connect = true;
ssl3.should_pause_on_connect = true;
socket_factory_.AddSSLSocketDataProvider(&ssl);
socket_factory_.AddSSLSocketDataProvider(&ssl2);
socket_factory_.AddSSLSocketDataProvider(&ssl3);
......@@ -404,7 +404,7 @@ TEST_P(SSLClientSocketPoolTest, DeletedSSLConnectJob) {
SSLSocketDataProvider ssl(ASYNC, OK);
ssl.is_in_session_cache = false;
ssl.should_block_on_connect = true;
ssl.should_pause_on_connect = true;
SSLSocketDataProvider ssl2(ASYNC, OK);
ssl2.is_in_session_cache = false;
SSLSocketDataProvider ssl3(ASYNC, OK);
......@@ -469,7 +469,7 @@ TEST_P(SSLClientSocketPoolTest, DeletedSocketAfterFail) {
SSLSocketDataProvider ssl(ASYNC, ERR_SSL_PROTOCOL_ERROR);
ssl.is_in_session_cache = false;
ssl.should_block_on_connect = true;
ssl.should_pause_on_connect = true;
SSLSocketDataProvider ssl2(ASYNC, OK);
ssl2.is_in_session_cache = false;
SSLSocketDataProvider ssl3(ASYNC, OK);
......@@ -542,10 +542,10 @@ TEST_P(SSLClientSocketPoolTest, SimultaneousConnectJobsFail) {
socket_factory_.AddSocketDataProvider(&data5);
SSLSocketDataProvider ssl(ASYNC, ERR_SSL_PROTOCOL_ERROR);
ssl.is_in_session_cache = false;
ssl.should_block_on_connect = true;
ssl.should_pause_on_connect = true;
SSLSocketDataProvider ssl2(ASYNC, OK);
ssl2.is_in_session_cache = false;
ssl2.should_block_on_connect = true;
ssl2.should_pause_on_connect = true;
SSLSocketDataProvider ssl3(ASYNC, OK);
ssl3.is_in_session_cache = false;
SSLSocketDataProvider ssl4(ASYNC, OK);
......@@ -632,7 +632,7 @@ TEST_P(SSLClientSocketPoolTest, SimultaneousConnectJobsSuccess) {
SSLSocketDataProvider ssl(ASYNC, OK);
ssl.is_in_session_cache = false;
ssl.should_block_on_connect = true;
ssl.should_pause_on_connect = true;
SSLSocketDataProvider ssl2(ASYNC, OK);
ssl2.is_in_session_cache = false;
SSLSocketDataProvider ssl3(ASYNC, OK);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment