зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-central to autoland. a=merge on a CLOSED TREE
This commit is contained in:
Коммит
76c870f876
|
@ -21,7 +21,6 @@ struct IPCServiceWorkerDescriptor
|
|||
nsCString scope;
|
||||
nsCString scriptURL;
|
||||
ServiceWorkerState state;
|
||||
bool handlesFetch;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -29,8 +29,6 @@ ServiceWorkerDescriptor::ServiceWorkerDescriptor(
|
|||
mData->scope() = aScope;
|
||||
mData->scriptURL() = aScriptURL;
|
||||
mData->state() = aState;
|
||||
// Set HandlesFetch as true in default
|
||||
mData->handlesFetch() = true;
|
||||
}
|
||||
|
||||
ServiceWorkerDescriptor::ServiceWorkerDescriptor(
|
||||
|
@ -39,7 +37,7 @@ ServiceWorkerDescriptor::ServiceWorkerDescriptor(
|
|||
const nsACString& aScriptURL, ServiceWorkerState aState)
|
||||
: mData(MakeUnique<IPCServiceWorkerDescriptor>(
|
||||
aId, aRegistrationId, aRegistrationVersion, aPrincipalInfo,
|
||||
nsCString(aScriptURL), nsCString(aScope), aState, true)) {}
|
||||
nsCString(aScriptURL), nsCString(aScope), aState)) {}
|
||||
|
||||
ServiceWorkerDescriptor::ServiceWorkerDescriptor(
|
||||
const IPCServiceWorkerDescriptor& aDescriptor)
|
||||
|
@ -120,14 +118,6 @@ void ServiceWorkerDescriptor::SetRegistrationVersion(uint64_t aVersion) {
|
|||
mData->registrationVersion() = aVersion;
|
||||
}
|
||||
|
||||
bool ServiceWorkerDescriptor::HandlesFetch() const {
|
||||
return mData->handlesFetch();
|
||||
}
|
||||
|
||||
void ServiceWorkerDescriptor::SetHandlesFetch(bool aHandlesFetch) {
|
||||
mData->handlesFetch() = aHandlesFetch;
|
||||
}
|
||||
|
||||
bool ServiceWorkerDescriptor::Matches(
|
||||
const ServiceWorkerDescriptor& aDescriptor) const {
|
||||
return Id() == aDescriptor.Id() && Scope() == aDescriptor.Scope() &&
|
||||
|
|
|
@ -82,10 +82,6 @@ class ServiceWorkerDescriptor final {
|
|||
|
||||
void SetRegistrationVersion(uint64_t aVersion);
|
||||
|
||||
bool HandlesFetch() const;
|
||||
|
||||
void SetHandlesFetch(bool aHandlesFetch);
|
||||
|
||||
// Try to determine if two workers match each other. This is less strict
|
||||
// than an operator==() call since it ignores mutable values like State().
|
||||
bool Matches(const ServiceWorkerDescriptor& aDescriptor) const;
|
||||
|
|
|
@ -126,7 +126,6 @@ class ServiceWorkerInfo final : public nsIServiceWorkerInfo {
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_DIAGNOSTIC_ASSERT(mHandlesFetch == Unknown);
|
||||
mHandlesFetch = aHandlesFetch ? Enabled : Disabled;
|
||||
mDescriptor.SetHandlesFetch(aHandlesFetch);
|
||||
}
|
||||
|
||||
void SetRegistrationVersion(uint64_t aVersion);
|
||||
|
|
|
@ -25,8 +25,6 @@ ServiceWorkerInterceptController::ShouldPrepareForIntercept(
|
|||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
||||
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
|
||||
// For subresource requests we base our decision solely on the client's
|
||||
// controller value. Any settings that would have blocked service worker
|
||||
// access should have been set before the initial navigation created the
|
||||
|
@ -34,30 +32,7 @@ ServiceWorkerInterceptController::ShouldPrepareForIntercept(
|
|||
if (!nsContentUtils::IsNonSubresourceRequest(aChannel)) {
|
||||
const Maybe<ServiceWorkerDescriptor>& controller =
|
||||
loadInfo->GetController();
|
||||
// For child intercept, only checking the loadInfo controller existence.
|
||||
if (!ServiceWorkerParentInterceptEnabled()) {
|
||||
*aShouldIntercept = controller.isSome();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If the controller doesn't handle fetch events, return false
|
||||
if (controller.isSome()) {
|
||||
*aShouldIntercept = controller.ref().HandlesFetch();
|
||||
|
||||
// The service worker has no fetch event handler, try to schedule a
|
||||
// soft-update through ServiceWorkerRegistrationInfo.
|
||||
// Get ServiceWorkerRegistrationInfo by the ServiceWorkerInfo's principal
|
||||
// and scope
|
||||
if (!*aShouldIntercept && swm) {
|
||||
RefPtr<ServiceWorkerRegistrationInfo> registration =
|
||||
swm->GetRegistration(controller.ref().GetPrincipal().get(),
|
||||
controller.ref().Scope());
|
||||
MOZ_ASSERT(registration);
|
||||
registration->MaybeScheduleTimeCheckAndUpdate();
|
||||
}
|
||||
} else {
|
||||
*aShouldIntercept = false;
|
||||
}
|
||||
*aShouldIntercept = controller.isSome();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -65,7 +40,8 @@ ServiceWorkerInterceptController::ShouldPrepareForIntercept(
|
|||
aURI, loadInfo->GetOriginAttributes());
|
||||
|
||||
// First check with the ServiceWorkerManager for a matching service worker.
|
||||
if (!swm || !swm->IsAvailable(principal, aURI, aChannel)) {
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
if (!swm || !swm->IsAvailable(principal, aURI)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -2313,59 +2313,13 @@ void ServiceWorkerManager::DispatchFetchEvent(nsIInterceptedChannel* aChannel,
|
|||
aRv = uploadChannel->EnsureUploadStreamIsCloneable(permissionsRunnable);
|
||||
}
|
||||
|
||||
bool ServiceWorkerManager::IsAvailable(nsIPrincipal* aPrincipal, nsIURI* aURI,
|
||||
nsIChannel* aChannel) {
|
||||
bool ServiceWorkerManager::IsAvailable(nsIPrincipal* aPrincipal, nsIURI* aURI) {
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
MOZ_ASSERT(aURI);
|
||||
MOZ_ASSERT(aChannel);
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationInfo> registration =
|
||||
GetServiceWorkerRegistrationInfo(aPrincipal, aURI);
|
||||
|
||||
// For child interception, just check the availability.
|
||||
if (!ServiceWorkerParentInterceptEnabled()) {
|
||||
return registration && registration->GetActive();
|
||||
}
|
||||
|
||||
if (!registration || !registration->GetActive()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Checking if the matched service worker handles fetch events or not.
|
||||
// If it does, directly return true and handle the client controlling logic
|
||||
// in DispatchFetchEvent(). otherwise, do followings then return false.
|
||||
// 1. Set the matched service worker as the controller of LoadInfo and
|
||||
// correspoinding ClinetInfo
|
||||
// 2. Maybe schedule a soft update
|
||||
if (!registration->GetActive()->HandlesFetch()) {
|
||||
// Checkin if the channel is not storage allowed first.
|
||||
if (StorageAllowedForChannel(aChannel) != StorageAccess::eAllow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ServiceWorkerInterceptController::ShouldPrepareForIntercept() handles the
|
||||
// subresource cases. Must be non-subresource case here.
|
||||
MOZ_ASSERT(nsContentUtils::IsNonSubresourceRequest(aChannel));
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
||||
|
||||
Maybe<ClientInfo> clientInfo = loadInfo->GetReservedClientInfo();
|
||||
if (clientInfo.isNothing()) {
|
||||
clientInfo = loadInfo->GetInitialClientInfo();
|
||||
}
|
||||
|
||||
if (clientInfo.isSome()) {
|
||||
StartControllingClient(clientInfo.ref(), registration);
|
||||
}
|
||||
loadInfo->SetController(registration->GetActive()->Descriptor());
|
||||
|
||||
// https://w3c.github.io/ServiceWorker/#on-fetch-request-algorithm 17.1
|
||||
// try schedule a soft-update for non-subresource case.
|
||||
registration->MaybeScheduleTimeCheckAndUpdate();
|
||||
return false;
|
||||
}
|
||||
// Found a matching service worker which handles fetch events, return true.
|
||||
return true;
|
||||
return registration && registration->GetActive();
|
||||
}
|
||||
|
||||
nsresult ServiceWorkerManager::GetClientRegistration(
|
||||
|
|
|
@ -116,14 +116,7 @@ class ServiceWorkerManager final : public nsIServiceWorkerManager,
|
|||
NS_DECL_NSISERVICEWORKERMANAGER
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
// Return true if the given principal and URI matches a registered service
|
||||
// worker which handles fetch event.
|
||||
// If there is a matched service worker but doesn't handle fetch events, this
|
||||
// method will try to set the matched service worker as the controller of the
|
||||
// passed in channel. Then also schedule a soft-update job for the service
|
||||
// worker.
|
||||
bool IsAvailable(nsIPrincipal* aPrincipal, nsIURI* aURI,
|
||||
nsIChannel* aChannel);
|
||||
bool IsAvailable(nsIPrincipal* aPrincipal, nsIURI* aURI);
|
||||
|
||||
// Return true if the given content process could potentially be executing
|
||||
// service worker code with the given principal. At the current time, this
|
||||
|
|
Загрузка…
Ссылка в новой задаче