Bug 1286126 - Move ServiceWorker initialization early in the ContentChild startup, r=gabor

This commit is contained in:
Andrea Marchesini 2016-07-13 10:34:24 +02:00
Родитель 1c24a823c1
Коммит d3dcd9a2a2
5 изменённых файлов: 25 добавлений и 29 удалений

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

@ -1032,14 +1032,6 @@ ContentChild::InitXPCOM()
global->SetInitialProcessData(data);
}
// Loading the ServiceWorker configuration.
ServiceWorkerConfiguration configuration;
SendGetServiceWorkerConfiguration(&configuration);
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
MOZ_ASSERT(swm);
swm->LoadRegistrations(configuration.serviceWorkerRegistrations());
InitOnContentProcessCreated();
}
@ -2633,6 +2625,15 @@ ContentChild::RecvAppInit()
return true;
}
bool
ContentChild::RecvInitServiceWorkers(const ServiceWorkerConfiguration& aConfig)
{
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
MOZ_ASSERT(swm);
swm->LoadRegistrations(aConfig.serviceWorkerRegistrations());
return true;
}
bool
ContentChild::RecvLastPrivateDocShellDestroyed()
{

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

@ -457,6 +457,9 @@ public:
virtual bool RecvAppInit() override;
virtual bool
RecvInitServiceWorkers(const ServiceWorkerConfiguration& aConfig) override;
virtual bool RecvLastPrivateDocShellDestroyed() override;
virtual bool RecvVolumes(InfallibleTArray<VolumeInfo>&& aVolumes) override;

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

@ -2511,6 +2511,14 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
Unused << SendSetAudioSessionData(id, sessionName, iconPath);
}
#endif
RefPtr<ServiceWorkerRegistrar> swr = ServiceWorkerRegistrar::Get();
MOZ_ASSERT(swr);
nsTArray<ServiceWorkerRegistrationData> registrations;
swr->GetRegistrations(registrations);
Unused << SendInitServiceWorkers(ServiceWorkerConfiguration(registrations));
}
bool
@ -5503,18 +5511,6 @@ ContentParent::PermissionManagerRelease(const ContentParentId& aCpId,
return false;
}
bool
ContentParent::RecvGetServiceWorkerConfiguration(ServiceWorkerConfiguration* aConfig)
{
MOZ_ASSERT(XRE_IsParentProcess());
RefPtr<ServiceWorkerRegistrar> swr = ServiceWorkerRegistrar::Get();
MOZ_ASSERT(swr);
swr->GetRegistrations(aConfig->serviceWorkerRegistrations());
return true;
}
bool
ContentParent::RecvProfile(const nsCString& aProfile)
{

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

@ -1135,9 +1135,6 @@ private:
virtual bool RecvUpdateDropEffect(const uint32_t& aDragAction,
const uint32_t& aDropEffect) override;
virtual bool
RecvGetServiceWorkerConfiguration(ServiceWorkerConfiguration* aConfig) override;
virtual bool RecvProfile(const nsCString& aProfile) override;
virtual bool RecvGetGraphicsDeviceInitData(DeviceInitData* aOut) override;

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

@ -526,6 +526,11 @@ child:
nsCString ID, nsCString vendor);
async AppInit();
/**
* Send ServiceWorkerRegistrationData to child process.
*/
async InitServiceWorkers(ServiceWorkerConfiguration aConfig);
// Notify child that last-pb-context-exited notification was observed
async LastPrivateDocShellDestroyed();
@ -1084,12 +1089,6 @@ parent:
async PContentPermissionRequest(PermissionRequest[] aRequests, Principal aPrincipal,
TabId tabId);
/**
* Send ServiceWorkerRegistrationData to child process.
*/
sync GetServiceWorkerConfiguration()
returns (ServiceWorkerConfiguration aConfig);
async Profile(nsCString aProfile);
/**