Commit 980b8878 authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Chromium LUCI CQ

PM: Also key awaiting frame clients on version_id.

It seems there's a possibility for a single frame client to be an
un-committed controlee of two service worker version_ids at the
same time.
Presumably this happens rarely during e.g. version updates or some
such.

Bug: 1143281
Change-Id: I9250b24945e7eed0251a7dee2eef3f473c74c917
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2581939Reviewed-by: default avatarPatrick Monette <pmonette@chromium.org>
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835275}
parent 75119bf8
...@@ -376,7 +376,9 @@ void WorkerWatcher::OnControlleeAdded( ...@@ -376,7 +376,9 @@ void WorkerWatcher::OnControlleeAdded(
case blink::mojom::ServiceWorkerClientType::kWindow: { case blink::mojom::ServiceWorkerClientType::kWindow: {
// For window clients, it is necessary to wait until the navigation has // For window clients, it is necessary to wait until the navigation has
// committed to a render frame host. // committed to a render frame host.
bool inserted = client_frames_awaiting_commit_.insert(client_uuid).second; bool inserted = client_frames_awaiting_commit_
.insert(AwaitingKey(version_id, client_uuid))
.second;
DCHECK(inserted); DCHECK(inserted);
break; break;
} }
...@@ -424,7 +426,8 @@ void WorkerWatcher::OnControlleeRemoved(int64_t version_id, ...@@ -424,7 +426,8 @@ void WorkerWatcher::OnControlleeRemoved(int64_t version_id,
return; return;
// Nothing to do for a frame client whose navigation never committed. // Nothing to do for a frame client whose navigation never committed.
size_t removed = client_frames_awaiting_commit_.erase(client_uuid); size_t removed = client_frames_awaiting_commit_.erase(
AwaitingKey(version_id, client_uuid));
if (removed) { if (removed) {
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
// |client_uuid| should not be part of this service worker's clients. // |client_uuid| should not be part of this service worker's clients.
...@@ -480,7 +483,8 @@ void WorkerWatcher::OnControlleeNavigationCommitted( ...@@ -480,7 +483,8 @@ void WorkerWatcher::OnControlleeNavigationCommitted(
features::kServiceWorkerRelationshipsInGraph)) features::kServiceWorkerRelationshipsInGraph))
return; return;
size_t removed = client_frames_awaiting_commit_.erase(client_uuid); size_t removed = client_frames_awaiting_commit_.erase(
AwaitingKey(version_id, client_uuid));
DCHECK_EQ(removed, 1u); DCHECK_EQ(removed, 1u);
bool inserted = service_worker_clients_[version_id] bool inserted = service_worker_clients_[version_id]
......
...@@ -211,7 +211,9 @@ class WorkerWatcher : public content::DedicatedWorkerService::Observer, ...@@ -211,7 +211,9 @@ class WorkerWatcher : public content::DedicatedWorkerService::Observer,
// Keeps track of frame clients that are awaiting the navigation commit // Keeps track of frame clients that are awaiting the navigation commit
// notification. Used for service workers only. // notification. Used for service workers only.
base::flat_set<std::string /*client_uuid*/> client_frames_awaiting_commit_; using AwaitingKey =
std::pair<int64_t /*version_id*/, std::string /*client_uuid*/>;
base::flat_set<AwaitingKey> client_frames_awaiting_commit_;
// Maps each service worker to its clients. // Maps each service worker to its clients.
base::flat_map< base::flat_map<
......
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