Fix shutdown crash in InitNetworkContext with multi-threaded message loop (fixes issue #2985)

This commit is contained in:
Marshall Greenblatt
2020-07-20 14:03:15 -04:00
parent 3f2c37255f
commit 149ccf946f
3 changed files with 21 additions and 12 deletions

View File

@@ -1318,6 +1318,15 @@ void CefContentBrowserClient::ConfigureNetworkContextParams(
const base::FilePath& relative_partition_path,
network::mojom::NetworkContextParams* network_context_params,
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params) {
// This method may be called during shutdown when using multi-threaded
// message loop mode. In that case exit early to avoid crashes.
if (!SystemNetworkContextManager::GetInstance()) {
// This must match the value expected in
// StoragePartitionImpl::InitNetworkContext.
network_context_params->context_name = "magic_shutting_down";
return;
}
Profile* profile = Profile::FromBrowserContext(context);
profile->ConfigureNetworkContextParams(in_memory, relative_partition_path,
network_context_params,