2016-04-09 03:28:25 +03:00
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2.0 . If a copy of the MPL was not distributed with this
* file , You can obtain one at http : //mozilla.org/MPL/2.0/. */
# include "ServiceWorkerRegistrationInfo.h"
BEGIN_WORKERS_NAMESPACE
2016-04-29 04:01:22 +03:00
namespace {
class ContinueActivateRunnable final : public LifeCycleEventCallback
{
nsMainThreadPtrHandle < ServiceWorkerRegistrationInfo > mRegistration ;
bool mSuccess ;
public :
explicit ContinueActivateRunnable ( const nsMainThreadPtrHandle < ServiceWorkerRegistrationInfo > & aRegistration )
: mRegistration ( aRegistration )
, mSuccess ( false )
{
AssertIsOnMainThread ( ) ;
}
void
SetResult ( bool aResult ) override
{
mSuccess = aResult ;
}
NS_IMETHOD
Run ( ) override
{
AssertIsOnMainThread ( ) ;
mRegistration - > FinishActivate ( mSuccess ) ;
mRegistration = nullptr ;
return NS_OK ;
}
} ;
} // anonymous namespace
2016-04-09 03:28:25 +03:00
void
ServiceWorkerRegistrationInfo : : Clear ( )
{
2016-07-28 02:09:15 +03:00
if ( mEvaluatingWorker ) {
mEvaluatingWorker = nullptr ;
}
2016-11-21 05:14:54 +03:00
UpdateRegistrationStateProperties ( WhichServiceWorker : : INSTALLING_WORKER |
WhichServiceWorker : : WAITING_WORKER |
WhichServiceWorker : : ACTIVE_WORKER , Invalidate ) ;
2016-04-09 03:28:25 +03:00
if ( mInstallingWorker ) {
mInstallingWorker - > UpdateState ( ServiceWorkerState : : Redundant ) ;
mInstallingWorker - > WorkerPrivate ( ) - > NoteDeadServiceWorkerInfo ( ) ;
mInstallingWorker = nullptr ;
// FIXME(nsm): Abort any inflight requests from installing worker.
}
if ( mWaitingWorker ) {
mWaitingWorker - > UpdateState ( ServiceWorkerState : : Redundant ) ;
mWaitingWorker - > WorkerPrivate ( ) - > NoteDeadServiceWorkerInfo ( ) ;
mWaitingWorker = nullptr ;
}
if ( mActiveWorker ) {
mActiveWorker - > UpdateState ( ServiceWorkerState : : Redundant ) ;
mActiveWorker - > WorkerPrivate ( ) - > NoteDeadServiceWorkerInfo ( ) ;
mActiveWorker = nullptr ;
}
2017-03-22 06:39:06 +03:00
NotifyChromeRegistrationListeners ( ) ;
2016-04-09 03:28:25 +03:00
}
ServiceWorkerRegistrationInfo : : ServiceWorkerRegistrationInfo ( const nsACString & aScope ,
2017-01-04 12:08:43 +03:00
nsIPrincipal * aPrincipal ,
nsLoadFlags aLoadFlags )
2016-04-09 03:28:25 +03:00
: mControlledDocumentsCounter ( 0 )
, mUpdateState ( NoUpdate )
, mLastUpdateCheckTime ( 0 )
2017-01-04 12:08:43 +03:00
, mLoadFlags ( aLoadFlags )
2016-04-09 03:28:25 +03:00
, mScope ( aScope )
, mPrincipal ( aPrincipal )
, mPendingUninstall ( false )
{ }
ServiceWorkerRegistrationInfo : : ~ ServiceWorkerRegistrationInfo ( )
{
if ( IsControllingDocuments ( ) ) {
NS_WARNING ( " ServiceWorkerRegistrationInfo is still controlling documents. This can be a bug or a leak in ServiceWorker API or in any other API that takes the document alive. " ) ;
}
}
NS_IMPL_ISUPPORTS ( ServiceWorkerRegistrationInfo , nsIServiceWorkerRegistrationInfo )
NS_IMETHODIMP
ServiceWorkerRegistrationInfo : : GetPrincipal ( nsIPrincipal * * aPrincipal )
{
AssertIsOnMainThread ( ) ;
NS_ADDREF ( * aPrincipal = mPrincipal ) ;
return NS_OK ;
}
NS_IMETHODIMP
ServiceWorkerRegistrationInfo : : GetScope ( nsAString & aScope )
{
AssertIsOnMainThread ( ) ;
CopyUTF8toUTF16 ( mScope , aScope ) ;
return NS_OK ;
}
NS_IMETHODIMP
ServiceWorkerRegistrationInfo : : GetScriptSpec ( nsAString & aScriptSpec )
{
AssertIsOnMainThread ( ) ;
RefPtr < ServiceWorkerInfo > newest = Newest ( ) ;
if ( newest ) {
CopyUTF8toUTF16 ( newest - > ScriptSpec ( ) , aScriptSpec ) ;
}
return NS_OK ;
}
NS_IMETHODIMP
ServiceWorkerRegistrationInfo : : GetInstallingWorker ( nsIServiceWorkerInfo * * aResult )
{
AssertIsOnMainThread ( ) ;
nsCOMPtr < nsIServiceWorkerInfo > info = do_QueryInterface ( mInstallingWorker ) ;
info . forget ( aResult ) ;
return NS_OK ;
}
NS_IMETHODIMP
ServiceWorkerRegistrationInfo : : GetWaitingWorker ( nsIServiceWorkerInfo * * aResult )
{
AssertIsOnMainThread ( ) ;
nsCOMPtr < nsIServiceWorkerInfo > info = do_QueryInterface ( mWaitingWorker ) ;
info . forget ( aResult ) ;
return NS_OK ;
}
NS_IMETHODIMP
ServiceWorkerRegistrationInfo : : GetActiveWorker ( nsIServiceWorkerInfo * * aResult )
{
AssertIsOnMainThread ( ) ;
nsCOMPtr < nsIServiceWorkerInfo > info = do_QueryInterface ( mActiveWorker ) ;
info . forget ( aResult ) ;
return NS_OK ;
}
NS_IMETHODIMP
ServiceWorkerRegistrationInfo : : GetWorkerByID ( uint64_t aID , nsIServiceWorkerInfo * * aResult )
{
AssertIsOnMainThread ( ) ;
MOZ_ASSERT ( aResult ) ;
RefPtr < ServiceWorkerInfo > info = GetServiceWorkerInfoById ( aID ) ;
// It is ok to return null for a missing service worker info.
info . forget ( aResult ) ;
return NS_OK ;
}
NS_IMETHODIMP
ServiceWorkerRegistrationInfo : : AddListener (
nsIServiceWorkerRegistrationInfoListener * aListener )
{
AssertIsOnMainThread ( ) ;
if ( ! aListener | | mListeners . Contains ( aListener ) ) {
return NS_ERROR_INVALID_ARG ;
}
mListeners . AppendElement ( aListener ) ;
return NS_OK ;
}
NS_IMETHODIMP
ServiceWorkerRegistrationInfo : : RemoveListener (
nsIServiceWorkerRegistrationInfoListener * aListener )
{
AssertIsOnMainThread ( ) ;
if ( ! aListener | | ! mListeners . Contains ( aListener ) ) {
return NS_ERROR_INVALID_ARG ;
}
mListeners . RemoveElement ( aListener ) ;
return NS_OK ;
}
already_AddRefed < ServiceWorkerInfo >
ServiceWorkerRegistrationInfo : : GetServiceWorkerInfoById ( uint64_t aId )
{
2016-07-28 02:09:15 +03:00
AssertIsOnMainThread ( ) ;
2016-04-09 03:28:25 +03:00
RefPtr < ServiceWorkerInfo > serviceWorker ;
2016-07-28 02:09:15 +03:00
if ( mEvaluatingWorker & & mEvaluatingWorker - > ID ( ) = = aId ) {
serviceWorker = mEvaluatingWorker ;
} else if ( mInstallingWorker & & mInstallingWorker - > ID ( ) = = aId ) {
2016-04-09 03:28:25 +03:00
serviceWorker = mInstallingWorker ;
} else if ( mWaitingWorker & & mWaitingWorker - > ID ( ) = = aId ) {
serviceWorker = mWaitingWorker ;
} else if ( mActiveWorker & & mActiveWorker - > ID ( ) = = aId ) {
serviceWorker = mActiveWorker ;
}
return serviceWorker . forget ( ) ;
}
void
ServiceWorkerRegistrationInfo : : TryToActivateAsync ( )
{
2016-05-05 11:45:00 +03:00
MOZ_ALWAYS_SUCCEEDS (
NS_DispatchToMainThread ( NewRunnableMethod ( this ,
& ServiceWorkerRegistrationInfo : : TryToActivate ) ) ) ;
2016-04-09 03:28:25 +03:00
}
/*
2016-07-28 03:36:10 +03:00
* TryToActivate should not be called directly , use TryToActivateAsync instead .
2016-04-09 03:28:25 +03:00
*/
void
ServiceWorkerRegistrationInfo : : TryToActivate ( )
{
2016-07-28 03:36:10 +03:00
AssertIsOnMainThread ( ) ;
bool controlling = IsControllingDocuments ( ) ;
bool skipWaiting = mWaitingWorker & & mWaitingWorker - > SkipWaitingFlag ( ) ;
2016-08-18 17:12:08 +03:00
bool idle = IsIdle ( ) ;
2016-07-28 03:36:10 +03:00
if ( idle & & ( ! controlling | | skipWaiting ) ) {
2016-04-09 03:28:25 +03:00
Activate ( ) ;
}
}
void
ServiceWorkerRegistrationInfo : : Activate ( )
{
2016-04-17 14:29:53 +03:00
if ( ! mWaitingWorker ) {
2016-04-09 03:28:25 +03:00
return ;
}
2017-01-13 01:00:36 +03:00
RefPtr < ServiceWorkerManager > swm = ServiceWorkerManager : : GetInstance ( ) ;
if ( ! swm ) {
// browser shutdown began during async activation step
return ;
}
2016-04-17 14:29:53 +03:00
TransitionWaitingToActive ( ) ;
2016-04-09 03:28:25 +03:00
// FIXME(nsm): Unlink appcache if there is one.
// "Queue a task to fire a simple event named controllerchange..."
nsCOMPtr < nsIRunnable > controllerChangeRunnable =
2016-05-05 11:45:00 +03:00
NewRunnableMethod < RefPtr < ServiceWorkerRegistrationInfo > > (
2016-04-09 03:28:25 +03:00
swm , & ServiceWorkerManager : : FireControllerChange , this ) ;
NS_DispatchToMainThread ( controllerChangeRunnable ) ;
nsCOMPtr < nsIRunnable > failRunnable =
2016-05-05 11:45:00 +03:00
NewRunnableMethod < bool > ( this ,
& ServiceWorkerRegistrationInfo : : FinishActivate ,
false /* success */ ) ;
2016-04-09 03:28:25 +03:00
nsMainThreadPtrHandle < ServiceWorkerRegistrationInfo > handle (
new nsMainThreadPtrHolder < ServiceWorkerRegistrationInfo > ( this ) ) ;
RefPtr < LifeCycleEventCallback > callback = new ContinueActivateRunnable ( handle ) ;
ServiceWorkerPrivate * workerPrivate = mActiveWorker - > WorkerPrivate ( ) ;
MOZ_ASSERT ( workerPrivate ) ;
nsresult rv = workerPrivate - > SendLifeCycleEvent ( NS_LITERAL_STRING ( " activate " ) ,
callback , failRunnable ) ;
if ( NS_WARN_IF ( NS_FAILED ( rv ) ) ) {
MOZ_ALWAYS_SUCCEEDS ( NS_DispatchToMainThread ( failRunnable ) ) ;
return ;
}
}
void
ServiceWorkerRegistrationInfo : : FinishActivate ( bool aSuccess )
{
if ( mPendingUninstall | | ! mActiveWorker | |
mActiveWorker - > State ( ) ! = ServiceWorkerState : : Activating ) {
return ;
}
// Activation never fails, so aSuccess is ignored.
mActiveWorker - > UpdateState ( ServiceWorkerState : : Activated ) ;
2017-03-22 06:39:06 +03:00
NotifyChromeRegistrationListeners ( ) ;
2016-04-09 03:28:25 +03:00
RefPtr < ServiceWorkerManager > swm = ServiceWorkerManager : : GetInstance ( ) ;
2017-01-13 01:00:36 +03:00
if ( ! swm ) {
// browser shutdown started during async activation completion step
return ;
}
2016-04-09 03:28:25 +03:00
swm - > StoreRegistration ( mPrincipal , this ) ;
}
void
ServiceWorkerRegistrationInfo : : RefreshLastUpdateCheckTime ( )
{
AssertIsOnMainThread ( ) ;
mLastUpdateCheckTime = PR_IntervalNow ( ) / PR_MSEC_PER_SEC ;
}
bool
ServiceWorkerRegistrationInfo : : IsLastUpdateCheckTimeOverOneDay ( ) const
{
AssertIsOnMainThread ( ) ;
// For testing.
if ( Preferences : : GetBool ( " dom.serviceWorkers.testUpdateOverOneDay " ) ) {
return true ;
}
const uint64_t kSecondsPerDay = 86400 ;
const uint64_t now = PR_IntervalNow ( ) / PR_MSEC_PER_SEC ;
2016-04-27 12:24:04 +03:00
if ( ( now - mLastUpdateCheckTime ) > kSecondsPerDay ) {
2016-04-09 03:28:25 +03:00
return true ;
}
return false ;
}
void
2016-11-21 05:14:54 +03:00
ServiceWorkerRegistrationInfo : : AsyncUpdateRegistrationStateProperties ( WhichServiceWorker aWorker ,
TransitionType aTransition )
2016-04-09 03:28:25 +03:00
{
2016-04-17 14:29:53 +03:00
AssertIsOnMainThread ( ) ;
RefPtr < ServiceWorkerManager > swm = ServiceWorkerManager : : GetInstance ( ) ;
2017-01-13 01:00:36 +03:00
if ( ! swm ) {
// browser shutdown started during this async step
return ;
}
2016-11-21 05:14:54 +03:00
if ( aTransition = = Invalidate ) {
swm - > InvalidateServiceWorkerRegistrationWorker ( this , aWorker ) ;
} else {
MOZ_ASSERT ( aTransition = = TransitionToNextState ) ;
swm - > TransitionServiceWorkerRegistrationWorker ( this , aWorker ) ;
2016-11-22 01:38:00 +03:00
if ( aWorker = = WhichServiceWorker : : WAITING_WORKER ) {
swm - > CheckPendingReadyPromises ( ) ;
}
2016-11-21 05:14:54 +03:00
}
}
void
ServiceWorkerRegistrationInfo : : UpdateRegistrationStateProperties ( WhichServiceWorker aWorker ,
TransitionType aTransition )
{
AssertIsOnMainThread ( ) ;
2016-04-17 14:29:53 +03:00
2016-11-21 05:14:54 +03:00
nsCOMPtr < nsIRunnable > runnable = NewRunnableMethod < WhichServiceWorker , TransitionType > (
this ,
& ServiceWorkerRegistrationInfo : : AsyncUpdateRegistrationStateProperties , aWorker , aTransition ) ;
MOZ_ALWAYS_SUCCEEDS ( NS_DispatchToMainThread ( runnable . forget ( ) ) ) ;
}
void
ServiceWorkerRegistrationInfo : : NotifyChromeRegistrationListeners ( )
{
2016-04-09 03:28:25 +03:00
nsTArray < nsCOMPtr < nsIServiceWorkerRegistrationInfoListener > > listeners ( mListeners ) ;
for ( size_t index = 0 ; index < listeners . Length ( ) ; + + index ) {
listeners [ index ] - > OnChange ( ) ;
}
}
void
ServiceWorkerRegistrationInfo : : MaybeScheduleTimeCheckAndUpdate ( )
{
AssertIsOnMainThread ( ) ;
RefPtr < ServiceWorkerManager > swm = ServiceWorkerManager : : GetInstance ( ) ;
if ( ! swm ) {
// shutting down, do nothing
return ;
}
if ( mUpdateState = = NoUpdate ) {
mUpdateState = NeedTimeCheckAndUpdate ;
}
swm - > ScheduleUpdateTimer ( mPrincipal , mScope ) ;
}
void
ServiceWorkerRegistrationInfo : : MaybeScheduleUpdate ( )
{
AssertIsOnMainThread ( ) ;
RefPtr < ServiceWorkerManager > swm = ServiceWorkerManager : : GetInstance ( ) ;
if ( ! swm ) {
// shutting down, do nothing
return ;
}
mUpdateState = NeedUpdate ;
swm - > ScheduleUpdateTimer ( mPrincipal , mScope ) ;
}
bool
ServiceWorkerRegistrationInfo : : CheckAndClearIfUpdateNeeded ( )
{
AssertIsOnMainThread ( ) ;
bool result = mUpdateState = = NeedUpdate | |
( mUpdateState = = NeedTimeCheckAndUpdate & &
IsLastUpdateCheckTimeOverOneDay ( ) ) ;
mUpdateState = NoUpdate ;
return result ;
}
2016-07-28 02:09:15 +03:00
ServiceWorkerInfo *
ServiceWorkerRegistrationInfo : : GetEvaluating ( ) const
{
AssertIsOnMainThread ( ) ;
return mEvaluatingWorker ;
}
2016-04-17 14:29:53 +03:00
ServiceWorkerInfo *
ServiceWorkerRegistrationInfo : : GetInstalling ( ) const
{
AssertIsOnMainThread ( ) ;
return mInstallingWorker ;
}
ServiceWorkerInfo *
ServiceWorkerRegistrationInfo : : GetWaiting ( ) const
{
AssertIsOnMainThread ( ) ;
return mWaitingWorker ;
}
ServiceWorkerInfo *
ServiceWorkerRegistrationInfo : : GetActive ( ) const
{
AssertIsOnMainThread ( ) ;
return mActiveWorker ;
}
2017-03-10 20:15:07 +03:00
ServiceWorkerInfo *
ServiceWorkerRegistrationInfo : : GetByID ( uint64_t aID ) const
{
if ( mActiveWorker & & mActiveWorker - > ID ( ) = = aID ) {
return mActiveWorker ;
}
if ( mWaitingWorker & & mWaitingWorker - > ID ( ) = = aID ) {
return mWaitingWorker ;
}
if ( mInstallingWorker & & mInstallingWorker - > ID ( ) = = aID ) {
return mInstallingWorker ;
}
if ( mEvaluatingWorker & & mEvaluatingWorker - > ID ( ) = = aID ) {
return mEvaluatingWorker ;
}
return nullptr ;
}
2016-07-28 02:09:15 +03:00
void
ServiceWorkerRegistrationInfo : : SetEvaluating ( ServiceWorkerInfo * aServiceWorker )
{
AssertIsOnMainThread ( ) ;
MOZ_ASSERT ( aServiceWorker ) ;
MOZ_ASSERT ( ! mEvaluatingWorker ) ;
MOZ_ASSERT ( ! mInstallingWorker ) ;
MOZ_ASSERT ( mWaitingWorker ! = aServiceWorker ) ;
MOZ_ASSERT ( mActiveWorker ! = aServiceWorker ) ;
mEvaluatingWorker = aServiceWorker ;
}
void
ServiceWorkerRegistrationInfo : : ClearEvaluating ( )
{
AssertIsOnMainThread ( ) ;
if ( ! mEvaluatingWorker ) {
return ;
}
mEvaluatingWorker - > UpdateState ( ServiceWorkerState : : Redundant ) ;
mEvaluatingWorker = nullptr ;
}
2016-04-17 14:29:53 +03:00
void
ServiceWorkerRegistrationInfo : : ClearInstalling ( )
{
AssertIsOnMainThread ( ) ;
if ( ! mInstallingWorker ) {
return ;
}
2016-11-21 05:14:54 +03:00
UpdateRegistrationStateProperties ( WhichServiceWorker : : INSTALLING_WORKER ,
Invalidate ) ;
2016-04-17 14:29:53 +03:00
mInstallingWorker - > UpdateState ( ServiceWorkerState : : Redundant ) ;
mInstallingWorker = nullptr ;
2017-03-22 06:39:06 +03:00
NotifyChromeRegistrationListeners ( ) ;
2016-04-17 14:29:53 +03:00
}
2016-04-17 14:29:53 +03:00
void
2016-07-28 02:09:15 +03:00
ServiceWorkerRegistrationInfo : : TransitionEvaluatingToInstalling ( )
2016-04-17 14:29:53 +03:00
{
AssertIsOnMainThread ( ) ;
2016-07-28 02:09:15 +03:00
MOZ_ASSERT ( mEvaluatingWorker ) ;
2016-04-17 14:29:53 +03:00
MOZ_ASSERT ( ! mInstallingWorker ) ;
2016-07-28 02:09:15 +03:00
mInstallingWorker = mEvaluatingWorker . forget ( ) ;
2016-04-17 14:29:53 +03:00
mInstallingWorker - > UpdateState ( ServiceWorkerState : : Installing ) ;
2016-11-21 05:14:54 +03:00
NotifyChromeRegistrationListeners ( ) ;
2016-04-17 14:29:53 +03:00
}
void
2016-04-17 14:29:53 +03:00
ServiceWorkerRegistrationInfo : : TransitionInstallingToWaiting ( )
2016-04-17 14:29:53 +03:00
{
AssertIsOnMainThread ( ) ;
2016-04-17 14:29:53 +03:00
MOZ_ASSERT ( mInstallingWorker ) ;
if ( mWaitingWorker ) {
MOZ_ASSERT ( mInstallingWorker - > CacheName ( ) ! = mWaitingWorker - > CacheName ( ) ) ;
mWaitingWorker - > UpdateState ( ServiceWorkerState : : Redundant ) ;
}
mWaitingWorker = mInstallingWorker . forget ( ) ;
2016-11-21 05:14:54 +03:00
UpdateRegistrationStateProperties ( WhichServiceWorker : : INSTALLING_WORKER ,
TransitionToNextState ) ;
2016-04-17 14:29:53 +03:00
mWaitingWorker - > UpdateState ( ServiceWorkerState : : Installed ) ;
2017-03-22 06:39:06 +03:00
NotifyChromeRegistrationListeners ( ) ;
2016-04-17 14:29:53 +03:00
RefPtr < ServiceWorkerManager > swm = ServiceWorkerManager : : GetInstance ( ) ;
2017-01-13 01:00:36 +03:00
if ( ! swm ) {
// browser shutdown began
return ;
}
2016-04-17 14:29:53 +03:00
swm - > StoreRegistration ( mPrincipal , this ) ;
2016-04-17 14:29:53 +03:00
}
void
ServiceWorkerRegistrationInfo : : SetActive ( ServiceWorkerInfo * aServiceWorker )
{
AssertIsOnMainThread ( ) ;
2016-04-17 14:29:53 +03:00
MOZ_ASSERT ( aServiceWorker ) ;
// TODO: Assert installing, waiting, and active are nullptr once the SWM
// moves to the parent process. After that happens this code will
// only run for browser initialization and not for cross-process
// overrides.
MOZ_ASSERT ( mInstallingWorker ! = aServiceWorker ) ;
MOZ_ASSERT ( mWaitingWorker ! = aServiceWorker ) ;
MOZ_ASSERT ( mActiveWorker ! = aServiceWorker ) ;
if ( mActiveWorker ) {
MOZ_ASSERT ( aServiceWorker - > CacheName ( ) ! = mActiveWorker - > CacheName ( ) ) ;
mActiveWorker - > UpdateState ( ServiceWorkerState : : Redundant ) ;
}
// The active worker is being overriden due to initial load or
// another process activating a worker. Move straight to the
// Activated state.
2016-04-17 14:29:53 +03:00
mActiveWorker = aServiceWorker ;
2016-04-17 14:29:53 +03:00
mActiveWorker - > SetActivateStateUncheckedWithoutEvent ( ServiceWorkerState : : Activated ) ;
2016-11-21 05:14:54 +03:00
UpdateRegistrationStateProperties ( WhichServiceWorker : : ACTIVE_WORKER , Invalidate ) ;
2017-03-22 06:39:06 +03:00
NotifyChromeRegistrationListeners ( ) ;
2016-04-17 14:29:53 +03:00
}
void
ServiceWorkerRegistrationInfo : : TransitionWaitingToActive ( )
{
AssertIsOnMainThread ( ) ;
MOZ_ASSERT ( mWaitingWorker ) ;
if ( mActiveWorker ) {
MOZ_ASSERT ( mWaitingWorker - > CacheName ( ) ! = mActiveWorker - > CacheName ( ) ) ;
mActiveWorker - > UpdateState ( ServiceWorkerState : : Redundant ) ;
}
// We are transitioning from waiting to active normally, so go to
// the activating state.
mActiveWorker = mWaitingWorker . forget ( ) ;
2016-11-21 05:14:54 +03:00
UpdateRegistrationStateProperties ( WhichServiceWorker : : WAITING_WORKER ,
TransitionToNextState ) ;
2016-04-17 14:29:53 +03:00
mActiveWorker - > UpdateState ( ServiceWorkerState : : Activating ) ;
2017-03-22 06:39:06 +03:00
NotifyChromeRegistrationListeners ( ) ;
2016-04-17 14:29:53 +03:00
}
2016-08-18 17:12:08 +03:00
bool
ServiceWorkerRegistrationInfo : : IsIdle ( ) const
{
return ! mActiveWorker | | mActiveWorker - > WorkerPrivate ( ) - > IsIdle ( ) ;
}
2017-01-04 12:08:43 +03:00
nsLoadFlags
ServiceWorkerRegistrationInfo : : GetLoadFlags ( ) const
{
return mLoadFlags ;
}
2017-01-04 12:08:51 +03:00
void
ServiceWorkerRegistrationInfo : : SetLoadFlags ( nsLoadFlags aLoadFlags )
{
mLoadFlags = aLoadFlags ;
}
2016-04-09 03:28:25 +03:00
END_WORKERS_NAMESPACE