0
Files
src/apps
David Bertoni 9cfed26659 [Extensions] Clean up LazyContextId issues.
The CL cleans up issues within LazyContextId and how it's used.

1. LazyContextId currently stores the service worker scope for
instances created for a service worker-based extension. Since we
only ever register the extension's script at the root scope, there's
no need to store this, since it can be inferred from the extension's
ID.

2. ServiceWorkerTaskQueue::SequencedContextId is a std::pair
containing a LazyContextId and a base::UnguessableToken that's
generated when the queue tries to activate the service worker. This
CL changes this to a struct with named fields for clarity. It also
only stores the extension's ID and the BrowserContext from the
LazyContextId, since that's all that's needed.

3. There are places where LazyContextId instances are created and the
type of the instance (for and EventPage-based extension or a service
worker-based extension) is inferred from the constructor used. Since
the scope is no longer saved, there is no longer a need for unique
constructors and the type cannot be inferred. This CL adds static
member functions that are clearly named and create the expected
type of LazyContextId. There is also an option to create one for
an extension where the function determines the type of LazyContextId
based on the extension. This is the safest and clearest way, so many
call sites are migrated to use this static member function.

Bug: None
Change-Id: If40c9a7fa9fa0148bb2d1b0faa7f988a18dfe654
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5050418
Reviewed-by: Fabian Sommer <fabiansommer@chromium.org>
Reviewed-by: Ben Reich <benreich@chromium.org>
Reviewed-by: Trent Apted <tapted@chromium.org>
Auto-Submit: David Bertoni <dbertoni@chromium.org>
Commit-Queue: David Bertoni <dbertoni@chromium.org>
Reviewed-by: Devlin Cronin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1236662}
2023-12-12 23:33:32 +00:00
..