Bug 1462772 P2 Add the registration Id to the ServiceWorkerDescriptor. r=mrbkap

This commit is contained in:
Ben Kelly 2018-07-02 07:44:18 -07:00
Родитель 083c06c238
Коммит 4866ecedf2
9 изменённых файлов: 31 добавлений и 2 удалений

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

@ -15,6 +15,7 @@ namespace dom {
struct IPCServiceWorkerDescriptor
{
uint64_t id;
uint64_t registrationId;
PrincipalInfo principalInfo;
nsCString scope;
nsCString scriptURL;

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

@ -16,6 +16,7 @@ using mozilla::ipc::PrincipalInfo;
using mozilla::ipc::PrincipalInfoToPrincipal;
ServiceWorkerDescriptor::ServiceWorkerDescriptor(uint64_t aId,
uint64_t aRegistrationId,
nsIPrincipal* aPrincipal,
const nsACString& aScope,
const nsACString& aScriptURL,
@ -26,17 +27,20 @@ ServiceWorkerDescriptor::ServiceWorkerDescriptor(uint64_t aId,
PrincipalToPrincipalInfo(aPrincipal, &mData->principalInfo()));
mData->id() = aId;
mData->registrationId() = aRegistrationId;
mData->scope() = aScope;
mData->scriptURL() = aScriptURL;
mData->state() = aState;
}
ServiceWorkerDescriptor::ServiceWorkerDescriptor(uint64_t aId,
uint64_t aRegistrationId,
const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
const nsACString& aScope,
const nsACString& aScriptURL,
ServiceWorkerState aState)
: mData(MakeUnique<IPCServiceWorkerDescriptor>(aId, aPrincipalInfo,
: mData(MakeUnique<IPCServiceWorkerDescriptor>(aId, aRegistrationId,
aPrincipalInfo,
nsCString(aScriptURL),
nsCString(aScope), aState))
{
@ -92,6 +96,12 @@ ServiceWorkerDescriptor::Id() const
return mData->id();
}
uint64_t
ServiceWorkerDescriptor::RegistrationId() const
{
return mData->registrationId();
}
const mozilla::ipc::PrincipalInfo&
ServiceWorkerDescriptor::PrincipalInfo() const
{

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

@ -36,12 +36,14 @@ class ServiceWorkerDescriptor final
public:
ServiceWorkerDescriptor(uint64_t aId,
uint64_t aRegistrationId,
nsIPrincipal* aPrincipal,
const nsACString& aScope,
const nsACString& aScriptURL,
ServiceWorkerState aState);
ServiceWorkerDescriptor(uint64_t aId,
uint64_t aRegistrationId,
const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
const nsACString& aScope,
const nsACString& aScriptURL,
@ -67,6 +69,9 @@ public:
uint64_t
Id() const;
uint64_t
RegistrationId() const;
const mozilla::ipc::PrincipalInfo&
PrincipalInfo() const;

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

@ -181,11 +181,12 @@ ServiceWorkerInfo::UpdateState(ServiceWorkerState aState)
ServiceWorkerInfo::ServiceWorkerInfo(nsIPrincipal* aPrincipal,
const nsACString& aScope,
uint64_t aRegistrationId,
const nsACString& aScriptSpec,
const nsAString& aCacheName,
nsLoadFlags aImportsLoadFlags)
: mPrincipal(aPrincipal)
, mDescriptor(GetNextID(), aPrincipal, aScope, aScriptSpec,
, mDescriptor(GetNextID(), aRegistrationId, aPrincipal, aScope, aScriptSpec,
ServiceWorkerState::Parsed)
, mCacheName(aCacheName)
, mImportsLoadFlags(aImportsLoadFlags)

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

@ -142,6 +142,7 @@ public:
ServiceWorkerInfo(nsIPrincipal* aPrincipal,
const nsACString& aScope,
uint64_t aRegistrationId,
const nsACString& aScriptSpec,
const nsAString& aCacheName,
nsLoadFlags aLoadFlags);

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

@ -1583,6 +1583,7 @@ ServiceWorkerManager::LoadRegistration(
registration->SetActive(
new ServiceWorkerInfo(registration->Principal(),
registration->Scope(),
registration->Id(),
currentWorkerURL,
aRegistration.cacheName(),
importsLoadFlags));

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

@ -729,6 +729,12 @@ ServiceWorkerRegistrationInfo::Descriptor() const
return mDescriptor;
}
uint64_t
ServiceWorkerRegistrationInfo::Id() const
{
return mDescriptor.Id();
}
uint32_t
ServiceWorkerRegistrationInfo::GetUpdateDelay()
{

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

@ -221,6 +221,9 @@ public:
const ServiceWorkerRegistrationDescriptor&
Descriptor() const;
uint64_t
Id() const;
uint32_t
GetUpdateDelay();

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

@ -461,6 +461,7 @@ ServiceWorkerUpdateJob::ComparisonResult(nsresult aStatus,
RefPtr<ServiceWorkerInfo> sw =
new ServiceWorkerInfo(mRegistration->Principal(),
mRegistration->Scope(),
mRegistration->Id(),
mScriptSpec,
aNewCacheName,
flags);