Commit 0b14d31d authored by Patrick Monette's avatar Patrick Monette Committed by Commit Bot

Don't create a dedicated worker if its process is dead.

This is an optimization to avoid unnecessarily creating a worker if it's
going to be immediately destroyed.

In addition, the PerformanceManager can not handle a dedicated worker
whose render process is dead because that means the frame that created
the worker is also already gone.

Bug: 993029, 1064772
Change-Id: Id4ffbcfd34f2c23ad7e3381b92358cf543bae6c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124536
Commit-Queue: Patrick Monette <pmonette@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754492}
parent a0d7df33
...@@ -65,6 +65,7 @@ DedicatedWorkerHost::DedicatedWorkerHost( ...@@ -65,6 +65,7 @@ DedicatedWorkerHost::DedicatedWorkerHost(
coep_reporter_(std::move(coep_reporter)) { coep_reporter_(std::move(coep_reporter)) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(worker_process_host_); DCHECK(worker_process_host_);
DCHECK(worker_process_host_->IsInitializedAndNotDead());
DCHECK(coep_reporter_); DCHECK(coep_reporter_);
scoped_process_host_observer_.Add(worker_process_host_); scoped_process_host_observer_.Add(worker_process_host_);
...@@ -576,7 +577,8 @@ class DedicatedWorkerHostFactoryImpl final ...@@ -576,7 +577,8 @@ class DedicatedWorkerHostFactoryImpl final
} }
auto* worker_process_host = RenderProcessHost::FromID(worker_process_id_); auto* worker_process_host = RenderProcessHost::FromID(worker_process_id_);
if (!worker_process_host) { if (!worker_process_host ||
!worker_process_host->IsInitializedAndNotDead()) {
// Abort if the worker's process host is gone. This means that the calling // Abort if the worker's process host is gone. This means that the calling
// frame or worker is also either destroyed or in the process of being // frame or worker is also either destroyed or in the process of being
// destroyed. // destroyed.
...@@ -623,7 +625,8 @@ class DedicatedWorkerHostFactoryImpl final ...@@ -623,7 +625,8 @@ class DedicatedWorkerHostFactoryImpl final
// |script_url|, and report as bad message if that fails. // |script_url|, and report as bad message if that fails.
auto* worker_process_host = RenderProcessHost::FromID(worker_process_id_); auto* worker_process_host = RenderProcessHost::FromID(worker_process_id_);
if (!worker_process_host) { if (!worker_process_host ||
!worker_process_host->IsInitializedAndNotDead()) {
// Abort if the worker's process host is gone. This means that the calling // Abort if the worker's process host is gone. This means that the calling
// frame or worker is also either destroyed or in the process of being // frame or worker is also either destroyed or in the process of being
// destroyed. // destroyed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment