Bug 1500343 - Part 3: Remove dom.fileHandle.enabled usage in IDBRequest.cpp r=dom-storage-reviewers,jari

Differential Revision: https://phabricator.services.mozilla.com/D159732
This commit is contained in:
Kagami Sascha Rosylight 2023-02-08 15:51:06 +00:00
parent 1b25e6b527
commit 4e1b33f70f
5 changed files with 3 additions and 121 deletions

View File

@ -156,7 +156,6 @@ IDBDatabase::IDBDatabase(IDBOpenDBRequest* aRequest,
mFactory(std::move(aFactory)),
mSpec(std::move(aSpec)),
mBackgroundActor(aActor),
mFileHandleDisabled(aRequest->IsFileHandleDisabled()),
mClosed(false),
mInvalidated(false),
mQuotaExceeded(false),
@ -807,43 +806,6 @@ void IDBDatabase::NoteInactiveTransaction() {
EventTarget()->Dispatch(runnable.forget(), NS_DISPATCH_NORMAL));
}
nsresult IDBDatabase::GetQuotaInfo(nsACString& aOrigin,
PersistenceType* aPersistenceType) {
using mozilla::dom::quota::QuotaManager;
MOZ_ASSERT(NS_IsMainThread(), "This can't work off the main thread!");
if (aPersistenceType) {
*aPersistenceType = mSpec->metadata().persistenceType();
MOZ_ASSERT(*aPersistenceType != PERSISTENCE_TYPE_INVALID);
}
PrincipalInfo* principalInfo = mFactory->GetPrincipalInfo();
MOZ_ASSERT(principalInfo);
switch (principalInfo->type()) {
case PrincipalInfo::TNullPrincipalInfo:
MOZ_CRASH("Is this needed?!");
case PrincipalInfo::TSystemPrincipalInfo:
aOrigin = QuotaManager::GetOriginForChrome();
return NS_OK;
case PrincipalInfo::TContentPrincipalInfo: {
QM_TRY_UNWRAP(auto principal, PrincipalInfoToPrincipal(*principalInfo));
QM_TRY_UNWRAP(aOrigin, QuotaManager::GetOriginFromPrincipal(principal));
return NS_OK;
}
default:
MOZ_CRASH("Unknown PrincipalInfo type!");
}
MOZ_CRASH("Should never get here!");
}
void IDBDatabase::ExpireFileActors(bool aExpireAll) {
AssertIsOnOwningThread();

View File

@ -78,7 +78,6 @@ class IDBDatabase final : public DOMEventTargetHelper {
// Weak refs, IDBMutableFile strongly owns this IDBDatabase object.
nsTArray<NotNull<IDBMutableFile*>> mLiveMutableFiles;
const bool mFileHandleDisabled;
bool mClosed;
bool mInvalidated;
bool mQuotaExceeded;
@ -160,12 +159,6 @@ class IDBDatabase final : public DOMEventTargetHelper {
void NoteInactiveTransaction();
// XXX This doesn't really belong here... It's only needed for IDBMutableFile
// serialization and should be removed or fixed someday.
nsresult GetQuotaInfo(nsACString& aOrigin, PersistenceType* aPersistenceType);
bool IsFileHandleDisabled() const { return mFileHandleDisabled; }
void NoteLiveMutableFile(IDBMutableFile& aMutableFile);
void NoteFinishedMutableFile(IDBMutableFile& aMutableFile);

View File

@ -168,71 +168,6 @@ bool StructuredCloneWriteCallback(JSContext* aCx,
// UNWRAP_OBJECT calls might mutate this.
JS::Rooted<JSObject*> obj(aCx, aObj);
IDBMutableFile* mutableFile;
if (NS_SUCCEEDED(UNWRAP_OBJECT(IDBMutableFile, &obj, mutableFile))) {
if (cloneWriteInfo->mDatabase->IsFileHandleDisabled()) {
return false;
}
IDBDatabase* const database = mutableFile->Database();
MOZ_ASSERT(database);
// Throw when trying to store IDBMutableFile objects that live in a
// different database.
if (database != cloneWriteInfo->mDatabase) {
MOZ_ASSERT(!SameCOMIdentity(database, cloneWriteInfo->mDatabase));
if (database->Name() != cloneWriteInfo->mDatabase->Name()) {
return false;
}
nsCString fileOrigin, databaseOrigin;
PersistenceType filePersistenceType, databasePersistenceType;
if (NS_WARN_IF(NS_FAILED(
database->GetQuotaInfo(fileOrigin, &filePersistenceType)))) {
return false;
}
if (NS_WARN_IF(NS_FAILED(cloneWriteInfo->mDatabase->GetQuotaInfo(
databaseOrigin, &databasePersistenceType)))) {
return false;
}
if (filePersistenceType != databasePersistenceType ||
fileOrigin != databaseOrigin) {
return false;
}
}
if (cloneWriteInfo->mFiles.Length() > size_t(UINT32_MAX)) {
MOZ_ASSERT(false, "Fix the structured clone data to use a bigger type!");
return false;
}
const uint32_t index = cloneWriteInfo->mFiles.Length();
const NS_ConvertUTF16toUTF8 convType(mutableFile->Type());
const uint32_t convTypeLength =
NativeEndian::swapToLittleEndian(convType.Length());
const NS_ConvertUTF16toUTF8 convName(mutableFile->Name());
const uint32_t convNameLength =
NativeEndian::swapToLittleEndian(convName.Length());
if (!JS_WriteUint32Pair(aWriter, SCTAG_DOM_MUTABLEFILE, uint32_t(index)) ||
!JS_WriteBytes(aWriter, &convTypeLength, sizeof(uint32_t)) ||
!JS_WriteBytes(aWriter, convType.get(), convType.Length()) ||
!JS_WriteBytes(aWriter, &convNameLength, sizeof(uint32_t)) ||
!JS_WriteBytes(aWriter, convName.get(), convName.Length())) {
return false;
}
cloneWriteInfo->mFiles.EmplaceBack(mutableFile);
return true;
}
{
Blob* blob = nullptr;
if (NS_SUCCEEDED(UNWRAP_OBJECT(Blob, &obj, blob))) {

View File

@ -312,11 +312,9 @@ void IDBRequest::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
}
IDBOpenDBRequest::IDBOpenDBRequest(SafeRefPtr<IDBFactory> aFactory,
nsIGlobalObject* aGlobal,
bool aFileHandleDisabled)
nsIGlobalObject* aGlobal)
: IDBRequest(aGlobal),
mFactory(std::move(aFactory)),
mFileHandleDisabled(aFileHandleDisabled),
mIncreasedActiveDatabaseCount(false) {
AssertIsOnOwningThread();
MOZ_ASSERT(mFactory);
@ -335,10 +333,8 @@ RefPtr<IDBOpenDBRequest> IDBOpenDBRequest::Create(
aFactory->AssertIsOnOwningThread();
MOZ_ASSERT(aGlobal);
bool fileHandleDisabled = !StaticPrefs::dom_fileHandle_enabled();
RefPtr<IDBOpenDBRequest> request =
new IDBOpenDBRequest(std::move(aFactory), aGlobal, fileHandleDisabled);
new IDBOpenDBRequest(std::move(aFactory), aGlobal);
CaptureCaller(aCx, request->mFilename, &request->mLineNo, &request->mColumn);
if (!NS_IsMainThread()) {

View File

@ -254,7 +254,6 @@ class IDBOpenDBRequest final : public IDBRequest {
RefPtr<StrongWorkerRef> mWorkerRef;
const bool mFileHandleDisabled;
bool mIncreasedActiveDatabaseCount;
public:
@ -262,8 +261,6 @@ class IDBOpenDBRequest final : public IDBRequest {
JSContext* aCx, SafeRefPtr<IDBFactory> aFactory,
nsIGlobalObject* aGlobal);
bool IsFileHandleDisabled() const { return mFileHandleDisabled; }
void SetTransaction(SafeRefPtr<IDBTransaction> aTransaction);
void DispatchNonTransactionError(nsresult aErrorCode);
@ -282,8 +279,7 @@ class IDBOpenDBRequest final : public IDBRequest {
JS::Handle<JSObject*> aGivenProto) override;
private:
IDBOpenDBRequest(SafeRefPtr<IDBFactory> aFactory, nsIGlobalObject* aGlobal,
bool aFileHandleDisabled);
IDBOpenDBRequest(SafeRefPtr<IDBFactory> aFactory, nsIGlobalObject* aGlobal);
~IDBOpenDBRequest();