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

This commit is contained in:
Marshall Greenblatt
2020-07-20 13:49:16 -04:00
parent fab2af8876
commit e87fedd27c
3 changed files with 21 additions and 12 deletions

View File

@@ -1296,6 +1296,15 @@ void AlloyContentBrowserClient::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,