зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1433505
P3 Make ServiceWorkerRegistrationInfo use ServiceWorkerRegistrationDescriptor internally. r=asuth
This commit is contained in:
Родитель
84065537b6
Коммит
0d6f124415
|
@ -78,6 +78,8 @@ ServiceWorkerRegistrationInfo::Clear()
|
|||
mActiveWorker = nullptr;
|
||||
}
|
||||
|
||||
mDescriptor.SetWorkers(mInstallingWorker, mWaitingWorker, mActiveWorker);
|
||||
|
||||
NotifyChromeRegistrationListeners();
|
||||
}
|
||||
|
||||
|
@ -85,14 +87,13 @@ ServiceWorkerRegistrationInfo::ServiceWorkerRegistrationInfo(
|
|||
const nsACString& aScope,
|
||||
nsIPrincipal* aPrincipal,
|
||||
ServiceWorkerUpdateViaCache aUpdateViaCache)
|
||||
: mScope(aScope)
|
||||
, mPrincipal(aPrincipal)
|
||||
: mPrincipal(aPrincipal)
|
||||
, mDescriptor(aPrincipal, aScope, aUpdateViaCache)
|
||||
, mControlledClientsCounter(0)
|
||||
, mUpdateState(NoUpdate)
|
||||
, mCreationTime(PR_Now())
|
||||
, mCreationTimeStamp(TimeStamp::Now())
|
||||
, mLastUpdateTime(0)
|
||||
, mUpdateViaCache(aUpdateViaCache)
|
||||
, mPendingUninstall(false)
|
||||
{}
|
||||
|
||||
|
@ -104,7 +105,7 @@ ServiceWorkerRegistrationInfo::~ServiceWorkerRegistrationInfo()
|
|||
const nsCString&
|
||||
ServiceWorkerRegistrationInfo::Scope() const
|
||||
{
|
||||
return mScope;
|
||||
return mDescriptor.Scope();
|
||||
}
|
||||
|
||||
nsIPrincipal*
|
||||
|
@ -145,7 +146,7 @@ NS_IMETHODIMP
|
|||
ServiceWorkerRegistrationInfo::GetScope(nsAString& aScope)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
CopyUTF8toUTF16(mScope, aScope);
|
||||
CopyUTF8toUTF16(Scope(), aScope);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -341,6 +342,9 @@ ServiceWorkerRegistrationInfo::FinishActivate(bool aSuccess)
|
|||
// Activation never fails, so aSuccess is ignored.
|
||||
mActiveWorker->UpdateState(ServiceWorkerState::Activated);
|
||||
mActiveWorker->UpdateActivatedTime();
|
||||
|
||||
mDescriptor.SetWorkers(mInstallingWorker, mWaitingWorker, mActiveWorker);
|
||||
|
||||
NotifyChromeRegistrationListeners();
|
||||
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
|
@ -450,7 +454,7 @@ ServiceWorkerRegistrationInfo::MaybeScheduleTimeCheckAndUpdate()
|
|||
mUpdateState = NeedTimeCheckAndUpdate;
|
||||
}
|
||||
|
||||
swm->ScheduleUpdateTimer(mPrincipal, mScope);
|
||||
swm->ScheduleUpdateTimer(mPrincipal, Scope());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -466,7 +470,7 @@ ServiceWorkerRegistrationInfo::MaybeScheduleUpdate()
|
|||
|
||||
mUpdateState = NeedUpdate;
|
||||
|
||||
swm->ScheduleUpdateTimer(mPrincipal, mScope);
|
||||
swm->ScheduleUpdateTimer(mPrincipal, Scope());
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -572,6 +576,8 @@ ServiceWorkerRegistrationInfo::ClearInstalling()
|
|||
mInstallingWorker->UpdateRedundantTime();
|
||||
mInstallingWorker = nullptr;
|
||||
|
||||
mDescriptor.SetWorkers(mInstallingWorker, mWaitingWorker, mActiveWorker);
|
||||
|
||||
NotifyChromeRegistrationListeners();
|
||||
}
|
||||
|
||||
|
@ -584,6 +590,9 @@ ServiceWorkerRegistrationInfo::TransitionEvaluatingToInstalling()
|
|||
|
||||
mInstallingWorker = mEvaluatingWorker.forget();
|
||||
mInstallingWorker->UpdateState(ServiceWorkerState::Installing);
|
||||
|
||||
mDescriptor.SetWorkers(mInstallingWorker, mWaitingWorker, mActiveWorker);
|
||||
|
||||
NotifyChromeRegistrationListeners();
|
||||
}
|
||||
|
||||
|
@ -604,6 +613,9 @@ ServiceWorkerRegistrationInfo::TransitionInstallingToWaiting()
|
|||
TransitionToNextState);
|
||||
mWaitingWorker->UpdateState(ServiceWorkerState::Installed);
|
||||
mWaitingWorker->UpdateInstalledTime();
|
||||
|
||||
mDescriptor.SetWorkers(mInstallingWorker, mWaitingWorker, mActiveWorker);
|
||||
|
||||
NotifyChromeRegistrationListeners();
|
||||
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
|
@ -642,6 +654,9 @@ ServiceWorkerRegistrationInfo::SetActive(ServiceWorkerInfo* aServiceWorker)
|
|||
// We don't need to update activated time when we load registration from
|
||||
// registrar.
|
||||
UpdateRegistrationStateProperties(WhichServiceWorker::ACTIVE_WORKER, Invalidate);
|
||||
|
||||
mDescriptor.SetWorkers(mInstallingWorker, mWaitingWorker, mActiveWorker);
|
||||
|
||||
NotifyChromeRegistrationListeners();
|
||||
}
|
||||
|
||||
|
@ -663,6 +678,9 @@ ServiceWorkerRegistrationInfo::TransitionWaitingToActive()
|
|||
UpdateRegistrationStateProperties(WhichServiceWorker::WAITING_WORKER,
|
||||
TransitionToNextState);
|
||||
mActiveWorker->UpdateState(ServiceWorkerState::Activating);
|
||||
|
||||
mDescriptor.SetWorkers(mInstallingWorker, mWaitingWorker, mActiveWorker);
|
||||
|
||||
NotifyChromeRegistrationListeners();
|
||||
}
|
||||
|
||||
|
@ -675,14 +693,14 @@ ServiceWorkerRegistrationInfo::IsIdle() const
|
|||
ServiceWorkerUpdateViaCache
|
||||
ServiceWorkerRegistrationInfo::GetUpdateViaCache() const
|
||||
{
|
||||
return mUpdateViaCache;
|
||||
return mDescriptor.UpdateViaCache();
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorkerRegistrationInfo::SetUpdateViaCache(
|
||||
ServiceWorkerUpdateViaCache aUpdateViaCache)
|
||||
{
|
||||
mUpdateViaCache = aUpdateViaCache;
|
||||
mDescriptor.SetUpdateViaCache(aUpdateViaCache);
|
||||
}
|
||||
|
||||
int64_t
|
||||
|
@ -701,5 +719,11 @@ ServiceWorkerRegistrationInfo::SetLastUpdateTime(const int64_t aTime)
|
|||
mLastUpdateTime = aTime;
|
||||
}
|
||||
|
||||
const ServiceWorkerRegistrationDescriptor&
|
||||
ServiceWorkerRegistrationInfo::Descriptor() const
|
||||
{
|
||||
return mDescriptor;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "mozilla/dom/ServiceWorkerInfo.h"
|
||||
#include "mozilla/dom/ServiceWorkerCommon.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrationBinding.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h"
|
||||
#include "nsProxyRelease.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -18,8 +19,8 @@ namespace dom {
|
|||
class ServiceWorkerRegistrationInfo final
|
||||
: public nsIServiceWorkerRegistrationInfo
|
||||
{
|
||||
const nsCString mScope;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
ServiceWorkerRegistrationDescriptor mDescriptor;
|
||||
nsTArray<nsCOMPtr<nsIServiceWorkerRegistrationInfoListener>> mListeners;
|
||||
|
||||
uint32_t mControlledClientsCounter;
|
||||
|
@ -37,8 +38,6 @@ class ServiceWorkerRegistrationInfo final
|
|||
// The time of update is 0, if SWR've never been updated yet.
|
||||
PRTime mLastUpdateTime;
|
||||
|
||||
ServiceWorkerUpdateViaCache mUpdateViaCache;
|
||||
|
||||
RefPtr<ServiceWorkerInfo> mEvaluatingWorker;
|
||||
RefPtr<ServiceWorkerInfo> mActiveWorker;
|
||||
RefPtr<ServiceWorkerInfo> mWaitingWorker;
|
||||
|
@ -210,6 +209,9 @@ public:
|
|||
void
|
||||
SetLastUpdateTime(const int64_t aTime);
|
||||
|
||||
const ServiceWorkerRegistrationDescriptor&
|
||||
Descriptor() const;
|
||||
|
||||
private:
|
||||
enum TransitionType {
|
||||
TransitionToNextState = 0,
|
||||
|
|
Загрузка…
Ссылка в новой задаче