зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1434342 P2 Make ServiceWorker store and use a ServiceWorkerDescriptor internally. r=asuth
This commit is contained in:
Родитель
231fc8a398
Коммит
7427e49f90
|
@ -61,14 +61,15 @@ ServiceWorker::Create(nsIGlobalObject* aOwner,
|
|||
return ref.forget();
|
||||
}
|
||||
|
||||
ref = new ServiceWorker(aOwner, info);
|
||||
ref = new ServiceWorker(aOwner, aDescriptor, info);
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
ServiceWorker::ServiceWorker(nsIGlobalObject* aGlobal,
|
||||
ServiceWorkerInfo* aInfo)
|
||||
: DOMEventTargetHelper(aGlobal),
|
||||
mInfo(aInfo)
|
||||
: DOMEventTargetHelper(aGlobal)
|
||||
, mDescriptor(aDescriptor)
|
||||
, mInfo(aInfo)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aInfo);
|
||||
|
@ -97,10 +98,28 @@ ServiceWorker::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|||
return ServiceWorkerBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
ServiceWorkerState
|
||||
ServiceWorker::State() const
|
||||
{
|
||||
return mDescriptor.State();
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorker::SetState(ServiceWorkerState aState)
|
||||
{
|
||||
mDescriptor.SetState(aState);
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorker::GetScriptURL(nsString& aURL) const
|
||||
{
|
||||
CopyUTF8toUTF16(mInfo->ScriptSpec(), aURL);
|
||||
CopyUTF8toUTF16(mDescriptor.ScriptURL(), aURL);
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorker::DispatchStateChange(ServiceWorkerState aState)
|
||||
{
|
||||
DOMEventTargetHelper::DispatchTrustedEvent(NS_LITERAL_STRING("statechange"));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/ServiceWorkerBinding.h" // For ServiceWorkerState.
|
||||
#include "mozilla/dom/ServiceWorkerDescriptor.h"
|
||||
|
||||
class nsIGlobalObject;
|
||||
|
||||
|
@ -38,25 +39,16 @@ public:
|
|||
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
ServiceWorkerState
|
||||
State() const
|
||||
{
|
||||
return mState;
|
||||
}
|
||||
State() const;
|
||||
|
||||
void
|
||||
SetState(ServiceWorkerState aState)
|
||||
{
|
||||
mState = aState;
|
||||
}
|
||||
SetState(ServiceWorkerState aState);
|
||||
|
||||
void
|
||||
GetScriptURL(nsString& aURL) const;
|
||||
|
||||
void
|
||||
DispatchStateChange(ServiceWorkerState aState)
|
||||
{
|
||||
DOMEventTargetHelper::DispatchTrustedEvent(NS_LITERAL_STRING("statechange"));
|
||||
}
|
||||
DispatchStateChange(ServiceWorkerState aState);
|
||||
|
||||
#ifdef XP_WIN
|
||||
#undef PostMessage
|
||||
|
@ -67,12 +59,14 @@ public:
|
|||
const Sequence<JSObject*>& aTransferable, ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
ServiceWorker(nsIGlobalObject* aWindow, ServiceWorkerInfo* aInfo);
|
||||
ServiceWorker(nsIGlobalObject* aWindow,
|
||||
const ServiceWorkerDescriptor& aDescriptor,
|
||||
ServiceWorkerInfo* aInfo);
|
||||
|
||||
// This class is reference-counted and will be destroyed from Release().
|
||||
~ServiceWorker();
|
||||
|
||||
ServiceWorkerState mState;
|
||||
ServiceWorkerDescriptor mDescriptor;
|
||||
const RefPtr<ServiceWorkerInfo> mInfo;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче