Commit 9fb1d37e authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Chromium LUCI CQ

Add an instrumentation in ServiceWorkerRegistration

We have a hypothesis that ServiceWorkerRegistration could be
destructed between ActivateWaitingVersion() and
ContinueActivation(). This CL adds an instrumentation to confirm
the hypothesis.

Bug: 1159778
Change-Id: Id15e4832e6ce82cc5230dc3f907b3e90036e62de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2636007Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844704}
parent d3ec16af
......@@ -67,6 +67,12 @@ ServiceWorkerRegistration::ServiceWorkerRegistration(
ServiceWorkerRegistration::~ServiceWorkerRegistration() {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK(!listeners_.might_have_observers());
// TODO(crbug.com/1159778): Remove once the bug is fixed.
CHECK(!in_activate_waiting_version_)
<< "ServiceWorkerRegistration was destroyed while activating waiting "
"version";
if (context_)
context_->RemoveLiveRegistration(registration_id_);
}
......@@ -480,6 +486,8 @@ void ServiceWorkerRegistration::ActivateWaitingVersion(bool delay) {
if (activating_version->is_redundant())
return; // Activation is no longer relevant.
in_activate_waiting_version_ = true;
// "5. If exitingWorker is not null,
if (exiting_version.get()) {
// Whenever activation happens, evict bfcached controllees.
......@@ -517,6 +525,7 @@ void ServiceWorkerRegistration::ActivateWaitingVersion(bool delay) {
// "10. Queue a task to fire an event named activate..."
// The browser could be shutting down. To avoid spurious start worker
// failures, wait a bit before continuing.
in_activate_waiting_version_ = false;
if (delay) {
task_runner_->PostDelayedTask(
FROM_HERE,
......
......@@ -286,6 +286,9 @@ class CONTENT_EXPORT ServiceWorkerRegistration
// longer considered a lame duck.
base::RepeatingTimer lame_duck_timer_;
// TODO(crbug.com/1159778): Remove once the bug is fixed.
bool in_activate_waiting_version_ = false;
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration);
};
......
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