Bug 1648449 - Use NotNull for CacheCreator::mLoaders. r=dom-workers-and-storage-reviewers,asuth

Differential Revision: https://phabricator.services.mozilla.com/D81076
This commit is contained in:
Simon Giesecke
2020-06-30 08:35:19 +00:00
parent 4f3e68f174
commit e99ddcd933

View File

@@ -414,10 +414,10 @@ class CacheCreator final : public PromiseNativeHandler {
AssertIsOnMainThread(); AssertIsOnMainThread();
} }
void AddLoader(CacheScriptLoader* aLoader) { void AddLoader(MovingNotNull<RefPtr<CacheScriptLoader>> aLoader) {
AssertIsOnMainThread(); AssertIsOnMainThread();
MOZ_ASSERT(!mCacheStorage); MOZ_ASSERT(!mCacheStorage);
mLoaders.AppendElement(aLoader); mLoaders.AppendElement(std::move(aLoader));
} }
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx,
@@ -453,7 +453,7 @@ class CacheCreator final : public PromiseNativeHandler {
RefPtr<Cache> mCache; RefPtr<Cache> mCache;
RefPtr<CacheStorage> mCacheStorage; RefPtr<CacheStorage> mCacheStorage;
nsCOMPtr<nsIGlobalObject> mSandboxGlobalObject; nsCOMPtr<nsIGlobalObject> mSandboxGlobalObject;
nsTArray<RefPtr<CacheScriptLoader>> mLoaders; nsTArray<NotNull<RefPtr<CacheScriptLoader>>> mLoaders;
nsString mCacheName; nsString mCacheName;
OriginAttributes mOriginAttributes; OriginAttributes mOriginAttributes;
@@ -957,9 +957,8 @@ class ScriptLoaderRunnable final : public nsIRunnable, public nsINamed {
mCacheCreator = new CacheCreator(mWorkerPrivate); mCacheCreator = new CacheCreator(mWorkerPrivate);
for (ScriptLoadInfo& loadInfo : mLoadInfos) { for (ScriptLoadInfo& loadInfo : mLoadInfos) {
RefPtr<CacheScriptLoader> loader = new CacheScriptLoader( mCacheCreator->AddLoader(MakeNotNull<RefPtr<CacheScriptLoader>>(
mWorkerPrivate, loadInfo, IsMainWorkerScript(), this); mWorkerPrivate, loadInfo, IsMainWorkerScript(), this));
mCacheCreator->AddLoader(loader);
} }
// The worker may have a null principal on first load, but in that case its // The worker may have a null principal on first load, but in that case its
@@ -1687,7 +1686,6 @@ void CacheCreator::ResolvedCallback(JSContext* aCx,
// If the worker is canceled, CancelMainThread() will have cleared the // If the worker is canceled, CancelMainThread() will have cleared the
// loaders via DeleteCache(). // loaders via DeleteCache().
for (uint32_t i = 0, len = mLoaders.Length(); i < len; ++i) { for (uint32_t i = 0, len = mLoaders.Length(); i < len; ++i) {
MOZ_DIAGNOSTIC_ASSERT(mLoaders[i]);
mLoaders[i]->Load(cache); mLoaders[i]->Load(cache);
} }
} }