mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1170543 P3 Expose ServiceWorker idle thread state to ServiceWorkerManager. r=asuth
This commit is contained in:
parent
23604e56e7
commit
1a8803ebd5
@ -1292,6 +1292,13 @@ ServiceWorkerManager::NotifyUnregister(nsIPrincipal* aPrincipal,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorkerManager::WorkerIsIdle(ServiceWorkerInfo* aWorker)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(aWorker);
|
||||
}
|
||||
|
||||
already_AddRefed<ServiceWorkerJobQueue>
|
||||
ServiceWorkerManager::GetOrCreateJobQueue(const nsACString& aKey,
|
||||
const nsACString& aScope)
|
||||
|
@ -294,6 +294,9 @@ public:
|
||||
nsresult
|
||||
NotifyUnregister(nsIPrincipal* aPrincipal, const nsAString& aScope);
|
||||
|
||||
void
|
||||
WorkerIsIdle(ServiceWorkerInfo* aWorker);
|
||||
|
||||
private:
|
||||
ServiceWorkerManager();
|
||||
~ServiceWorkerManager();
|
||||
|
@ -1899,6 +1899,13 @@ ServiceWorkerPrivate::DetachDebugger()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
ServiceWorkerPrivate::IsIdle() const
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
return mTokenCount == 0 || (mTokenCount == 1 && mIdleKeepAliveToken);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
ServiceWorkerPrivate::NoteIdleWorkerCallback(nsITimer* aTimer, void* aPrivate)
|
||||
{
|
||||
@ -1994,6 +2001,11 @@ ServiceWorkerPrivate::ReleaseToken()
|
||||
--mTokenCount;
|
||||
if (!mTokenCount) {
|
||||
TerminateWorker();
|
||||
} else if (IsIdle()) {
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
if (swm) {
|
||||
swm->WorkerIsIdle(mInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,6 +146,9 @@ public:
|
||||
nsresult
|
||||
DetachDebugger();
|
||||
|
||||
bool
|
||||
IsIdle() const;
|
||||
|
||||
private:
|
||||
enum WakeUpReason {
|
||||
FetchEvent = 0,
|
||||
|
Loading…
Reference in New Issue
Block a user