mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1110485 P6 Remove useless cache::FileUtils type. r=ehsan
This commit is contained in:
parent
f21157b4d1
commit
2b8b6dd1ab
2
dom/cache/DBAction.cpp
vendored
2
dom/cache/DBAction.cpp
vendored
@ -170,7 +170,7 @@ DBAction::WipeDatabase(nsIFile* aDBFile, nsIFile* aDBDir)
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
// Delete the morgue as well.
|
||||
rv = FileUtils::BodyDeleteDir(aDBDir);
|
||||
rv = BodyDeleteDir(aDBDir);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
return rv;
|
||||
|
51
dom/cache/FileUtils.cpp
vendored
51
dom/cache/FileUtils.cpp
vendored
@ -23,11 +23,24 @@ namespace cache {
|
||||
using mozilla::dom::quota::FileInputStream;
|
||||
using mozilla::dom::quota::FileOutputStream;
|
||||
using mozilla::dom::quota::PERSISTENCE_TYPE_DEFAULT;
|
||||
using mozilla::unused;
|
||||
|
||||
namespace {
|
||||
|
||||
enum BodyFileType
|
||||
{
|
||||
BODY_FILE_FINAL,
|
||||
BODY_FILE_TMP
|
||||
};
|
||||
|
||||
nsresult
|
||||
BodyIdToFile(nsIFile* aBaseDir, const nsID& aId, BodyFileType aType,
|
||||
nsIFile** aBodyFileOut);
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// static
|
||||
nsresult
|
||||
FileUtils::BodyCreateDir(nsIFile* aBaseDir)
|
||||
BodyCreateDir(nsIFile* aBaseDir)
|
||||
{
|
||||
MOZ_ASSERT(aBaseDir);
|
||||
|
||||
@ -49,7 +62,7 @@ FileUtils::BodyCreateDir(nsIFile* aBaseDir)
|
||||
|
||||
// static
|
||||
nsresult
|
||||
FileUtils::BodyDeleteDir(nsIFile* aBaseDir)
|
||||
BodyDeleteDir(nsIFile* aBaseDir)
|
||||
{
|
||||
MOZ_ASSERT(aBaseDir);
|
||||
|
||||
@ -72,8 +85,7 @@ FileUtils::BodyDeleteDir(nsIFile* aBaseDir)
|
||||
|
||||
// static
|
||||
nsresult
|
||||
FileUtils::BodyGetCacheDir(nsIFile* aBaseDir, const nsID& aId,
|
||||
nsIFile** aCacheDirOut)
|
||||
BodyGetCacheDir(nsIFile* aBaseDir, const nsID& aId, nsIFile** aCacheDirOut)
|
||||
{
|
||||
MOZ_ASSERT(aBaseDir);
|
||||
MOZ_ASSERT(aCacheDirOut);
|
||||
@ -107,11 +119,11 @@ FileUtils::BodyGetCacheDir(nsIFile* aBaseDir, const nsID& aId,
|
||||
|
||||
// static
|
||||
nsresult
|
||||
FileUtils::BodyStartWriteStream(const QuotaInfo& aQuotaInfo,
|
||||
nsIFile* aBaseDir, nsIInputStream* aSource,
|
||||
void* aClosure,
|
||||
nsAsyncCopyCallbackFun aCallback, nsID* aIdOut,
|
||||
nsISupports** aCopyContextOut)
|
||||
BodyStartWriteStream(const QuotaInfo& aQuotaInfo,
|
||||
nsIFile* aBaseDir, nsIInputStream* aSource,
|
||||
void* aClosure,
|
||||
nsAsyncCopyCallbackFun aCallback, nsID* aIdOut,
|
||||
nsISupports** aCopyContextOut)
|
||||
{
|
||||
MOZ_ASSERT(aBaseDir);
|
||||
MOZ_ASSERT(aSource);
|
||||
@ -168,7 +180,7 @@ FileUtils::BodyStartWriteStream(const QuotaInfo& aQuotaInfo,
|
||||
|
||||
// static
|
||||
void
|
||||
FileUtils::BodyCancelWrite(nsIFile* aBaseDir, nsISupports* aCopyContext)
|
||||
BodyCancelWrite(nsIFile* aBaseDir, nsISupports* aCopyContext)
|
||||
{
|
||||
MOZ_ASSERT(aBaseDir);
|
||||
MOZ_ASSERT(aCopyContext);
|
||||
@ -182,7 +194,7 @@ FileUtils::BodyCancelWrite(nsIFile* aBaseDir, nsISupports* aCopyContext)
|
||||
|
||||
// static
|
||||
nsresult
|
||||
FileUtils::BodyFinalizeWrite(nsIFile* aBaseDir, const nsID& aId)
|
||||
BodyFinalizeWrite(nsIFile* aBaseDir, const nsID& aId)
|
||||
{
|
||||
MOZ_ASSERT(aBaseDir);
|
||||
|
||||
@ -206,8 +218,8 @@ FileUtils::BodyFinalizeWrite(nsIFile* aBaseDir, const nsID& aId)
|
||||
|
||||
// static
|
||||
nsresult
|
||||
FileUtils::BodyOpen(const QuotaInfo& aQuotaInfo, nsIFile* aBaseDir,
|
||||
const nsID& aId, nsIInputStream** aStreamOut)
|
||||
BodyOpen(const QuotaInfo& aQuotaInfo, nsIFile* aBaseDir, const nsID& aId,
|
||||
nsIInputStream** aStreamOut)
|
||||
{
|
||||
MOZ_ASSERT(aBaseDir);
|
||||
MOZ_ASSERT(aStreamOut);
|
||||
@ -234,7 +246,7 @@ FileUtils::BodyOpen(const QuotaInfo& aQuotaInfo, nsIFile* aBaseDir,
|
||||
|
||||
// static
|
||||
nsresult
|
||||
FileUtils::BodyDeleteFiles(nsIFile* aBaseDir, const nsTArray<nsID>& aIdList)
|
||||
BodyDeleteFiles(nsIFile* aBaseDir, const nsTArray<nsID>& aIdList)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@ -273,10 +285,11 @@ FileUtils::BodyDeleteFiles(nsIFile* aBaseDir, const nsTArray<nsID>& aIdList)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
namespace {
|
||||
|
||||
nsresult
|
||||
FileUtils::BodyIdToFile(nsIFile* aBaseDir, const nsID& aId,
|
||||
BodyFileType aType, nsIFile** aBodyFileOut)
|
||||
BodyIdToFile(nsIFile* aBaseDir, const nsID& aId, BodyFileType aType,
|
||||
nsIFile** aBodyFileOut)
|
||||
{
|
||||
MOZ_ASSERT(aBaseDir);
|
||||
MOZ_ASSERT(aBodyFileOut);
|
||||
@ -304,6 +317,8 @@ FileUtils::BodyIdToFile(nsIFile* aBaseDir, const nsID& aId,
|
||||
return rv;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
} // namespace cache
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
61
dom/cache/FileUtils.h
vendored
61
dom/cache/FileUtils.h
vendored
@ -19,51 +19,36 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
namespace cache {
|
||||
|
||||
// TODO: remove static class and use functions in cache namespace (bug 1110485)
|
||||
class FileUtils final
|
||||
{
|
||||
public:
|
||||
enum BodyFileType
|
||||
{
|
||||
BODY_FILE_FINAL,
|
||||
BODY_FILE_TMP
|
||||
};
|
||||
nsresult
|
||||
BodyCreateDir(nsIFile* aBaseDir);
|
||||
|
||||
static nsresult BodyCreateDir(nsIFile* aBaseDir);
|
||||
// Note that this function can only be used during the initialization of the
|
||||
// database. We're unlikely to be able to delete the DB successfully past
|
||||
// that point due to the file being in use.
|
||||
static nsresult BodyDeleteDir(nsIFile* aBaseDir);
|
||||
static nsresult BodyGetCacheDir(nsIFile* aBaseDir, const nsID& aId,
|
||||
nsIFile** aCacheDirOut);
|
||||
// Note that this function can only be used during the initialization of the
|
||||
// database. We're unlikely to be able to delete the DB successfully past
|
||||
// that point due to the file being in use.
|
||||
nsresult
|
||||
BodyDeleteDir(nsIFile* aBaseDir);
|
||||
|
||||
static nsresult
|
||||
BodyStartWriteStream(const QuotaInfo& aQuotaInfo, nsIFile* aBaseDir,
|
||||
nsIInputStream* aSource, void* aClosure,
|
||||
nsAsyncCopyCallbackFun aCallback, nsID* aIdOut,
|
||||
nsISupports** aCopyContextOut);
|
||||
nsresult
|
||||
BodyGetCacheDir(nsIFile* aBaseDir, const nsID& aId, nsIFile** aCacheDirOut);
|
||||
|
||||
static void
|
||||
BodyCancelWrite(nsIFile* aBaseDir, nsISupports* aCopyContext);
|
||||
nsresult
|
||||
BodyStartWriteStream(const QuotaInfo& aQuotaInfo, nsIFile* aBaseDir,
|
||||
nsIInputStream* aSource, void* aClosure,
|
||||
nsAsyncCopyCallbackFun aCallback, nsID* aIdOut,
|
||||
nsISupports** aCopyContextOut);
|
||||
|
||||
static nsresult
|
||||
BodyFinalizeWrite(nsIFile* aBaseDir, const nsID& aId);
|
||||
void
|
||||
BodyCancelWrite(nsIFile* aBaseDir, nsISupports* aCopyContext);
|
||||
|
||||
static nsresult
|
||||
BodyOpen(const QuotaInfo& aQuotaInfo, nsIFile* aBaseDir, const nsID& aId,
|
||||
nsIInputStream** aStreamOut);
|
||||
nsresult
|
||||
BodyFinalizeWrite(nsIFile* aBaseDir, const nsID& aId);
|
||||
|
||||
static nsresult
|
||||
BodyDeleteFiles(nsIFile* aBaseDir, const nsTArray<nsID>& aIdList);
|
||||
nsresult
|
||||
BodyOpen(const QuotaInfo& aQuotaInfo, nsIFile* aBaseDir, const nsID& aId,
|
||||
nsIInputStream** aStreamOut);
|
||||
|
||||
private:
|
||||
static nsresult
|
||||
BodyIdToFile(nsIFile* aBaseDir, const nsID& aId, BodyFileType aType,
|
||||
nsIFile** aBodyFileOut);
|
||||
|
||||
FileUtils() = delete;
|
||||
~FileUtils() = delete;
|
||||
};
|
||||
nsresult
|
||||
BodyDeleteFiles(nsIFile* aBaseDir, const nsTArray<nsID>& aIdList);
|
||||
|
||||
} // namespace cache
|
||||
} // namespace dom
|
||||
|
39
dom/cache/Manager.cpp
vendored
39
dom/cache/Manager.cpp
vendored
@ -34,7 +34,8 @@ namespace {
|
||||
|
||||
using mozilla::unused;
|
||||
using mozilla::dom::cache::Action;
|
||||
using mozilla::dom::cache::FileUtils;
|
||||
using mozilla::dom::cache::BodyCreateDir;
|
||||
using mozilla::dom::cache::BodyDeleteFiles;
|
||||
using mozilla::dom::cache::QuotaInfo;
|
||||
using mozilla::dom::cache::SyncDBAction;
|
||||
using mozilla::dom::cache::db::CreateSchema;
|
||||
@ -59,7 +60,7 @@ public:
|
||||
// TODO: have Context create/delete marker files in constructor/destructor
|
||||
// and only do expensive maintenance if that marker is present (bug 1110446)
|
||||
|
||||
nsresult rv = FileUtils::BodyCreateDir(aDBDir);
|
||||
nsresult rv = BodyCreateDir(aDBDir);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
mozStorageTransaction trans(aConn, false,
|
||||
@ -113,7 +114,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
rv = FileUtils::BodyDeleteFiles(dbDir, mDeletedBodyIdList);
|
||||
rv = BodyDeleteFiles(dbDir, mDeletedBodyIdList);
|
||||
unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
|
||||
aResolver->Resolve(rv);
|
||||
@ -508,8 +509,7 @@ public:
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
rv = FileUtils::BodyOpen(aQuotaInfo, aDBDir, mResponse.mBodyId,
|
||||
getter_AddRefs(stream));
|
||||
rv = BodyOpen(aQuotaInfo, aDBDir, mResponse.mBodyId, getter_AddRefs(stream));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
if (NS_WARN_IF(!stream)) { return NS_ERROR_FILE_NOT_FOUND; }
|
||||
|
||||
@ -572,9 +572,8 @@ public:
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
rv = FileUtils::BodyOpen(aQuotaInfo, aDBDir,
|
||||
mSavedResponses[i].mBodyId,
|
||||
getter_AddRefs(stream));
|
||||
rv = BodyOpen(aQuotaInfo, aDBDir, mSavedResponses[i].mBodyId,
|
||||
getter_AddRefs(stream));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
if (NS_WARN_IF(!stream)) { return NS_ERROR_FILE_NOT_FOUND; }
|
||||
|
||||
@ -759,14 +758,14 @@ private:
|
||||
for (uint32_t i = 0; i < mList.Length(); ++i) {
|
||||
Entry& e = mList[i];
|
||||
if (e.mRequestStream) {
|
||||
rv = FileUtils::BodyFinalizeWrite(mDBDir, e.mRequestBodyId);
|
||||
rv = BodyFinalizeWrite(mDBDir, e.mRequestBodyId);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
DoResolve(rv);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (e.mResponseStream) {
|
||||
rv = FileUtils::BodyFinalizeWrite(mDBDir, e.mResponseBodyId);
|
||||
rv = BodyFinalizeWrite(mDBDir, e.mResponseBodyId);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
DoResolve(rv);
|
||||
return;
|
||||
@ -871,10 +870,9 @@ private:
|
||||
|
||||
nsCOMPtr<nsISupports> copyContext;
|
||||
|
||||
nsresult rv = FileUtils::BodyStartWriteStream(aQuotaInfo, mDBDir, source,
|
||||
this, AsyncCopyCompleteFunc,
|
||||
bodyId,
|
||||
getter_AddRefs(copyContext));
|
||||
nsresult rv = BodyStartWriteStream(aQuotaInfo, mDBDir, source, this,
|
||||
AsyncCopyCompleteFunc, bodyId,
|
||||
getter_AddRefs(copyContext));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
mBodyIdWrittenList.AppendElement(*bodyId);
|
||||
@ -895,7 +893,7 @@ private:
|
||||
// May occur on either owning thread or target thread
|
||||
MutexAutoLock lock(mMutex);
|
||||
for (uint32_t i = 0; i < mCopyContextList.Length(); ++i) {
|
||||
FileUtils::BodyCancelWrite(mDBDir, mCopyContextList[i]);
|
||||
BodyCancelWrite(mDBDir, mCopyContextList[i]);
|
||||
}
|
||||
mCopyContextList.Clear();
|
||||
}
|
||||
@ -938,7 +936,7 @@ private:
|
||||
|
||||
// Clean up any files we might have written before hitting the error.
|
||||
if (NS_FAILED(aRv)) {
|
||||
FileUtils::BodyDeleteFiles(mDBDir, mBodyIdWrittenList);
|
||||
BodyDeleteFiles(mDBDir, mBodyIdWrittenList);
|
||||
}
|
||||
|
||||
// Must be released on the target thread where it was opened.
|
||||
@ -1063,9 +1061,8 @@ public:
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
rv = FileUtils::BodyOpen(aQuotaInfo, aDBDir,
|
||||
mSavedRequests[i].mBodyId,
|
||||
getter_AddRefs(stream));
|
||||
rv = BodyOpen(aQuotaInfo, aDBDir, mSavedRequests[i].mBodyId,
|
||||
getter_AddRefs(stream));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
if (NS_WARN_IF(!stream)) { return NS_ERROR_FILE_NOT_FOUND; }
|
||||
|
||||
@ -1126,8 +1123,8 @@ public:
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
rv = FileUtils::BodyOpen(aQuotaInfo, aDBDir, mSavedResponse.mBodyId,
|
||||
getter_AddRefs(stream));
|
||||
rv = BodyOpen(aQuotaInfo, aDBDir, mSavedResponse.mBodyId,
|
||||
getter_AddRefs(stream));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
if (NS_WARN_IF(!stream)) { return NS_ERROR_FILE_NOT_FOUND; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user