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

Unified Diff: net/socket/ssl_client_socket_impl.h

Issue 2411033003: Drop buffers in idle SSLClientSockets (and SSLServerSockets). (Closed)
Patch Set: rsleevi comments Created 4 years, 2 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
« no previous file with comments | « net/socket/socket_test_util.cc ('k') | net/socket/ssl_client_socket_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/ssl_client_socket_impl.h
diff --git a/net/socket/ssl_client_socket_impl.h b/net/socket/ssl_client_socket_impl.h
index ff235ed4bdfa0bd771c6cf326f1bdbabba5dfaab..010a6f008b7f1d97d86d4c1e6a8f3010d0e507d2 100644
--- a/net/socket/ssl_client_socket_impl.h
+++ b/net/socket/ssl_client_socket_impl.h
@@ -26,6 +26,7 @@
#include "net/cert/ct_verify_result.h"
#include "net/log/net_log_with_source.h"
#include "net/socket/client_socket_handle.h"
+#include "net/socket/socket_bio_adapter.h"
#include "net/socket/ssl_client_socket.h"
#include "net/ssl/channel_id_service.h"
#include "net/ssl/openssl_ssl_util.h"
@@ -45,6 +46,7 @@ namespace net {
class CertVerifier;
class CTVerifier;
+class SocketBIOAdapter;
class SSLCertRequestInfo;
class SSLInfo;
@@ -52,7 +54,8 @@ using TokenBindingSignatureMap =
base::MRUCache<std::pair<TokenBindingType, std::string>,
std::vector<uint8_t>>;
-class SSLClientSocketImpl : public SSLClientSocket {
+class SSLClientSocketImpl : public SSLClientSocket,
+ public SocketBIOAdapter::Delegate {
public:
// Takes ownership of the transport_socket, which may already be connected.
// The given hostname will be compared with the name(s) in the server's
@@ -121,6 +124,10 @@ class SSLClientSocketImpl : public SSLClientSocket {
int SetReceiveBufferSize(int32_t size) override;
int SetSendBufferSize(int32_t size) override;
+ // SocketBIOAdapter implementation:
+ void OnReadReady() override;
+ void OnWriteReady() override;
+
private:
class PeerCertificateChain;
class SSLContext;
@@ -131,7 +138,6 @@ class SSLClientSocketImpl : public SSLClientSocket {
void DoReadCallback(int result);
void DoWriteCallback(int result);
- bool DoTransportIO();
int DoHandshake();
int DoHandshakeComplete(int result);
int DoChannelIDLookup();
@@ -142,26 +148,16 @@ class SSLClientSocketImpl : public SSLClientSocket {
void UpdateServerCert();
void OnHandshakeIOComplete(int result);
- void OnSendComplete(int result);
- void OnRecvComplete(int result);
int DoHandshakeLoop(int last_io_result);
- int DoReadLoop();
- int DoWriteLoop();
int DoPayloadRead();
int DoPayloadWrite();
// Called when an asynchronous event completes which may have blocked the
- // pending Read or Write calls, if any. Retries both state machines and, if
- // complete, runs the respective callbacks.
- void PumpReadWriteEvents();
-
- int BufferSend();
- int BufferRecv();
- void BufferSendComplete(int result);
- void BufferRecvComplete(int result);
- void TransportWriteComplete(int result);
- int TransportReadComplete(int result);
+ // pending Connect, Read or Write calls, if any. Retries all state machines
+ // and, if complete, runs the respective callbacks.
+ void RetryAllOperations();
+
int VerifyCT();
// Callback from the SSL layer that indicates the remote server is requesting
@@ -173,25 +169,6 @@ class SSLClientSocketImpl : public SSLClientSocket {
// certificates don't change during renegotiation.
int CertVerifyCallback(X509_STORE_CTX* store_ctx);
- // Called during an operation on |transport_bio_|'s peer. Checks saved
- // transport error state and, if appropriate, returns an error through
- // OpenSSL's error system.
- long MaybeReplayTransportError(BIO* bio,
- int cmd,
- const char* argp,
- int argi,
- long argl,
- long retvalue);
-
- // Callback from the SSL layer when an operation is performed on
- // |transport_bio_|'s peer.
- static long BIOCallback(BIO* bio,
- int cmd,
- const char* argp,
- int argi,
- long argl,
- long retvalue);
-
// Called after the initial handshake completes and after the server
// certificate has been verified. The order of handshake completion and
// certificate verification depends on whether the connection was false
@@ -258,14 +235,6 @@ class SSLClientSocketImpl : public SSLClientSocket {
const crypto::OpenSSLErrStackTracer& tracer,
OpenSSLErrorInfo* info);
- bool transport_send_busy_;
- bool transport_recv_busy_;
-
- // Buffers which are shared by BoringSSL and SSLClientSocketImpl.
- // GrowableIOBuffer is used to keep ownership and setting offset.
- scoped_refptr<GrowableIOBuffer> send_buffer_;
- scoped_refptr<GrowableIOBuffer> recv_buffer_;
-
CompletionCallback user_connect_callback_;
CompletionCallback user_read_callback_;
CompletionCallback user_write_callback_;
@@ -293,15 +262,6 @@ class SSLClientSocketImpl : public SSLClientSocket {
// If there is a pending read result, the OpenSSLErrorInfo associated with it.
OpenSSLErrorInfo pending_read_error_info_;
- // Used by TransportReadComplete() to signify an error reading from the
- // transport socket. A value of OK indicates the socket is still
- // readable. EOFs are mapped to ERR_CONNECTION_CLOSED.
- int transport_read_error_;
-
- // Used by TransportWriteComplete() and TransportReadComplete() to signify an
- // error writing to the transport socket. A value of OK indicates no error.
- int transport_write_error_;
-
// Set when Connect finishes.
std::unique_ptr<PeerCertificateChain> server_cert_chain_;
scoped_refptr<X509Certificate> server_cert_;
@@ -336,9 +296,9 @@ class SSLClientSocketImpl : public SSLClientSocket {
// OpenSSL stuff
bssl::UniquePtr<SSL> ssl_;
- bssl::UniquePtr<BIO> transport_bio_;
std::unique_ptr<ClientSocketHandle> transport_;
+ std::unique_ptr<SocketBIOAdapter> transport_adapter_;
const HostPortPair host_and_port_;
SSLConfig ssl_config_;
// ssl_session_cache_shard_ is an opaque string that partitions the SSL
« no previous file with comments | « net/socket/socket_test_util.cc ('k') | net/socket/ssl_client_socket_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698