Index: net/socket/socket_test_util.cc |
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc |
index f993801adeb2814aede788bcf82c693bfa99696f..4540d508b0f4e8ee61d70779d1d9b5e49eac43e3 100644 |
--- a/net/socket/socket_test_util.cc |
+++ b/net/socket/socket_test_util.cc |
@@ -10,6 +10,7 @@ |
#include "base/basictypes.h" |
#include "base/bind.h" |
#include "base/bind_helpers.h" |
+#include "base/callback_helpers.h" |
#include "base/compiler_specific.h" |
#include "base/message_loop/message_loop.h" |
#include "base/run_loop.h" |
@@ -653,6 +654,8 @@ MockClientSocketFactory::MockClientSocketFactory() {} |
MockClientSocketFactory::~MockClientSocketFactory() {} |
+bool MockClientSocketFactory::leader_connected_ = false; |
+ |
void MockClientSocketFactory::AddSocketDataProvider( |
SocketDataProvider* data) { |
mock_data_.Add(data); |
@@ -668,6 +671,14 @@ void MockClientSocketFactory::ResetNextMockIndexes() { |
mock_ssl_data_.ResetNextIndex(); |
} |
+void MockClientSocketFactory::SetLeaderConnected() { |
+ leader_connected_ = true; |
+} |
+ |
+bool MockClientSocketFactory::IsLeaderConnected() { |
+ return leader_connected_; |
+} |
+ |
scoped_ptr<DatagramClientSocket> |
MockClientSocketFactory::CreateDatagramClientSocket( |
DatagramSocket::BindType bind_type, |
@@ -699,15 +710,23 @@ scoped_ptr<SSLClientSocket> MockClientSocketFactory::CreateSSLClientSocket( |
const HostPortPair& host_and_port, |
const SSLConfig& ssl_config, |
const SSLClientSocketContext& context) { |
- return scoped_ptr<SSLClientSocket>( |
+ scoped_ptr<MockSSLClientSocket> socket( |
new MockSSLClientSocket(transport_socket.Pass(), |
- host_and_port, ssl_config, |
+ host_and_port, |
+ ssl_config, |
mock_ssl_data_.GetNext())); |
+ ssl_client_sockets_.push_back(socket.get()); |
+ return socket.PassAs<SSLClientSocket>(); |
} |
void MockClientSocketFactory::ClearSSLSessionCache() { |
} |
+std::vector<MockSSLClientSocket*> |
+MockClientSocketFactory::GetSSLClientSockets() { |
+ return ssl_client_sockets_; |
+} |
+ |
const char MockClientSocket::kTlsUnique[] = "MOCK_TLSUNIQ"; |
MockClientSocket::MockClientSocket(const BoundNetLog& net_log) |
@@ -762,6 +781,22 @@ void MockClientSocket::GetSSLCertRequestInfo( |
SSLCertRequestInfo* cert_request_info) { |
} |
+bool MockClientSocket::InSessionCache() const { |
+ return true; |
+} |
+ |
+void MockClientSocket::SetHandshakeSuccessCallback(const base::Closure& cb) { |
+} |
+ |
+void MockClientSocket::SetHandshakeFailureCallback(const base::Closure& cb) { |
+} |
+ |
+void MockClientSocket::OnSocketFailure() { |
+} |
+ |
+void MockClientSocket::SetIsLeader() { |
+} |
+ |
int MockClientSocket::ExportKeyingMaterial(const base::StringPiece& label, |
bool has_context, |
const base::StringPiece& context, |
@@ -1314,9 +1349,9 @@ MockSSLClientSocket::MockSSLClientSocket( |
const SSLConfig& ssl_config, |
SSLSocketDataProvider* data) |
: MockClientSocket( |
- // Have to use the right BoundNetLog for LoadTimingInfo regression |
- // tests. |
- transport_socket->socket()->NetLog()), |
+ // Have to use the right BoundNetLog for LoadTimingInfo regression |
+ // tests. |
+ transport_socket->socket()->NetLog()), |
transport_(transport_socket.Pass()), |
data_(data), |
is_npn_state_set_(false), |
@@ -1342,11 +1377,32 @@ int MockSSLClientSocket::Write(IOBuffer* buf, int buf_len, |
} |
int MockSSLClientSocket::Connect(const CompletionCallback& callback) { |
+ if (SSLClientSocketPool::get_enable_connect_job_waiting()) { |
+ // The socket should only be starting to connect if the leader has already |
+ // connected -- unless the socket is the leader. |
+ if (!MockClientSocketFactory::IsLeaderConnected()) |
+ good_ordering_ = false; |
+ else |
+ good_ordering_ = true; |
+ } |
int rv = transport_->socket()->Connect( |
base::Bind(&ConnectCallback, base::Unretained(this), callback)); |
if (rv == OK) { |
- if (data_->connect.result == OK) |
+ if (data_->connect.result == OK) { |
connected_ = true; |
+ if (SSLClientSocketPool::get_enable_connect_job_waiting()) { |
+ if (data_->is_leader_) { |
+ good_ordering_ = true; |
+ MockClientSocketFactory::SetLeaderConnected(); |
+ } |
+ if (!success_callback_.is_null()) |
+ success_callback_.Run(); |
+ } |
+ } else if (SSLClientSocketPool::get_enable_connect_job_waiting() && |
+ data_->is_leader_) { |
+ error_callback_.Run(); |
Ryan Sleevi
2014/07/12 00:12:15
This doesn't seem right.
Is the behaviour of a no
|
+ } |
+ |
if (data_->connect.mode == ASYNC) { |
RunCallbackAsync(callback, data_->connect.result); |
return ERR_IO_PENDING; |
@@ -1399,6 +1455,23 @@ void MockSSLClientSocket::GetSSLCertRequestInfo( |
} |
} |
+bool MockSSLClientSocket::InSessionCache() const { |
+ return data_->is_in_session_cache_; |
+} |
+ |
+void MockSSLClientSocket::SetHandshakeSuccessCallback(const base::Closure& cb) { |
+ success_callback_ = cb; |
+} |
+ |
+void MockSSLClientSocket::SetHandshakeFailureCallback(const base::Closure& cb) { |
+ error_callback_ = cb; |
+} |
+ |
+void MockSSLClientSocket::OnHandshakeFailure() { |
+ if (!error_callback_.is_null()) |
+ base::ResetAndReturn(&error_callback_).Run(); |
+} |
+ |
SSLClientSocket::NextProtoStatus MockSSLClientSocket::GetNextProto( |
std::string* proto, std::string* server_protos) { |
*proto = data_->next_proto; |
@@ -1441,6 +1514,10 @@ ServerBoundCertService* MockSSLClientSocket::GetServerBoundCertService() const { |
return data_->server_bound_cert_service; |
} |
+bool MockSSLClientSocket::IsGoodOrdering() const { |
+ return good_ordering_; |
+} |
+ |
void MockSSLClientSocket::OnReadComplete(const MockRead& data) { |
NOTIMPLEMENTED(); |
} |