SSLClientSessionCache ownership refactor

In master, there is one instance of SSLClientSessionCache, accessible through
the singleton SSLClientSocketImpl::SSLContext.

Design principle for refactor: everywhere that a unique shard key is used to
index into the global session cache, we can refactor to use a unique instance
of the session cache.

This CL (1) removes the cache from the singleton and (2) adds an instance of
the cache to each instance of HttpNetworkSession.

[email protected]

Change-Id: Iccbad54264e8f9014c92f06e9698f253f365c8d3
Bug: 458365
Reviewed-on: https://chromium-review.googlesource.com/c/1400777
Commit-Queue: Daniel McArdle <[email protected]>
Reviewed-by: Matt Menke <[email protected]>
Reviewed-by: Steven Bennetts <[email protected]>
Reviewed-by: mark a. foltz <[email protected]>
Reviewed-by: Primiano Tucci <[email protected]>
Reviewed-by: Luke Halliwell <[email protected]>
Reviewed-by: David Benjamin <[email protected]>
Auto-Submit: Daniel McArdle <[email protected]>
Cr-Commit-Position: refs/heads/master@{#627694}
diff --git a/net/socket/ssl_client_socket_impl.h b/net/socket/ssl_client_socket_impl.h
index ee1b18c..0dda5dd 100644
--- a/net/socket/ssl_client_socket_impl.h
+++ b/net/socket/ssl_client_socket_impl.h
@@ -34,12 +34,6 @@
 #include "third_party/boringssl/src/include/openssl/base.h"
 #include "third_party/boringssl/src/include/openssl/ssl.h"
 
-namespace base {
-namespace trace_event {
-class ProcessMemoryDump;
-}
-}
-
 namespace crypto {
 class OpenSSLErrStackTracer;
 }
@@ -104,10 +98,6 @@
 
   void ApplySocketTag(const SocketTag& tag) override;
 
-  // Dumps memory allocation stats. |pmd| is the browser process memory dump.
-  static void DumpSSLClientSessionMemoryStats(
-      base::trace_event::ProcessMemoryDump* pmd);
-
   // Socket implementation.
   int Read(IOBuffer* buf,
            int buf_len,
@@ -183,6 +173,9 @@
   // Returns true if renegotiations are allowed.
   bool IsRenegotiationAllowed() const;
 
+  // Returns true when we should be using the ssl_client_session_cache_
+  bool IsCachingEnabled() const;
+
   // Callbacks for operations with the private key.
   ssl_private_key_result_t PrivateKeySignCallback(uint8_t* out,
                                                   size_t* out_len,
@@ -272,6 +265,8 @@
   std::unique_ptr<SocketBIOAdapter> transport_adapter_;
   const HostPortPair host_and_port_;
   SSLConfig ssl_config_;
+  // ssl_client_session_cache_ is a non-owning pointer to session cache
+  SSLClientSessionCache* ssl_client_session_cache_;
   // ssl_session_cache_shard_ is an opaque string that partitions the SSL
   // session cache. i.e. sessions created with one value will not attempt to
   // resume on the socket with a different value.