mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1353636 - Part 2: Expose ServieworkerRegistration.updateViaCache. r=bkelly
--HG-- extra : rebase_source : 51eb4aebc78f0e48487e88ce5f9f9b70bf8efadd
This commit is contained in:
parent
3f781402a4
commit
502a2f107a
@ -74,6 +74,7 @@ interface nsIServiceWorkerRegistrationInfo : nsISupports
|
||||
|
||||
readonly attribute DOMString scope;
|
||||
readonly attribute DOMString scriptSpec;
|
||||
readonly attribute unsigned short updateViaCache;
|
||||
|
||||
readonly attribute PRTime lastUpdateTime;
|
||||
|
||||
|
@ -17,6 +17,7 @@ interface ServiceWorkerRegistration : EventTarget {
|
||||
[Unforgeable] readonly attribute ServiceWorker? active;
|
||||
|
||||
readonly attribute USVString scope;
|
||||
readonly attribute ServiceWorkerUpdateViaCache updateViaCache;
|
||||
|
||||
[Throws, NewObject]
|
||||
Promise<void> update();
|
||||
|
@ -139,6 +139,33 @@ public:
|
||||
aScope = mScope;
|
||||
}
|
||||
|
||||
ServiceWorkerUpdateViaCache
|
||||
UpdateViaCache() const override
|
||||
{
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
MOZ_ASSERT(swm);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
|
||||
MOZ_ASSERT(window);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
|
||||
MOZ_ASSERT(doc);
|
||||
|
||||
nsCOMPtr<nsIServiceWorkerRegistrationInfo> registration;
|
||||
nsresult rv = swm->GetRegistrationByPrincipal(doc->NodePrincipal(), mScope,
|
||||
getter_AddRefs(registration));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv) && registration);
|
||||
|
||||
uint16_t updateViaCache;
|
||||
rv = registration->GetUpdateViaCache(&updateViaCache);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
// Silence possible compiler warnings.
|
||||
Unused << rv;
|
||||
|
||||
return static_cast<ServiceWorkerUpdateViaCache>(updateViaCache);
|
||||
}
|
||||
|
||||
private:
|
||||
~ServiceWorkerRegistrationMainThread();
|
||||
|
||||
@ -916,6 +943,13 @@ public:
|
||||
aScope = mScope;
|
||||
}
|
||||
|
||||
ServiceWorkerUpdateViaCache
|
||||
UpdateViaCache() const override
|
||||
{
|
||||
// FIXME(hopang): Will be implemented after Bug 1113522.
|
||||
return ServiceWorkerUpdateViaCache::Imports;
|
||||
}
|
||||
|
||||
bool
|
||||
Notify(Status aStatus) override;
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/ServiceWorkerBinding.h"
|
||||
#include "mozilla/dom/ServiceWorkerCommon.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrationBinding.h"
|
||||
#include "mozilla/dom/workers/bindings/WorkerHolder.h"
|
||||
#include "nsContentUtils.h" // Required for nsContentUtils::PushEnabled
|
||||
|
||||
@ -90,6 +91,9 @@ public:
|
||||
virtual void
|
||||
GetScope(nsAString& aScope) const = 0;
|
||||
|
||||
virtual ServiceWorkerUpdateViaCache
|
||||
UpdateViaCache() const = 0;
|
||||
|
||||
virtual already_AddRefed<Promise>
|
||||
Update(ErrorResult& aRv) = 0;
|
||||
|
||||
|
@ -128,6 +128,13 @@ ServiceWorkerRegistrationInfo::GetScriptSpec(nsAString& aScriptSpec)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceWorkerRegistrationInfo::GetUpdateViaCache(uint16_t* aUpdateViaCache)
|
||||
{
|
||||
*aUpdateViaCache = static_cast<uint16_t>(GetUpdateViaCache());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceWorkerRegistrationInfo::GetLastUpdateTime(PRTime* _retval)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user