diff --git a/src/components/cronet/cronet_context.cc b/src/components/cronet/cronet_context.cc index 85f14aa6fe..baee20b686 100644 --- a/src/components/cronet/cronet_context.cc +++ b/src/components/cronet/cronet_context.cc @@ -247,6 +247,10 @@ CronetContext::NetworkTasks::~NetworkTasks() { if (net::NetworkChangeNotifier::AreNetworkHandlesSupported()) net::NetworkChangeNotifier::RemoveNetworkObserver(this); + + if (default_cert_net_fetcher_) { + default_cert_net_fetcher_->Shutdown(); + } } void CronetContext::InitRequestContextOnInitThread() { @@ -426,6 +430,9 @@ CronetContext::NetworkTasks::BuildDefaultURLRequestContext( g_net_log.Get().net_log(), &context_builder); } + default_cert_net_fetcher_ = base::MakeRefCounted(); + context_builder.SetCertVerifier(net::CertVerifier::CreateDefault(default_cert_net_fetcher_)); + auto context = context_builder.Build(); // Set up host cache persistence if it's enabled. Happens after building the @@ -437,6 +444,8 @@ CronetContext::NetworkTasks::BuildDefaultURLRequestContext( g_net_log.Get().net_log()); } + default_cert_net_fetcher_->SetURLRequestContext(context.get()); + SetSharedURLRequestContextConfig(context.get()); return context; } diff --git a/src/components/cronet/cronet_context.h b/src/components/cronet/cronet_context.h index 6141657fb0..d30d01da07 100644 --- a/src/components/cronet/cronet_context.h +++ b/src/components/cronet/cronet_context.h @@ -19,6 +19,7 @@ #include "base/threading/thread_checker.h" #include "components/prefs/json_pref_store.h" #include "net/base/network_change_notifier.h" +#include "net/cert_net/cert_net_fetcher_url_request.h" #include "net/nqe/effective_connection_type.h" #include "net/nqe/effective_connection_type_observer.h" #include "net/nqe/network_quality_estimator.h" @@ -333,6 +334,9 @@ class CronetContext { base::flat_map> contexts_; + + scoped_refptr default_cert_net_fetcher_; + // Shorthand for the default context (needed by // components/cronet/android/test/cronet_test_util.cc). net::URLRequestContext* default_context_;