mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 754142: Don't install quota handlers on chrome databases. r=bent
This commit is contained in:
parent
0750d2a779
commit
d9f7b8ce1d
@ -510,14 +510,17 @@ IDBFactory::OpenCommon(const nsAString& aName,
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window;
|
||||
JSObject* scriptOwner = nullptr;
|
||||
FactoryPrivilege privilege;
|
||||
|
||||
if (mWindow) {
|
||||
window = mWindow;
|
||||
scriptOwner =
|
||||
static_cast<nsGlobalWindow*>(window.get())->FastGetGlobalJSObject();
|
||||
privilege = Content;
|
||||
}
|
||||
else {
|
||||
scriptOwner = mOwningObject;
|
||||
privilege = Chrome;
|
||||
}
|
||||
|
||||
nsRefPtr<IDBOpenDBRequest> request =
|
||||
@ -526,9 +529,10 @@ IDBFactory::OpenCommon(const nsAString& aName,
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if (IndexedDatabaseManager::IsMainProcess()) {
|
||||
if (IndexedDatabaseManager::IsMainProcess()) {
|
||||
nsRefPtr<OpenDatabaseHelper> openHelper =
|
||||
new OpenDatabaseHelper(request, aName, mASCIIOrigin, aVersion, aDeleting);
|
||||
new OpenDatabaseHelper(request, aName, mASCIIOrigin, aVersion, aDeleting,
|
||||
privilege);
|
||||
|
||||
rv = openHelper->Init();
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
@ -36,6 +36,11 @@ class FileInfo;
|
||||
class IDBDatabase;
|
||||
class IDBTransaction;
|
||||
|
||||
enum FactoryPrivilege {
|
||||
Content,
|
||||
Chrome
|
||||
};
|
||||
|
||||
template <class T>
|
||||
void SwapData(T& aData1, T& aData2)
|
||||
{
|
||||
|
@ -730,6 +730,7 @@ IndexedDatabaseManager::GetIndexedDBQuotaMB()
|
||||
|
||||
nsresult
|
||||
IndexedDatabaseManager::EnsureOriginIsInitialized(const nsACString& aOrigin,
|
||||
FactoryPrivilege mPrivilege,
|
||||
nsIFile** aDirectory)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
@ -777,15 +778,17 @@ IndexedDatabaseManager::EnsureOriginIsInitialized(const nsACString& aOrigin,
|
||||
rv = patternFile->GetNativePath(pattern);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Now tell SQLite to start tracking this pattern.
|
||||
// Now tell SQLite to start tracking this pattern for content.
|
||||
nsCOMPtr<mozIStorageServiceQuotaManagement> ss =
|
||||
do_GetService(MOZ_STORAGE_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(ss, NS_ERROR_FAILURE);
|
||||
|
||||
rv = ss->SetQuotaForFilenamePattern(pattern,
|
||||
GetIndexedDBQuotaMB() * 1024 * 1024,
|
||||
mQuotaCallbackSingleton, nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (mPrivilege != Chrome) {
|
||||
rv = ss->SetQuotaForFilenamePattern(pattern,
|
||||
GetIndexedDBQuotaMB() * 1024 * 1024,
|
||||
mQuotaCallbackSingleton, nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// We need to see if there are any files in the directory already. If they
|
||||
// are database files then we need to create file managers for them and also
|
||||
@ -877,8 +880,10 @@ IndexedDatabaseManager::EnsureOriginIsInitialized(const nsACString& aOrigin,
|
||||
|
||||
fileManagers->AppendElement(fileManager);
|
||||
|
||||
rv = ss->UpdateQuotaInformationForFile(file);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (mPrivilege != Chrome) {
|
||||
rv = ss->UpdateQuotaInformationForFile(file);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
validSubdirs.PutEntry(dbBaseFilename);
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ public:
|
||||
GetIndexedDBQuotaMB();
|
||||
|
||||
nsresult EnsureOriginIsInitialized(const nsACString& aOrigin,
|
||||
FactoryPrivilege aPrivilege,
|
||||
nsIFile** aDirectory);
|
||||
|
||||
// Determine if the quota is lifted for the Window the current thread is
|
||||
|
@ -1609,6 +1609,7 @@ OpenDatabaseHelper::DoDatabaseWork()
|
||||
NS_ASSERTION(mgr, "This should never be null!");
|
||||
|
||||
nsresult rv = mgr->EnsureOriginIsInitialized(mASCIIOrigin,
|
||||
mPrivilege,
|
||||
getter_AddRefs(dbDirectory));
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
|
@ -23,12 +23,13 @@ public:
|
||||
const nsAString& aName,
|
||||
const nsACString& aASCIIOrigin,
|
||||
PRUint64 aRequestedVersion,
|
||||
bool aForDeletion)
|
||||
bool aForDeletion,
|
||||
FactoryPrivilege aPrivilege)
|
||||
: HelperBase(aRequest), mOpenDBRequest(aRequest), mName(aName),
|
||||
mASCIIOrigin(aASCIIOrigin), mRequestedVersion(aRequestedVersion),
|
||||
mForDeletion(aForDeletion), mDatabaseId(nullptr), mCurrentVersion(0),
|
||||
mLastObjectStoreId(0), mLastIndexId(0), mState(eCreated),
|
||||
mResultCode(NS_OK), mLoadDBMetadata(false)
|
||||
mForDeletion(aForDeletion), mPrivilege(aPrivilege), mDatabaseId(nullptr),
|
||||
mCurrentVersion(0), mLastObjectStoreId(0), mLastIndexId(0),
|
||||
mState(eCreated), mResultCode(NS_OK), mLoadDBMetadata(false)
|
||||
{
|
||||
NS_ASSERTION(!aForDeletion || !aRequestedVersion,
|
||||
"Can't be for deletion and request a version!");
|
||||
@ -100,6 +101,7 @@ protected:
|
||||
nsCString mASCIIOrigin;
|
||||
PRUint64 mRequestedVersion;
|
||||
bool mForDeletion;
|
||||
FactoryPrivilege mPrivilege;
|
||||
nsCOMPtr<nsIAtom> mDatabaseId;
|
||||
|
||||
// Out-params.
|
||||
|
Loading…
Reference in New Issue
Block a user