зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1112071 Change Cache ManagerId to use QuotaManager's concept of origin. r=ehsan
This commit is contained in:
Родитель
738d8e8d98
Коммит
1947fc8d08
|
@ -400,7 +400,7 @@ private:
|
|||
while (iter.HasMore()) {
|
||||
nsRefPtr<Manager> manager = iter.GetNext();
|
||||
if (aOrigin.IsVoid() ||
|
||||
manager->mManagerId->ExtendedOrigin() == aOrigin) {
|
||||
manager->mManagerId->QuotaOrigin() == aOrigin) {
|
||||
manager->Abort();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,26 +21,16 @@ ManagerId::Create(nsIPrincipal* aPrincipal, ManagerId** aManagerIdOut)
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// The QuotaManager::GetInfoFromPrincipal() has special logic for system
|
||||
// and about: principals. We currently don't need the system principal logic
|
||||
// because ManagerId only uses the origin for in memory comparisons. We
|
||||
// also don't do any special logic to host the same Cache for different about:
|
||||
// pages, so we don't need those checks either.
|
||||
//
|
||||
// But, if we get the same QuotaManager directory for different about:
|
||||
// origins, we probably only want one Manager instance. So, we might
|
||||
// want to start using the QM's concept of origin uniqueness here.
|
||||
//
|
||||
// TODO: consider using QuotaManager's modified origin here (bug 1112071)
|
||||
|
||||
nsCString origin;
|
||||
nsresult rv = aPrincipal->GetOriginNoSuffix(origin);
|
||||
// and about: principals. We need to use the same modified origin in
|
||||
// order to interpret calls from QM correctly.
|
||||
nsCString quotaOrigin;
|
||||
nsresult rv = QuotaManager::GetInfoFromPrincipal(aPrincipal,
|
||||
nullptr, //group
|
||||
"aOrigin,
|
||||
nullptr); // is app
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
nsCString jarPrefix;
|
||||
rv = aPrincipal->GetJarPrefix(jarPrefix);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
nsRefPtr<ManagerId> ref = new ManagerId(aPrincipal, origin, jarPrefix);
|
||||
nsRefPtr<ManagerId> ref = new ManagerId(aPrincipal, quotaOrigin);
|
||||
ref.forget(aManagerIdOut);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -54,10 +44,9 @@ ManagerId::Principal() const
|
|||
return ref.forget();
|
||||
}
|
||||
|
||||
ManagerId::ManagerId(nsIPrincipal* aPrincipal, const nsACString& aOrigin,
|
||||
const nsACString& aJarPrefix)
|
||||
ManagerId::ManagerId(nsIPrincipal* aPrincipal, const nsACString& aQuotaOrigin)
|
||||
: mPrincipal(aPrincipal)
|
||||
, mExtendedOrigin(aJarPrefix + aOrigin)
|
||||
, mQuotaOrigin(aQuotaOrigin)
|
||||
{
|
||||
MOZ_ASSERT(mPrincipal);
|
||||
}
|
||||
|
|
|
@ -29,16 +29,15 @@ public:
|
|||
// Main thread only
|
||||
already_AddRefed<nsIPrincipal> Principal() const;
|
||||
|
||||
const nsACString& ExtendedOrigin() const { return mExtendedOrigin; }
|
||||
const nsACString& QuotaOrigin() const { return mQuotaOrigin; }
|
||||
|
||||
bool operator==(const ManagerId& aOther) const
|
||||
{
|
||||
return mExtendedOrigin == aOther.mExtendedOrigin;
|
||||
return mQuotaOrigin == aOther.mQuotaOrigin;
|
||||
}
|
||||
|
||||
private:
|
||||
ManagerId(nsIPrincipal* aPrincipal, const nsACString& aOrigin,
|
||||
const nsACString& aJarPrefix);
|
||||
ManagerId(nsIPrincipal* aPrincipal, const nsACString& aOrigin);
|
||||
~ManagerId();
|
||||
|
||||
ManagerId(const ManagerId&) = delete;
|
||||
|
@ -48,7 +47,7 @@ private:
|
|||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
|
||||
// immutable to allow threadsfe access
|
||||
const nsCString mExtendedOrigin;
|
||||
const nsCString mQuotaOrigin;
|
||||
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::dom::cache::ManagerId)
|
||||
|
|
Загрузка…
Ссылка в новой задаче