зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1595964 Part 1 - Add nsIServiceWorkerRegistrationInfo.evaluatingWorker, r=asuth.
Differential Revision: https://phabricator.services.mozilla.com/D54286 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
82d41a33b2
Коммит
a72710f1b3
|
@ -58,6 +58,9 @@ interface nsIServiceWorkerInfo : nsISupports
|
|||
|
||||
readonly attribute nsIWorkerDebugger debugger;
|
||||
|
||||
// Return whether the ServiceWorker has a "fetch" event listener. Throws if
|
||||
// this is unknown because the worker's main script hasn't finished executing
|
||||
// (when exposed as evaluatingWorker).
|
||||
readonly attribute bool handlesFetchEvents;
|
||||
|
||||
readonly attribute PRTime installedTime;
|
||||
|
@ -91,6 +94,7 @@ interface nsIServiceWorkerRegistrationInfo : nsISupports
|
|||
|
||||
readonly attribute PRTime lastUpdateTime;
|
||||
|
||||
readonly attribute nsIServiceWorkerInfo evaluatingWorker;
|
||||
readonly attribute nsIServiceWorkerInfo installingWorker;
|
||||
readonly attribute nsIServiceWorkerInfo waitingWorker;
|
||||
readonly attribute nsIServiceWorkerInfo activeWorker;
|
||||
|
|
|
@ -91,6 +91,11 @@ NS_IMETHODIMP
|
|||
ServiceWorkerInfo::GetHandlesFetchEvents(bool* aValue) {
|
||||
MOZ_ASSERT(aValue);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (mHandlesFetch == Unknown) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aValue = HandlesFetch();
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ ServiceWorkerRegistrationInfo::GetScope(nsAString& aScope) {
|
|||
NS_IMETHODIMP
|
||||
ServiceWorkerRegistrationInfo::GetScriptSpec(nsAString& aScriptSpec) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
RefPtr<ServiceWorkerInfo> newest = Newest();
|
||||
RefPtr<ServiceWorkerInfo> newest = NewestIncludingEvaluating();
|
||||
if (newest) {
|
||||
CopyUTF8toUTF16(newest->ScriptSpec(), aScriptSpec);
|
||||
}
|
||||
|
@ -191,6 +191,15 @@ ServiceWorkerRegistrationInfo::GetLastUpdateTime(PRTime* _retval) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceWorkerRegistrationInfo::GetEvaluatingWorker(
|
||||
nsIServiceWorkerInfo** aResult) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
RefPtr<ServiceWorkerInfo> info = mEvaluatingWorker;
|
||||
info.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceWorkerRegistrationInfo::GetInstallingWorker(
|
||||
nsIServiceWorkerInfo** aResult) {
|
||||
|
@ -530,6 +539,11 @@ void ServiceWorkerRegistrationInfo::SetEvaluating(
|
|||
MOZ_ASSERT(mActiveWorker != aServiceWorker);
|
||||
|
||||
mEvaluatingWorker = aServiceWorker;
|
||||
|
||||
// We don't call UpdateRegistrationState() here because the evaluating worker
|
||||
// is currently not exposed to content on the registration, so calling it here
|
||||
// would produce redundant IPC traffic.
|
||||
NotifyChromeRegistrationListeners();
|
||||
}
|
||||
|
||||
void ServiceWorkerRegistrationInfo::ClearEvaluating() {
|
||||
|
@ -543,6 +557,9 @@ void ServiceWorkerRegistrationInfo::ClearEvaluating() {
|
|||
// We don't update the redundant time for the sw here, since we've not expose
|
||||
// evalutingWorker yet.
|
||||
mEvaluatingWorker = nullptr;
|
||||
|
||||
// As for SetEvaluating, UpdateRegistrationState() does not need to be called.
|
||||
NotifyChromeRegistrationListeners();
|
||||
}
|
||||
|
||||
void ServiceWorkerRegistrationInfo::ClearInstalling() {
|
||||
|
|
|
@ -104,6 +104,14 @@ class ServiceWorkerRegistrationInfo final
|
|||
return newest.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<ServiceWorkerInfo> NewestIncludingEvaluating() const {
|
||||
if (mEvaluatingWorker) {
|
||||
RefPtr<ServiceWorkerInfo> newest = mEvaluatingWorker;
|
||||
return newest.forget();
|
||||
}
|
||||
return Newest();
|
||||
}
|
||||
|
||||
already_AddRefed<ServiceWorkerInfo> GetServiceWorkerInfoById(uint64_t aId);
|
||||
|
||||
void StartControllingClient() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче