Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1237)

Unified Diff: net/socket/socket_test_util.h

Issue 353713005: Implements new, more robust design for communicating between SSLConnectJobs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implemented better memory management and callback handling. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/socket/socket_test_util.h
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index 2918aad2dc55ec4f3b8ff5a63c0e8b584aa1af5c..e9edb586341f27fb521852d1c066a4b13bb5ed3e 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -335,6 +335,10 @@ struct SSLSocketDataProvider {
bool channel_id_sent;
ServerBoundCertService* server_bound_cert_service;
int connection_status;
+
+ // Denotes that this job may have pending jobs dependant upon its connection.
+ bool is_leader_;
+ bool is_in_session_cache_;
Ryan Sleevi 2014/07/12 00:12:15 Please update the SSLSocketDataProvider ctor to se
mshelley 2014/07/17 00:28:44 Sorry -- my previous response was incorrect. There
};
// A DataProvider where the client must write a request before the reads (e.g.
@@ -634,6 +638,12 @@ class MockClientSocketFactory : public ClientSocketFactory {
void AddSSLSocketDataProvider(SSLSocketDataProvider* socket);
void ResetNextMockIndexes();
+ // Tells the client socket factory that the leading job has connected.
+ static void SetLeaderConnected();
+
+ // Returns |leader_connected_|.
+ static bool IsLeaderConnected();
+
SocketDataProviderArray<SocketDataProvider>& mock_data() {
return mock_data_;
}
@@ -654,10 +664,13 @@ class MockClientSocketFactory : public ClientSocketFactory {
const SSLConfig& ssl_config,
const SSLClientSocketContext& context) OVERRIDE;
virtual void ClearSSLSessionCache() OVERRIDE;
+ virtual std::vector<MockSSLClientSocket*> GetSSLClientSockets();
private:
SocketDataProviderArray<SocketDataProvider> mock_data_;
SocketDataProviderArray<SSLSocketDataProvider> mock_ssl_data_;
+ static bool leader_connected_;
+ std::vector<MockSSLClientSocket*> ssl_client_sockets_;
};
class MockClientSocket : public SSLClientSocket {
@@ -691,6 +704,11 @@ class MockClientSocket : public SSLClientSocket {
virtual void SetOmniboxSpeculation() OVERRIDE {}
// SSLClientSocket implementation.
+ virtual bool InSessionCache() const OVERRIDE;
+ virtual void SetHandshakeSuccessCallback(const base::Closure& cb) OVERRIDE;
+ virtual void SetHandshakeFailureCallback(const base::Closure& cb) OVERRIDE;
+ virtual void OnSocketFailure() OVERRIDE;
+ virtual void SetIsLeader() OVERRIDE;
wtc 2014/07/15 19:27:58 Delete these two methods.
mshelley 2014/07/17 00:28:44 Done.
virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info)
OVERRIDE;
virtual int ExportKeyingMaterial(const base::StringPiece& label,
@@ -950,6 +968,10 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket {
virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
// SSLClientSocket implementation.
+ virtual bool InSessionCache() const OVERRIDE;
+ virtual void SetHandshakeSuccessCallback(const base::Closure& cb) OVERRIDE;
+ virtual void SetHandshakeFailureCallback(const base::Closure& cb) OVERRIDE;
+ virtual void OnHandshakeFailure() OVERRIDE;
wtc 2014/07/15 19:27:58 Delete this method.
mshelley 2014/07/17 00:28:44 Done.
virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info)
OVERRIDE;
virtual NextProtoStatus GetNextProto(std::string* proto,
@@ -966,6 +988,15 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket {
virtual void set_channel_id_sent(bool channel_id_sent) OVERRIDE;
virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE;
+ // Returns a bool indicating whether or not the socket connected at
+ // the correct time relative to other sockets with the same host/port pair.
+ //
+ // If |is_leader_| is true, the socket should connect before all other
+ // sockets.
+ // If |is_leader_| is false, the socket should not connect until the leading
+ // socket has connected.
+ bool IsGoodOrdering() const;
+
private:
static void ConnectCallback(MockSSLClientSocket* ssl_client_socket,
const CompletionCallback& callback,
@@ -977,6 +1008,9 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket {
bool new_npn_value_;
bool is_protocol_negotiated_set_;
NextProto protocol_negotiated_;
+ bool good_ordering_;
+ base::Closure success_callback_;
+ base::Closure error_callback_;
DISALLOW_COPY_AND_ASSIGN(MockSSLClientSocket);
};

Powered by Google App Engine
This is Rietveld 408576698