diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index c898f5f1b33f..87d42486d503 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -285,6 +285,14 @@ void SetProxyInIO(net::URLRequestContextGetter* getter, RunCallbackInUI(callback); } +void SetCertVerifyProcInIO( + const scoped_refptr& context_getter, + const AtomCertVerifier::VerifyProc& proc) { + auto request_context = context_getter->GetURLRequestContext(); + static_cast(request_context->cert_verifier())-> + SetVerifyProc(proc); +} + void ClearHostResolverCacheInIO( const scoped_refptr& context_getter, const base::Closure& callback) { @@ -434,7 +442,10 @@ void Session::SetCertVerifyProc(v8::Local val, return; } - browser_context_->cert_verifier()->SetVerifyProc(proc); + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + base::Bind(&SetCertVerifyProcInIO, + make_scoped_refptr(browser_context_->GetRequestContext()), + proc)); } void Session::SetPermissionRequestHandler(v8::Local val, diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index 7b682543a09c..94cc3ee03d50 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -66,7 +66,6 @@ std::string RemoveWhitespace(const std::string& str) { AtomBrowserContext::AtomBrowserContext(const std::string& partition, bool in_memory) : brightray::BrowserContext(partition, in_memory), - cert_verifier_(new AtomCertVerifier), network_delegate_(new AtomNetworkDelegate) { // Construct user agent string. Browser* browser = Browser::Get(); @@ -174,7 +173,7 @@ content::PermissionManager* AtomBrowserContext::GetPermissionManager() { } std::unique_ptr AtomBrowserContext::CreateCertVerifier() { - return make_scoped_ptr(cert_verifier_); + return std::unique_ptr(new AtomCertVerifier); } net::SSLConfigService* AtomBrowserContext::CreateSSLConfigService() { diff --git a/atom/browser/atom_browser_context.h b/atom/browser/atom_browser_context.h index f793bc9870d6..732f1d045731 100644 --- a/atom/browser/atom_browser_context.h +++ b/atom/browser/atom_browser_context.h @@ -12,7 +12,6 @@ namespace atom { class AtomDownloadManagerDelegate; -class AtomCertVerifier; class AtomNetworkDelegate; class AtomPermissionManager; class WebViewManager; @@ -42,7 +41,6 @@ class AtomBrowserContext : public brightray::BrowserContext { // brightray::BrowserContext: void RegisterPrefs(PrefRegistrySimple* pref_registry) override; - AtomCertVerifier* cert_verifier() const { return cert_verifier_; } AtomNetworkDelegate* network_delegate() const { return network_delegate_; } private: @@ -52,7 +50,6 @@ class AtomBrowserContext : public brightray::BrowserContext { std::string user_agent_; // Managed by brightray::BrowserContext. - AtomCertVerifier* cert_verifier_; AtomNetworkDelegate* network_delegate_; DISALLOW_COPY_AND_ASSIGN(AtomBrowserContext); diff --git a/atom/browser/net/atom_cert_verifier.cc b/atom/browser/net/atom_cert_verifier.cc index adfba7060c90..dd588b9501ce 100644 --- a/atom/browser/net/atom_cert_verifier.cc +++ b/atom/browser/net/atom_cert_verifier.cc @@ -36,7 +36,6 @@ AtomCertVerifier::~AtomCertVerifier() { } void AtomCertVerifier::SetVerifyProc(const VerifyProc& proc) { - base::AutoLock auto_lock(lock_); verify_proc_ = proc; } @@ -52,20 +51,14 @@ int AtomCertVerifier::Verify( const net::BoundNetLog& net_log) { DCHECK_CURRENTLY_ON(BrowserThread::IO); - VerifyProc proc; - { - base::AutoLock auto_lock(lock_); - proc = verify_proc_; - } - - if (proc.is_null()) + if (verify_proc_.is_null()) return default_cert_verifier_->Verify( cert, hostname, ocsp_response, flags, crl_set, verify_result, callback, out_req, net_log); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(proc, hostname, make_scoped_refptr(cert), + base::Bind(verify_proc_, hostname, make_scoped_refptr(cert), base::Bind(OnResult, verify_result, callback))); return net::ERR_IO_PENDING; } diff --git a/atom/browser/net/atom_cert_verifier.h b/atom/browser/net/atom_cert_verifier.h index e00ba260ec3f..c8b4bf9290bb 100644 --- a/atom/browser/net/atom_cert_verifier.h +++ b/atom/browser/net/atom_cert_verifier.h @@ -5,10 +5,9 @@ #ifndef ATOM_BROWSER_NET_ATOM_CERT_VERIFIER_H_ #define ATOM_BROWSER_NET_ATOM_CERT_VERIFIER_H_ +#include #include -#include "base/memory/ref_counted.h" -#include "base/synchronization/lock.h" #include "net/cert/cert_verifier.h" namespace atom { @@ -39,7 +38,6 @@ class AtomCertVerifier : public net::CertVerifier { bool SupportsOCSPStapling() override; private: - base::Lock lock_; VerifyProc verify_proc_; std::unique_ptr default_cert_verifier_;