Index: content/browser/renderer_host/render_process_host_impl.cc |
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc |
index b3425b0d72e0ed354646da8c802154312fdf1f17..9496cf1052a219f97fe7abc06ae97ba444c17b7b 100644 |
--- a/content/browser/renderer_host/render_process_host_impl.cc |
+++ b/content/browser/renderer_host/render_process_host_impl.cc |
@@ -559,7 +559,7 @@ RenderProcessHostImpl::RenderProcessHostImpl( |
id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
browser_context_(browser_context), |
storage_partition_impl_(storage_partition_impl), |
- sudden_termination_allowed_(true), |
+ sudden_termination_blocking_refcount_(0), |
ignore_input_events_(false), |
is_for_guests_only_(is_for_guests_only), |
gpu_observer_registered_(false), |
@@ -956,7 +956,10 @@ void RenderProcessHostImpl::CreateMessageFilters() { |
GetID(), storage_partition_impl_->GetURLRequestContext(), |
storage_partition_impl_->GetFileSystemContext(), |
blob_storage_context.get(), StreamContext::GetFor(browser_context))); |
- AddFilter(new BlobDispatcherHost(blob_storage_context.get())); |
+ AddFilter(new BlobDispatcherHost( |
+ blob_storage_context.get(), |
+ base::Bind(&RenderProcessHostImpl::SetSuddenTerminationAllowed, |
+ base::Unretained(this)))); |
AddFilter(new FileUtilitiesMessageFilter(GetID())); |
AddFilter(new MimeRegistryMessageFilter()); |
AddFilter( |
@@ -1680,7 +1683,7 @@ bool RenderProcessHostImpl::FastShutdownIfPossible() { |
!GetHandle()) |
return false; // Render process hasn't started or is probably crashed. |
- // Test if there's an unload listener. |
+ // Test if there's an unload listener or blobs waiting to be transferred. |
// NOTE: It's possible that an onunload listener may be installed |
// while we're shutting down, so there's a small race here. Given that |
// the window is small, it's unlikely that the web page has much |
@@ -1972,11 +1975,11 @@ void RenderProcessHostImpl::RemovePendingView() { |
} |
void RenderProcessHostImpl::SetSuddenTerminationAllowed(bool enabled) { |
- sudden_termination_allowed_ = enabled; |
+ sudden_termination_blocking_refcount_ += enabled ? -1 : 1; |
} |
bool RenderProcessHostImpl::SuddenTerminationAllowed() const { |
- return sudden_termination_allowed_; |
+ return sudden_termination_blocking_refcount_ <= 0; |
} |
base::TimeDelta RenderProcessHostImpl::GetChildProcessIdleTime() const { |