Index: content/browser/ssl/ssl_client_auth_handler.h |
diff --git a/content/browser/ssl/ssl_client_auth_handler.h b/content/browser/ssl/ssl_client_auth_handler.h |
index 6774287975f5f1a903937888821eef970b8a6aa4..84991ae2036b9b373c8819a02656c615119a2f3f 100644 |
--- a/content/browser/ssl/ssl_client_auth_handler.h |
+++ b/content/browser/ssl/ssl_client_auth_handler.h |
@@ -6,30 +6,25 @@ |
#define CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
#include "base/basictypes.h" |
+#include "base/callback.h" |
#include "base/memory/ref_counted.h" |
-#include "base/sequenced_task_runner_helpers.h" |
-#include "content/common/content_export.h" |
+#include "base/memory/weak_ptr.h" |
#include "content/public/browser/browser_thread.h" |
#include "net/ssl/ssl_cert_request_info.h" |
namespace net { |
class ClientCertStore; |
-class HttpNetworkSession; |
class URLRequest; |
class X509Certificate; |
} // namespace net |
namespace content { |
-class ResourceContext; |
- |
// This class handles the approval and selection of a certificate for SSL client |
-// authentication by the user. |
-// It is self-owned and deletes itself when the UI reports the user selection or |
-// when the net::URLRequest is cancelled. |
-class CONTENT_EXPORT SSLClientAuthHandler |
- : public base::RefCountedThreadSafe< |
- SSLClientAuthHandler, BrowserThread::DeleteOnIOThread> { |
+// authentication by the user. Should only be used on the IO thread. If the |
+// SSLClientAuthHandler is destroyed before the certificate is selected, the |
+// selection is canceled and the callback never called. |
+class SSLClientAuthHandler { |
public: |
using CertificateCallback = base::Callback<void(net::X509Certificate*)>; |
@@ -37,39 +32,24 @@ class CONTENT_EXPORT SSLClientAuthHandler |
net::URLRequest* request, |
net::SSLCertRequestInfo* cert_request_info, |
const CertificateCallback& callback); |
+ ~SSLClientAuthHandler(); |
// Selects a certificate and resumes the URL request with that certificate. |
- // Should only be called on the IO thread. |
void SelectCertificate(); |
- // Invoked when the request associated with this handler is cancelled. |
- // Should only be called on the IO thread. |
- void OnRequestCancelled(); |
- |
- // Calls DoCertificateSelected on the I/O thread. |
- // Called on the UI thread after the user has made a selection (which may |
- // be long after DoSelectCertificate returns, if the UI is modeless/async.) |
- void CertificateSelected(net::X509Certificate* cert); |
- |
- protected: |
- virtual ~SSLClientAuthHandler(); |
- |
private: |
- friend class base::RefCountedThreadSafe< |
- SSLClientAuthHandler, BrowserThread::DeleteOnIOThread>; |
- friend class BrowserThread; |
- friend class base::DeleteHelper<SSLClientAuthHandler>; |
+ class Core; |
- // Called when ClientCertStore is done retrieving the cert list. |
+ // Called when |core_| is done retrieving the cert list. |
void DidGetClientCerts(); |
- // Notifies that the user has selected a cert. |
- // Called on the IO thread. |
- void DoCertificateSelected(net::X509Certificate* cert); |
+ // Called when the user has selected a cert. |
pneubeck (no reviews)
2014/12/14 16:45:13
wouldn't |cert| be null if the selection was abort
davidben
2015/01/23 21:05:35
We actually don't ever plumb through aborting a se
|
+ void CertificateSelected(net::X509Certificate* cert); |
- // Selects a client certificate on the UI thread. |
- void DoSelectCertificate(int render_process_host_id, |
- int render_frame_host_id); |
+ // A reference-counted core so the ClientCertStore may outlive |
+ // SSLClientAuthHandler if the handler is destroyed while an operation on the |
+ // ClientCertStore is in progress. |
+ scoped_refptr<Core> core_; |
// The net::URLRequest that triggered this client auth. |
net::URLRequest* request_; |
@@ -77,11 +57,11 @@ class CONTENT_EXPORT SSLClientAuthHandler |
// The certs to choose from. |
scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; |
- scoped_ptr<net::ClientCertStore> client_cert_store_; |
- |
// The callback to call when the certificate is selected. |
CertificateCallback callback_; |
+ base::WeakPtrFactory<SSLClientAuthHandler> weak_factory_; |
+ |
DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); |
}; |