-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Extensions] Simplify ServiceWorker keepalive counts for API calls
When an extension API is called from an ephemeral context like a service worker (or in MV2, an event page), we increment the keepalive count for the ephemeral context. We then decrement that keepalive count when the API call is complete. For event page contexts, we handle this entirely in the browser context in response to the API call coming in. For service workers, we currently have two separate IPC messages: one for the API call and a second to increment the keepalive. We similarly have an "ack" in the renderer that responds to the API call completion and sends the message to decrement the keepalive. At the time, this was done because it was simpler than incorporating the keepalive logic into the API call message (as it is for the event page case); this was in part due to service worker management previously running on the IO thread. This is no longer the case, and its simpler now to simply tie this into the browser receiving the API call. Do this, and have the browser handle incrementing and decrementing the keepalive count directly in response to the extension API call. This has the following advantages: - Significantly less code overall - Fewer IPC messsages - More similar code paths for event pages + service workers - The service worker keepalive count now uses the (more common) ProcessManager::[In|De]crementServiceWorkerKeepaliveCount() methods, which provide more information in debugging and make it easier to audit callsites. As part of this, we also add a UUID to ExtensionFunctions. This is used to track the request in the service worker layer. In the future, we can use this in lieu of the existing integer request ID. Bug: 1423190, 1444561 Change-Id: I249a4de1a85b74a125f9321cbaf32fc85b55a3ac Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4518520 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org> Reviewed-by: David Bertoni <dbertoni@chromium.org> Commit-Queue: Devlin Cronin <rdevlin.cronin@chromium.org> Cr-Commit-Position: refs/heads/main@{#1154102}
- Loading branch information
Showing
15 changed files
with
77 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.