mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 1425975 P6 Rename some service worker methods to not reference documents. r=asuth
This commit is contained in:
parent
81e3a5bfa7
commit
aaf7a2cb50
@ -1618,7 +1618,7 @@ ServiceWorkerManager::WorkerIsIdle(ServiceWorkerInfo* aWorker)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!reg->IsControllingDocuments() && reg->mPendingUninstall) {
|
||||
if (!reg->IsControllingClients() && reg->mPendingUninstall) {
|
||||
RemoveRegistration(reg);
|
||||
return;
|
||||
}
|
||||
@ -2366,7 +2366,7 @@ ServiceWorkerManager::MaybeStopControlling(nsIDocument* aDoc)
|
||||
// it will always call MaybeStopControlling() even if there isn't an
|
||||
// associated registration. So this check is required.
|
||||
if (registration) {
|
||||
StopControllingADocument(registration);
|
||||
StopControllingRegistration(registration);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2419,7 +2419,7 @@ ServiceWorkerManager::StartControllingADocument(ServiceWorkerRegistrationInfo* a
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
aRegistration->StartControllingADocument();
|
||||
aRegistration->StartControllingClient();
|
||||
mControlledDocuments.Put(aDoc, aRegistration);
|
||||
|
||||
StartControllingClient(clientInfo.ref(), aRegistration);
|
||||
@ -2438,10 +2438,10 @@ ServiceWorkerManager::StartControllingADocument(ServiceWorkerRegistrationInfo* a
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorkerManager::StopControllingADocument(ServiceWorkerRegistrationInfo* aRegistration)
|
||||
ServiceWorkerManager::StopControllingRegistration(ServiceWorkerRegistrationInfo* aRegistration)
|
||||
{
|
||||
aRegistration->StopControllingADocument();
|
||||
if (aRegistration->IsControllingDocuments() || !aRegistration->IsIdle()) {
|
||||
aRegistration->StopControllingClient();
|
||||
if (aRegistration->IsControllingClients() || !aRegistration->IsIdle()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3246,7 +3246,7 @@ ServiceWorkerManager::MaybeClaimClient(nsIDocument* aDocument,
|
||||
}
|
||||
|
||||
if (controllingRegistration) {
|
||||
StopControllingADocument(controllingRegistration);
|
||||
StopControllingRegistration(controllingRegistration);
|
||||
}
|
||||
|
||||
ref = StartControllingADocument(aWorkerRegistration, aDocument);
|
||||
|
@ -403,7 +403,7 @@ private:
|
||||
nsIDocument* aDoc);
|
||||
|
||||
void
|
||||
StopControllingADocument(ServiceWorkerRegistrationInfo* aRegistration);
|
||||
StopControllingRegistration(ServiceWorkerRegistrationInfo* aRegistration);
|
||||
|
||||
already_AddRefed<ServiceWorkerRegistrationInfo>
|
||||
GetServiceWorkerRegistrationInfo(nsPIDOMWindowInner* aWindow);
|
||||
|
@ -81,7 +81,7 @@ ServiceWorkerRegistrationInfo::ServiceWorkerRegistrationInfo(
|
||||
const nsACString& aScope,
|
||||
nsIPrincipal* aPrincipal,
|
||||
ServiceWorkerUpdateViaCache aUpdateViaCache)
|
||||
: mControlledDocumentsCounter(0)
|
||||
: mControlledClientsCounter(0)
|
||||
, mUpdateState(NoUpdate)
|
||||
, mCreationTime(PR_Now())
|
||||
, mCreationTimeStamp(TimeStamp::Now())
|
||||
@ -94,9 +94,7 @@ ServiceWorkerRegistrationInfo::ServiceWorkerRegistrationInfo(
|
||||
|
||||
ServiceWorkerRegistrationInfo::~ServiceWorkerRegistrationInfo()
|
||||
{
|
||||
if (IsControllingDocuments()) {
|
||||
NS_WARNING("ServiceWorkerRegistrationInfo is still controlling documents. This can be a bug or a leak in ServiceWorker API or in any other API that takes the document alive.");
|
||||
}
|
||||
MOZ_DIAGNOSTIC_ASSERT(!IsControllingClients());
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(ServiceWorkerRegistrationInfo, nsIServiceWorkerRegistrationInfo)
|
||||
@ -248,7 +246,7 @@ void
|
||||
ServiceWorkerRegistrationInfo::TryToActivate()
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
bool controlling = IsControllingDocuments();
|
||||
bool controlling = IsControllingClients();
|
||||
bool skipWaiting = mWaitingWorker && mWaitingWorker->SkipWaitingFlag();
|
||||
bool idle = IsIdle();
|
||||
if (idle && (!controlling || skipWaiting)) {
|
||||
|
@ -17,7 +17,7 @@ namespace workers {
|
||||
class ServiceWorkerRegistrationInfo final
|
||||
: public nsIServiceWorkerRegistrationInfo
|
||||
{
|
||||
uint32_t mControlledDocumentsCounter;
|
||||
uint32_t mControlledClientsCounter;
|
||||
|
||||
enum
|
||||
{
|
||||
@ -79,22 +79,22 @@ public:
|
||||
GetServiceWorkerInfoById(uint64_t aId);
|
||||
|
||||
void
|
||||
StartControllingADocument()
|
||||
StartControllingClient()
|
||||
{
|
||||
++mControlledDocumentsCounter;
|
||||
++mControlledClientsCounter;
|
||||
}
|
||||
|
||||
void
|
||||
StopControllingADocument()
|
||||
StopControllingClient()
|
||||
{
|
||||
MOZ_ASSERT(mControlledDocumentsCounter);
|
||||
--mControlledDocumentsCounter;
|
||||
MOZ_ASSERT(mControlledClientsCounter);
|
||||
--mControlledClientsCounter;
|
||||
}
|
||||
|
||||
bool
|
||||
IsControllingDocuments() const
|
||||
IsControllingClients() const
|
||||
{
|
||||
return mActiveWorker && mControlledDocumentsCounter;
|
||||
return mActiveWorker && mControlledClientsCounter;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -138,7 +138,7 @@ ServiceWorkerUnregisterJob::Unregister()
|
||||
InvokeResultCallbacks(NS_OK);
|
||||
|
||||
// "If no service worker client is using registration..."
|
||||
if (!registration->IsControllingDocuments() && registration->IsIdle()) {
|
||||
if (!registration->IsControllingClients() && registration->IsIdle()) {
|
||||
// "Invoke [[Clear Registration]]..."
|
||||
swm->RemoveRegistration(registration);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user