/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis *file,Youcanobtainoneathttp://mozilla.org/MPL/2.0/. */
voidServiceWorkerInfo::UpdateState(ServiceWorkerStateaState){ MOZ_ASSERT(NS_IsMainThread()); #ifdefDEBUG // Any state can directly transition to redundant, but everything else is // ordered. if(aState!=ServiceWorkerState::Redundant){ MOZ_ASSERT_IF(State()==ServiceWorkerState::Installing, aState==ServiceWorkerState::Installed); MOZ_ASSERT_IF(State()==ServiceWorkerState::Installed, aState==ServiceWorkerState::Activating); MOZ_ASSERT_IF(State()==ServiceWorkerState::Activating, aState==ServiceWorkerState::Activated); } // Activated can only go to redundant. MOZ_ASSERT_IF(State()==ServiceWorkerState::Activated, aState==ServiceWorkerState::Redundant); #endif // Flush any pending functional events to the worker when it transitions to // the activated state. // TODO: Do we care that these events will race with the propagation of the // state change? if(State()!=aState){ mServiceWorkerPrivate->UpdateState(aState); } mDescriptor.SetState(aState); if(State()==ServiceWorkerState::Redundant){ serviceWorkerScriptCache::PurgeCache(mPrincipal,mCacheName); mServiceWorkerPrivate->NoteDeadServiceWorkerInfo(); } }
ServiceWorkerInfo::ServiceWorkerInfo( nsIPrincipal*aPrincipal,constnsACString&aScope,constWorkerType&aType, uint64_taRegistrationId,uint64_taRegistrationVersion, constnsACString&aScriptSpec,constnsAString&aCacheName, nsLoadFlagsaImportsLoadFlags) :mPrincipal(aPrincipal), mDescriptor(GetNextID(),aRegistrationId,aRegistrationVersion, aPrincipal,aScope,aType,aScriptSpec, ServiceWorkerState::Parsed), mCacheName(aCacheName), mWorkerPrivateId(ComputeWorkerPrivateId()), mImportsLoadFlags(aImportsLoadFlags), mCreationTime(PR_Now()), mCreationTimeStamp(TimeStamp::Now()), mInstalledTime(0), mActivatedTime(0), mRedundantTime(0), mServiceWorkerPrivate(newServiceWorkerPrivate(this)), mSkipWaitingFlag(false), mHandlesFetch(Unknown), mNavigationFaultCount(0), mTestingInjectCancellation(NS_OK){ MOZ_ASSERT(XRE_GetProcessType()==GeckoProcessType_Default); MOZ_ASSERT(mPrincipal); // cache origin attributes so we can use them off main thread mOriginAttributes=mPrincipal->OriginAttributesRef(); MOZ_ASSERT(!mDescriptor.ScriptURL().IsEmpty()); MOZ_ASSERT(!mCacheName.IsEmpty()); MOZ_ASSERT(!mWorkerPrivateId.IsEmpty());
// Scripts of a service worker should always be loaded bypass service workers. // Otherwise, we might not be able to update a service worker correctly, if // there is a service worker generating the script. MOZ_DIAGNOSTIC_ASSERT(mImportsLoadFlags& nsIChannel::LOAD_BYPASS_SERVICE_WORKER); }
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.28Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.