mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1330487 - Part 2 : Refactor, new constructor of URIPrincipalReferrerPolicyAndCorsModeHashKey from SheetLoadData r=heycam
MozReview-Commit-ID: LC3jzw8mli7 Differential Revision: https://phabricator.services.mozilla.com/D2290 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
12582ae1aa
commit
a6c1be6216
@ -64,6 +64,7 @@
|
||||
#include "mozilla/dom/SRICheck.h"
|
||||
|
||||
#include "mozilla/Encoding.h"
|
||||
#include "mozilla/Logging.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -96,11 +97,6 @@ using namespace mozilla::dom;
|
||||
* determination.
|
||||
*/
|
||||
|
||||
namespace mozilla {
|
||||
namespace css {
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
|
||||
static mozilla::LazyLogModule sCssLoaderLog("nsCSSLoader");
|
||||
|
||||
static mozilla::LazyLogModule gSriPRLog("SRI");
|
||||
@ -132,6 +128,22 @@ static const char* const gStateStrings[] = {
|
||||
"eSheetComplete"
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey::
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey(css::SheetLoadData* aLoadData)
|
||||
: nsURIHashKey(aLoadData->mURI)
|
||||
, mPrincipal(aLoadData->mLoaderPrincipal)
|
||||
, mCORSMode(aLoadData->mSheet->GetCORSMode())
|
||||
, mReferrerPolicy(aLoadData->mSheet->GetReferrerPolicy())
|
||||
{
|
||||
MOZ_COUNT_CTOR(URIPrincipalReferrerPolicyAndCORSModeHashKey);
|
||||
}
|
||||
} // namespace mozilla
|
||||
|
||||
namespace mozilla {
|
||||
namespace css {
|
||||
|
||||
/********************************
|
||||
* SheetLoadData implementation *
|
||||
********************************/
|
||||
@ -884,12 +896,7 @@ Loader::UpdateLoadingData(URIPrincipalReferrerPolicyAndCORSModeHashKey* aOldKey,
|
||||
DebugOnly<bool> removed = mSheets->mLoadingDatas.Remove(aOldKey);
|
||||
MOZ_ASSERT(removed, "Can't find data to remove!!!");
|
||||
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey
|
||||
newKey(aData->mURI,
|
||||
aData->mLoaderPrincipal,
|
||||
aData->mSheet->GetCORSMode(),
|
||||
aData->mSheet->GetReferrerPolicy());
|
||||
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey newKey(aData);
|
||||
mSheets->mLoadingDatas.Put(&newKey, aData);
|
||||
}
|
||||
|
||||
@ -1414,10 +1421,8 @@ Loader::LoadSheet(SheetLoadData* aLoadData,
|
||||
|
||||
SheetLoadData* existingData = nullptr;
|
||||
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey key(aLoadData->mURI,
|
||||
aLoadData->mLoaderPrincipal,
|
||||
aLoadData->mSheet->GetCORSMode(),
|
||||
aLoadData->mSheet->GetReferrerPolicy());
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey key(aLoadData);
|
||||
|
||||
if (aSheetState == eSheetLoading) {
|
||||
mSheets->mLoadingDatas.Get(&key, &existingData);
|
||||
NS_ASSERTION(existingData, "CreateSheet lied about the state");
|
||||
@ -1758,10 +1763,7 @@ Loader::DoSheetComplete(SheetLoadData* aLoadData, LoadDataArray& aDatasToNotify)
|
||||
LOG_URI(" Finished loading: '%s'", aLoadData->mURI);
|
||||
// Remove the data from the list of loading datas
|
||||
if (aLoadData->mIsLoading) {
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey key(aLoadData->mURI,
|
||||
aLoadData->mLoaderPrincipal,
|
||||
aLoadData->mSheet->GetCORSMode(),
|
||||
aLoadData->mSheet->GetReferrerPolicy());
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey key(aLoadData);
|
||||
#ifdef DEBUG
|
||||
SheetLoadData *loadingData;
|
||||
NS_ASSERTION(
|
||||
@ -1846,10 +1848,7 @@ Loader::DoSheetComplete(SheetLoadData* aLoadData, LoadDataArray& aDatasToNotify)
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey key(aLoadData->mURI,
|
||||
aLoadData->mLoaderPrincipal,
|
||||
aLoadData->mSheet->GetCORSMode(),
|
||||
aLoadData->mSheet->GetReferrerPolicy());
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey key(aLoadData);
|
||||
NS_ASSERTION(sheet->IsComplete(),
|
||||
"Should only be caching complete sheets");
|
||||
mSheets->mCompleteSheets.Put(&key, sheet);
|
||||
@ -2092,10 +2091,7 @@ Loader::LoadStyleLink(const SheetInfo& aInfo, nsICSSLoaderObserver* aObserver)
|
||||
mSheets->mLoadingDatas.Count() != 0 &&
|
||||
!result.ShouldBlock()) {
|
||||
LOG((" Deferring sheet load"));
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey key(data->mURI,
|
||||
data->mLoaderPrincipal,
|
||||
data->mSheet->GetCORSMode(),
|
||||
data->mSheet->GetReferrerPolicy());
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey key(data);
|
||||
mSheets->mPendingDatas.Put(&key, data);
|
||||
|
||||
data->mMustNotify = true;
|
||||
|
@ -69,6 +69,7 @@ public:
|
||||
{
|
||||
MOZ_COUNT_CTOR(URIPrincipalReferrerPolicyAndCORSModeHashKey);
|
||||
}
|
||||
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey(const URIPrincipalReferrerPolicyAndCORSModeHashKey& toCopy)
|
||||
: nsURIHashKey(toCopy),
|
||||
mPrincipal(toCopy.mPrincipal),
|
||||
@ -77,6 +78,9 @@ public:
|
||||
{
|
||||
MOZ_COUNT_CTOR(URIPrincipalReferrerPolicyAndCORSModeHashKey);
|
||||
}
|
||||
|
||||
explicit URIPrincipalReferrerPolicyAndCORSModeHashKey(css::SheetLoadData* aLoadData);
|
||||
|
||||
~URIPrincipalReferrerPolicyAndCORSModeHashKey()
|
||||
{
|
||||
MOZ_COUNT_DTOR(URIPrincipalReferrerPolicyAndCORSModeHashKey);
|
||||
|
Loading…
Reference in New Issue
Block a user