Backed out changeset b7653e3d5f91 (bug 1174381) for widespread assertion failures.

This commit is contained in:
Ryan VanderMeulen 2015-06-21 07:47:02 -04:00
Родитель fa7eeb2ade
Коммит 926e7b839f
2 изменённых файлов: 16 добавлений и 38 удалений

Просмотреть файл

@ -379,7 +379,6 @@ NS_INTERFACE_MAP_END
ServiceWorkerManager::ServiceWorkerManager() ServiceWorkerManager::ServiceWorkerManager()
: mActor(nullptr) : mActor(nullptr)
, mShuttingDown(false)
{ {
// Register this component to PBackground. // Register this component to PBackground.
MOZ_ALWAYS_TRUE(BackgroundChild::GetOrCreateForCurrentThread(this)); MOZ_ALWAYS_TRUE(BackgroundChild::GetOrCreateForCurrentThread(this));
@ -389,7 +388,14 @@ ServiceWorkerManager::~ServiceWorkerManager()
{ {
// The map will assert if it is not empty when destroyed. // The map will assert if it is not empty when destroyed.
mRegistrationInfos.Clear(); mRegistrationInfos.Clear();
MOZ_ASSERT(!mActor);
if (mActor) {
mActor->ManagerShuttingDown();
nsRefPtr<TeardownRunnable> runnable = new TeardownRunnable(mActor);
nsresult rv = NS_DispatchToMainThread(runnable);
unused << NS_WARN_IF(NS_FAILED(rv));
}
} }
void void
@ -1547,12 +1553,10 @@ ServiceWorkerManager::AppendPendingOperation(ServiceWorkerJobQueue* aQueue,
MOZ_ASSERT(aQueue); MOZ_ASSERT(aQueue);
MOZ_ASSERT(aJob); MOZ_ASSERT(aJob);
if (!mShuttingDown) {
PendingOperation* opt = mPendingOperations.AppendElement(); PendingOperation* opt = mPendingOperations.AppendElement();
opt->mQueue = aQueue; opt->mQueue = aQueue;
opt->mJob = aJob; opt->mJob = aJob;
} }
}
void void
ServiceWorkerManager::AppendPendingOperation(nsIRunnable* aRunnable) ServiceWorkerManager::AppendPendingOperation(nsIRunnable* aRunnable)
@ -1560,11 +1564,9 @@ ServiceWorkerManager::AppendPendingOperation(nsIRunnable* aRunnable)
MOZ_ASSERT(!mActor); MOZ_ASSERT(!mActor);
MOZ_ASSERT(aRunnable); MOZ_ASSERT(aRunnable);
if (!mShuttingDown) {
PendingOperation* opt = mPendingOperations.AppendElement(); PendingOperation* opt = mPendingOperations.AppendElement();
opt->mRunnable = aRunnable; opt->mRunnable = aRunnable;
} }
}
/* /*
* Used to handle ExtendableEvent::waitUntil() and proceed with * Used to handle ExtendableEvent::waitUntil() and proceed with
@ -2381,10 +2383,8 @@ private:
nsRefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance(); nsRefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
// We could be shutting down. MOZ_ASSERT(swm->mActor);
if (swm->mActor) {
swm->mActor->SendUnregister(principalInfo, NS_ConvertUTF8toUTF16(mScope)); swm->mActor->SendUnregister(principalInfo, NS_ConvertUTF8toUTF16(mScope));
}
nsAutoCString scopeKey; nsAutoCString scopeKey;
nsresult rv = swm->PrincipalToScopeKey(mPrincipal, scopeKey); nsresult rv = swm->PrincipalToScopeKey(mPrincipal, scopeKey);
@ -2735,15 +2735,10 @@ ServiceWorkerManager::StoreRegistration(
nsIPrincipal* aPrincipal, nsIPrincipal* aPrincipal,
ServiceWorkerRegistrationInfo* aRegistration) ServiceWorkerRegistrationInfo* aRegistration)
{ {
MOZ_ASSERT(mActor);
MOZ_ASSERT(aPrincipal); MOZ_ASSERT(aPrincipal);
MOZ_ASSERT(aRegistration); MOZ_ASSERT(aRegistration);
if (mShuttingDown) {
return;
}
MOZ_ASSERT(mActor);
ServiceWorkerRegistrationData data; ServiceWorkerRegistrationData data;
nsresult rv = PopulateRegistrationData(aPrincipal, aRegistration, data); nsresult rv = PopulateRegistrationData(aPrincipal, aRegistration, data);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
@ -4069,10 +4064,6 @@ ServiceWorkerManager::RemoveRegistrationInternal(ServiceWorkerRegistrationInfo*
MOZ_ASSERT(aRegistration); MOZ_ASSERT(aRegistration);
MOZ_ASSERT(!aRegistration->IsControllingDocuments()); MOZ_ASSERT(!aRegistration->IsControllingDocuments());
if (mShuttingDown) {
return;
}
// All callers should be either from a job in which case the actor is // All callers should be either from a job in which case the actor is
// available, or from MaybeStopControlling(), in which case, this will only be // available, or from MaybeStopControlling(), in which case, this will only be
// called if a valid registration is found. If a valid registration exists, // called if a valid registration is found. If a valid registration exists,
@ -4551,8 +4542,6 @@ ServiceWorkerManager::Observe(nsISupports* aSubject,
RemoveAllRegistrations(principal); RemoveAllRegistrations(principal);
} else if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) { } else if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
mShuttingDown = true;
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) { if (obs) {
obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID); obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
@ -4560,15 +4549,6 @@ ServiceWorkerManager::Observe(nsISupports* aSubject,
obs->RemoveObserver(this, PURGE_DOMAIN_DATA); obs->RemoveObserver(this, PURGE_DOMAIN_DATA);
obs->RemoveObserver(this, WEBAPPS_CLEAR_DATA); obs->RemoveObserver(this, WEBAPPS_CLEAR_DATA);
} }
if (mActor) {
mActor->ManagerShuttingDown();
nsRefPtr<TeardownRunnable> runnable = new TeardownRunnable(mActor);
nsresult rv = NS_DispatchToMainThread(runnable);
unused << NS_WARN_IF(NS_FAILED(rv));
mActor = nullptr;
}
} else { } else {
MOZ_CRASH("Received message we aren't supposed to be registered for!"); MOZ_CRASH("Received message we aren't supposed to be registered for!");
} }

Просмотреть файл

@ -552,8 +552,6 @@ private:
struct PendingOperation; struct PendingOperation;
nsTArray<PendingOperation> mPendingOperations; nsTArray<PendingOperation> mPendingOperations;
bool mShuttingDown;
}; };
} // namespace workers } // namespace workers