Ensure that all async IPC calls made on ServiceWorkerRegistration (which includes calls made on behalf of NavigationPreloadManager) hold a strong reference to the ServiceWorkerRegistration for the duration of the async IPC calls so that the ServiceWorkerRegistration is not cycle-collected if the caller is only then-ing on the promise and has not retained a strong reference to the ServiceWorkerRegistration. This is accomplished by holding a strong self-reference in the IPC-resolved callback. In order to ensure that these strong references are properly cleaned up on the main thread, we: - Add a call to Shutdown during DisconnectFromOwner to shutdown IPC when the global is being torn down. - Modernize PServiceWorkerRegistration to allow the child to directly invoke `Send__delete__` rather than having to ask the parent to call that method via `SendTeardown`. This ensures the actor is destroyed in a more timely fashion and generally makes things easier to reason about. - Eliminate use of boolean flags that are redundant with what `CanSend()` indicates (as long as we call it on the thread that owns the actor). The Shutdown call isn't technically needed on the worker thread because worker shutdown tears down PBackground and thereby all PServiceWorkerRegistration instances, although these cleanups make that cleanup happen in a more timely fashion. Additionally, ServiceWorkerRegistrationChild does use IPCWorkerRef with the callback triggering eager shutdown of the actor on workers (notify(Canceling) can occur prior to DisconnectFromOwner when the interrupt is used), but the more notable impact is IPCWorkerRef causes the actor to not be counted as something that should prevent GC of the worker (and these changes do not alter that). Differential Revision: https://phabricator.services.mozilla.com/D242885
43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
include protocol PBackground;
|
|
|
|
include ClientIPCTypes;
|
|
include DOMTypes;
|
|
include IPCNavigationPreloadState;
|
|
include IPCServiceWorkerRegistrationDescriptor;
|
|
|
|
include "ipc/ErrorIPCUtils.h";
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
[ChildImpl=virtual, ParentImpl=virtual]
|
|
protocol PServiceWorkerRegistration
|
|
{
|
|
manager PBackground;
|
|
|
|
parent:
|
|
async Unregister() returns (bool aSuccess, CopyableErrorResult aRv);
|
|
async Update(nsCString aNewestWorkerScriptUrl) returns (
|
|
IPCServiceWorkerRegistrationDescriptorOrCopyableErrorResult aResult);
|
|
async GetNotifications(nsString aTag) returns (IPCNotificationsOrError aResult);
|
|
|
|
// For NavigationPreload interface
|
|
async SetNavigationPreloadEnabled(bool aEnabled) returns (bool aSuccess);
|
|
async SetNavigationPreloadHeader(nsCString aHeader) returns (bool aSuccess);
|
|
async GetNavigationPreloadState() returns (IPCNavigationPreloadState? aState);
|
|
|
|
child:
|
|
async UpdateState(IPCServiceWorkerRegistrationDescriptor aDescriptor);
|
|
async FireUpdateFound();
|
|
|
|
both:
|
|
async __delete__();
|
|
};
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|