mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Bug 931249 - Patch 8 - Provide direct getter to the fact that we are loading a worker instead of relying on cache name. r=khuey
--HG-- extra : rebase_source : ad85e2de17f562449f041fcb66a061a319da45f0
This commit is contained in:
parent
17ef920c79
commit
78132f902f
@ -314,6 +314,7 @@ public:
|
||||
: mCacheName(aWorkerPrivate->ServiceWorkerCacheName())
|
||||
{
|
||||
MOZ_ASSERT(aWorkerPrivate->IsServiceWorker());
|
||||
MOZ_ASSERT(aWorkerPrivate->LoadScriptAsPartOfLoadingServiceWorkerScript());
|
||||
AssertIsOnMainThread();
|
||||
}
|
||||
|
||||
@ -645,7 +646,7 @@ private:
|
||||
}
|
||||
|
||||
if (!mWorkerPrivate->IsServiceWorker() ||
|
||||
mWorkerPrivate->ServiceWorkerCacheName().IsEmpty()) {
|
||||
!mWorkerPrivate->LoadScriptAsPartOfLoadingServiceWorkerScript()) {
|
||||
for (uint32_t index = 0, len = mLoadInfos.Length(); index < len;
|
||||
++index) {
|
||||
nsresult rv = LoadScript(index);
|
||||
|
@ -487,8 +487,22 @@ public:
|
||||
{
|
||||
MOZ_ASSERT(IsServiceWorker());
|
||||
AssertIsOnMainThread();
|
||||
return mLoadingWorkerScript ?
|
||||
mLoadInfo.mServiceWorkerCacheName : EmptyString();
|
||||
return mLoadInfo.mServiceWorkerCacheName;
|
||||
}
|
||||
|
||||
// This is used to handle importScripts(). When the worker is first loaded
|
||||
// and executed, it happens in a sync loop. At this point it sets
|
||||
// mLoadingWorkerScript to true. importScripts() calls that occur during the
|
||||
// execution run in nested sync loops and so this continues to return true,
|
||||
// leading to these scripts being cached offline.
|
||||
// mLoadingWorkerScript is set to false when the top level loop ends.
|
||||
// importScripts() in function calls or event handlers are always fetched
|
||||
// from the network.
|
||||
bool
|
||||
LoadScriptAsPartOfLoadingServiceWorkerScript()
|
||||
{
|
||||
MOZ_ASSERT(IsServiceWorker());
|
||||
return mLoadingWorkerScript;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user