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

This commit is contained in:
Marshall Greenblatt 2019-11-26 16:26:48 -05:00
parent 49786ccc34
commit dfcfb51bef
3 changed files with 21 additions and 1 deletions

View File

@ -1288,6 +1288,11 @@ CefContentBrowserClient::CreateNetworkContext(
content::BrowserContext* context,
bool in_memory,
const base::FilePath& relative_partition_path) {
// 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())
return mojo::Remote<network::mojom::NetworkContext>();
Profile* profile = Profile::FromBrowserContext(context);
return profile->CreateNetworkContext(in_memory, relative_partition_path);
}

View File

@ -397,6 +397,9 @@ patches = [
# - Remove the non-nullptr WebContents requirement from
# NetworkServiceClient::OnAuthRequired.
# https://bitbucket.org/chromiumembedded/cef/issues/2718
#
# Fix shutdown crash in InitNetworkContext with multi-threaded message loop.
# https://bitbucket.org/chromiumembedded/cef/issues/2703
'name': 'services_network_request_id_2718',
},
{

View File

@ -1,5 +1,5 @@
diff --git content/browser/storage_partition_impl.cc content/browser/storage_partition_impl.cc
index 818a6370957a..64ab8e2462b5 100644
index 818a6370957a..46282b320b0b 100644
--- content/browser/storage_partition_impl.cc
+++ content/browser/storage_partition_impl.cc
@@ -577,10 +577,6 @@ class LoginHandlerDelegate {
@ -26,6 +26,18 @@ index 818a6370957a..64ab8e2462b5 100644
new LoginHandlerDelegate(std::move(auth_challenge_responder),
std::move(web_contents_getter), auth_info,
is_request_for_main_frame, process_id, routing_id,
@@ -2277,7 +2267,10 @@ void StoragePartitionImpl::GetQuotaSettings(
void StoragePartitionImpl::InitNetworkContext() {
network_context_ = GetContentClient()->browser()->CreateNetworkContext(
browser_context_, is_in_memory_, relative_partition_path_);
- DCHECK(network_context_);
+ if (!network_context_) {
+ // May happen during shutdown.
+ return;
+ }
network_context_client_receiver_.reset();
network_context_->SetClient(
diff --git services/network/public/cpp/simple_url_loader.cc services/network/public/cpp/simple_url_loader.cc
index 1cc4198e6057..0fae6dbe25a2 100644
--- services/network/public/cpp/simple_url_loader.cc