Backed out 3 changesets (bug 1722668) for failures on test_unsetLastAccessTime.js. CLOSED TREE

Backed out changeset db05822c64ff (bug 1722668)
Backed out changeset c9f100cb3f86 (bug 1722668)
Backed out changeset a7179b67eb1a (bug 1722668)
This commit is contained in:
Csoregi Natalia 2021-09-05 00:22:49 +03:00
Родитель 127496a5fe
Коммит 03b44ad93d
13 изменённых файлов: 32 добавлений и 496 удалений

Просмотреть файл

@ -286,7 +286,6 @@ constexpr auto kStorageName = u"storage"_ns;
constexpr auto kSQLiteSuffix = u".sqlite"_ns; constexpr auto kSQLiteSuffix = u".sqlite"_ns;
#define INDEXEDDB_DIRECTORY_NAME u"indexedDB" #define INDEXEDDB_DIRECTORY_NAME u"indexedDB"
#define ARCHIVES_DIRECTORY_NAME u"archives"
#define PERSISTENT_DIRECTORY_NAME u"persistent" #define PERSISTENT_DIRECTORY_NAME u"persistent"
#define PERMANENT_DIRECTORY_NAME u"permanent" #define PERMANENT_DIRECTORY_NAME u"permanent"
#define TEMPORARY_DIRECTORY_NAME u"temporary" #define TEMPORARY_DIRECTORY_NAME u"temporary"
@ -1713,9 +1712,9 @@ class RecordQuotaInfoLoadTimeHelper final : public Runnable {
RecordQuotaInfoLoadTimeHelper() RecordQuotaInfoLoadTimeHelper()
: Runnable("dom::quota::RecordQuotaInfoLoadTimeHelper") {} : Runnable("dom::quota::RecordQuotaInfoLoadTimeHelper") {}
TimeStamp Start(); void Start();
TimeStamp End(); void End();
private: private:
~RecordQuotaInfoLoadTimeHelper() = default; ~RecordQuotaInfoLoadTimeHelper() = default;
@ -1861,36 +1860,6 @@ Result<bool, nsresult> MaybeUpdateGroupForOrigin(
return updated; return updated;
} }
Result<bool, nsresult> MaybeUpdateLastAccessTimeForOrigin(
FullOriginMetadata& aFullOriginMetadata) {
MOZ_ASSERT(!NS_IsMainThread());
if (aFullOriginMetadata.mLastAccessTime == INT64_MIN) {
QuotaManager* quotaManager = QuotaManager::Get();
MOZ_ASSERT(quotaManager);
QM_TRY_INSPECT(
const auto& metadataFile,
quotaManager->GetDirectoryForOrigin(
aFullOriginMetadata.mPersistenceType, aFullOriginMetadata.mOrigin));
QM_TRY(metadataFile->Append(nsLiteralString(METADATA_V2_FILE_NAME)));
QM_TRY_UNWRAP(int64_t timestamp,
MOZ_TO_RESULT_INVOKE(metadataFile, GetLastModifiedTime));
// Need to convert from milliseconds to microseconds.
MOZ_ASSERT((INT64_MAX / PR_USEC_PER_MSEC) > timestamp);
timestamp *= int64_t(PR_USEC_PER_MSEC);
aFullOriginMetadata.mLastAccessTime = timestamp;
return true;
}
return false;
}
} // namespace } // namespace
BackgroundThreadObject::BackgroundThreadObject() BackgroundThreadObject::BackgroundThreadObject()
@ -2419,10 +2388,6 @@ int64_t GetLastModifiedTime(PersistenceType aPersistenceType, nsIFile& aFile) {
timestamp = PR_Now(); timestamp = PR_Now();
} }
// XXX if there were no suitable files for getting last modified time
// (timestamp is still set to INT64_MIN), we should return the current time
// instead of returning INT64_MIN.
return timestamp; return timestamp;
} }
@ -2668,16 +2633,6 @@ uint64_t GetTemporaryStorageLimit(uint64_t aAvailableSpaceBytes) {
return availableSpaceKB * .50 * 1024; return availableSpaceKB * .50 * 1024;
} }
bool IsOriginUnaccessed(const FullOriginMetadata& aFullOriginMetadata,
const int64_t aRecentTime) {
if (aFullOriginMetadata.mLastAccessTime > aRecentTime) {
return false;
}
return (aRecentTime - aFullOriginMetadata.mLastAccessTime) / PR_USEC_PER_SEC >
StaticPrefs::dom_quotaManager_unaccessedForLongTimeThresholdSec();
}
} // namespace } // namespace
/******************************************************************************* /*******************************************************************************
@ -3651,10 +3606,6 @@ nsresult QuotaManager::Init() {
QM_TRY_UNWRAP(do_Init(mStoragePath), QM_TRY_UNWRAP(do_Init(mStoragePath),
MOZ_TO_RESULT_INVOKE_TYPED(nsString, baseDir, GetPath)); MOZ_TO_RESULT_INVOKE_TYPED(nsString, baseDir, GetPath));
QM_TRY_UNWRAP(
do_Init(mStorageArchivesPath),
GetPathForStorage(*baseDir, nsLiteralString(ARCHIVES_DIRECTORY_NAME)));
QM_TRY_UNWRAP( QM_TRY_UNWRAP(
do_Init(mPermanentStoragePath), do_Init(mPermanentStoragePath),
GetPathForStorage(*baseDir, nsLiteralString(PERMANENT_DIRECTORY_NAME))); GetPathForStorage(*baseDir, nsLiteralString(PERMANENT_DIRECTORY_NAME)));
@ -4107,21 +4058,9 @@ nsresult QuotaManager::LoadQuota() {
MOZ_ASSERT(mStorageConnection); MOZ_ASSERT(mStorageConnection);
MOZ_ASSERT(!mTemporaryStorageInitialized); MOZ_ASSERT(!mTemporaryStorageInitialized);
// A list of all unaccessed default or temporary origins.
nsTArray<FullOriginMetadata> unaccessedOrigins;
auto MaybeCollectUnaccessedOrigin =
[loadQuotaInfoStartTime = PR_Now(),
&unaccessedOrigins](auto& fullOriginMetadata) {
if (IsOriginUnaccessed(fullOriginMetadata, loadQuotaInfoStartTime)) {
unaccessedOrigins.AppendElement(std::move(fullOriginMetadata));
}
};
auto recordQuotaInfoLoadTimeHelper = auto recordQuotaInfoLoadTimeHelper =
MakeRefPtr<RecordQuotaInfoLoadTimeHelper>(); MakeRefPtr<RecordQuotaInfoLoadTimeHelper>();
recordQuotaInfoLoadTimeHelper->Start();
const auto startTime = recordQuotaInfoLoadTimeHelper->Start();
auto LoadQuotaFromCache = [&]() -> nsresult { auto LoadQuotaFromCache = [&]() -> nsresult {
QM_TRY_INSPECT( QM_TRY_INSPECT(
@ -4133,15 +4072,10 @@ nsresult QuotaManager::LoadQuota() {
"last_access_time, accessed, persisted " "last_access_time, accessed, persisted "
"FROM origin"_ns)); "FROM origin"_ns));
auto autoRemoveQuota = MakeScopeExit([&] { auto autoRemoveQuota = MakeScopeExit([&] { RemoveQuota(); });
RemoveQuota();
unaccessedOrigins.Clear();
});
QM_TRY(quota::CollectWhileHasResult( QM_TRY(quota::CollectWhileHasResult(
*stmt, *stmt, [this](auto& stmt) -> Result<Ok, nsresult> {
[this,
&MaybeCollectUnaccessedOrigin](auto& stmt) -> Result<Ok, nsresult> {
QM_TRY_INSPECT(const int32_t& repositoryId, QM_TRY_INSPECT(const int32_t& repositoryId,
MOZ_TO_RESULT_INVOKE(stmt, GetInt32, 0)); MOZ_TO_RESULT_INVOKE(stmt, GetInt32, 0));
@ -4165,6 +4099,19 @@ nsresult QuotaManager::LoadQuota() {
fullOriginMetadata.mOrigin, fullOriginMetadata.mOrigin,
MOZ_TO_RESULT_INVOKE_TYPED(nsCString, stmt, GetUTF8String, 3)); MOZ_TO_RESULT_INVOKE_TYPED(nsCString, stmt, GetUTF8String, 3));
QM_TRY_INSPECT(const bool& updated,
MaybeUpdateGroupForOrigin(fullOriginMetadata));
Unused << updated;
// We don't need to update the .metadata-v2 file on disk here,
// EnsureTemporaryOriginIsInitialized is responsible for doing that.
// We just need to use correct group before initializing quota for the
// given origin. (Note that calling LoadFullOriginMetadataWithRestore
// below might update the group in the metadata file, but only as a
// side-effect. The actual place we ensure consistency is in
// EnsureTemporaryOriginIsInitialized.)
QM_TRY_INSPECT( QM_TRY_INSPECT(
const auto& clientUsagesText, const auto& clientUsagesText,
MOZ_TO_RESULT_INVOKE_TYPED(nsCString, stmt, GetUTF8String, 4)); MOZ_TO_RESULT_INVOKE_TYPED(nsCString, stmt, GetUTF8String, 4));
@ -4181,25 +4128,6 @@ nsresult QuotaManager::LoadQuota() {
QM_TRY_UNWRAP(fullOriginMetadata.mPersisted, QM_TRY_UNWRAP(fullOriginMetadata.mPersisted,
MOZ_TO_RESULT_INVOKE(stmt, GetInt32, 8)); MOZ_TO_RESULT_INVOKE(stmt, GetInt32, 8));
QM_TRY_INSPECT(const bool& groupUpdated,
MaybeUpdateGroupForOrigin(fullOriginMetadata));
Unused << groupUpdated;
QM_TRY_INSPECT(
const bool& lastAccessTimeUpdated,
MaybeUpdateLastAccessTimeForOrigin(fullOriginMetadata));
Unused << lastAccessTimeUpdated;
// We don't need to update the .metadata-v2 file on disk here,
// EnsureTemporaryOriginIsInitialized is responsible for doing that.
// We just need to use correct group and last access time before
// initializing quota for the given origin. (Note that calling
// LoadFullOriginMetadataWithRestore below might update the group in
// the metadata file, but only as a side-effect. The actual place we
// ensure consistency is in EnsureTemporaryOriginIsInitialized.)
if (accessed) { if (accessed) {
QM_TRY_INSPECT( QM_TRY_INSPECT(
const auto& directory, const auto& directory,
@ -4251,8 +4179,6 @@ nsresult QuotaManager::LoadQuota() {
InitQuotaForOrigin(fullOriginMetadata, clientUsages, usage); InitQuotaForOrigin(fullOriginMetadata, clientUsages, usage);
} }
MaybeCollectUnaccessedOrigin(fullOriginMetadata);
return Ok{}; return Ok{};
})); }));
@ -4315,10 +4241,9 @@ nsresult QuotaManager::LoadQuota() {
} }
QM_TRY(([&]() -> Result<Ok, nsresult> { QM_TRY(([&]() -> Result<Ok, nsresult> {
QM_TRY(([this, type, &MaybeCollectUnaccessedOrigin] { QM_TRY(([this, type] {
const auto innerFunc = [&](const auto&) -> nsresult { const auto innerFunc = [&](const auto&) -> nsresult {
return InitializeRepository(type, return InitializeRepository(type);
MaybeCollectUnaccessedOrigin);
}; };
return ExecuteInitialization( return ExecuteInitialization(
@ -4340,17 +4265,10 @@ nsresult QuotaManager::LoadQuota() {
#endif #endif
} }
recordQuotaInfoLoadTimeHelper->End();
autoRemoveQuota.release(); autoRemoveQuota.release();
const auto endTime = recordQuotaInfoLoadTimeHelper->End();
if (StaticPrefs::dom_quotaManager_checkQuotaInfoLoadTime() &&
static_cast<uint32_t>((endTime - startTime).ToMilliseconds()) >=
StaticPrefs::dom_quotaManager_longQuotaInfoLoadTimeThresholdMs() &&
!unaccessedOrigins.IsEmpty()) {
QM_WARNONLY_TRY(ArchiveOrigins(unaccessedOrigins));
}
return NS_OK; return NS_OK;
} }
@ -4699,16 +4617,10 @@ Result<FullOriginMetadata, nsresult> QuotaManager::LoadFullOriginMetadata(
QM_TRY(binaryStream->Close()); QM_TRY(binaryStream->Close());
QM_TRY_INSPECT(const bool& groupUpdated, QM_TRY_INSPECT(const bool& updated,
MaybeUpdateGroupForOrigin(fullOriginMetadata)); MaybeUpdateGroupForOrigin(fullOriginMetadata));
// A workaround for a bug in GetLastModifiedTime implementation which should if (updated) {
// have returned the current time instead of INT64_MIN when there were no
// suitable files for getting last modified time.
QM_TRY_INSPECT(const bool& lastAccessTimeUpdated,
MaybeUpdateLastAccessTimeForOrigin(fullOriginMetadata));
if (groupUpdated || lastAccessTimeUpdated) {
// Only overwriting .metadata-v2 (used to overwrite .metadata too) to reduce // Only overwriting .metadata-v2 (used to overwrite .metadata too) to reduce
// I/O. // I/O.
QM_TRY(CreateDirectoryMetadata2( QM_TRY(CreateDirectoryMetadata2(
@ -4745,10 +4657,7 @@ QuotaManager::LoadFullOriginMetadataWithRestore(nsIFile* aDirectory) {
}))); })));
} }
template <typename OriginFunc> nsresult QuotaManager::InitializeRepository(PersistenceType aPersistenceType) {
nsresult QuotaManager::InitializeRepository(PersistenceType aPersistenceType,
OriginFunc&& aOriginFunc) {
AssertIsOnIOThread();
MOZ_ASSERT(aPersistenceType == PERSISTENCE_TYPE_TEMPORARY || MOZ_ASSERT(aPersistenceType == PERSISTENCE_TYPE_TEMPORARY ||
aPersistenceType == PERSISTENCE_TYPE_DEFAULT); aPersistenceType == PERSISTENCE_TYPE_DEFAULT);
@ -4788,7 +4697,7 @@ nsresult QuotaManager::InitializeRepository(PersistenceType aPersistenceType,
QM_TRY( QM_TRY(
([this, &childDirectory, &renameAndInitInfos, ([this, &childDirectory, &renameAndInitInfos,
aPersistenceType, &aOriginFunc]() -> Result<Ok, nsresult> { aPersistenceType]() -> Result<Ok, nsresult> {
QM_TRY_INSPECT( QM_TRY_INSPECT(
const auto& leafName, const auto& leafName,
MOZ_TO_RESULT_INVOKE_TYPED(nsAutoString, childDirectory, MOZ_TO_RESULT_INVOKE_TYPED(nsAutoString, childDirectory,
@ -4860,8 +4769,6 @@ nsresult QuotaManager::InitializeRepository(PersistenceType aPersistenceType,
return Ok{}; return Ok{};
}))); })));
std::forward<OriginFunc>(aOriginFunc)(metadata);
break; break;
} }
@ -4892,10 +4799,10 @@ nsresult QuotaManager::InitializeRepository(PersistenceType aPersistenceType,
return Ok{}; return Ok{};
}())); }()));
for (auto& info : renameAndInitInfos) { for (const auto& info : renameAndInitInfos) {
QM_TRY(([&]() -> Result<Ok, nsresult> { QM_TRY(([&]() -> Result<Ok, nsresult> {
QM_TRY(([&directory, &info, this, aPersistenceType, QM_TRY(([&directory, &info, this,
&aOriginFunc]() -> Result<Ok, nsresult> { aPersistenceType]() -> Result<Ok, nsresult> {
const auto originDirName = const auto originDirName =
MakeSanitizedOriginString(info.mFullOriginMetadata.mOrigin); MakeSanitizedOriginString(info.mFullOriginMetadata.mOrigin);
@ -4914,13 +4821,10 @@ nsresult QuotaManager::InitializeRepository(PersistenceType aPersistenceType,
QM_TRY(info.mOriginDirectory->RenameTo(nullptr, originDirName)); QM_TRY(info.mOriginDirectory->RenameTo(nullptr, originDirName));
// XXX We don't check corruption here ?
QM_TRY(InitializeOrigin( QM_TRY(InitializeOrigin(
aPersistenceType, info.mFullOriginMetadata, info.mTimestamp, aPersistenceType, info.mFullOriginMetadata, info.mTimestamp,
info.mPersisted, targetDirectory)); info.mPersisted, targetDirectory));
std::forward<OriginFunc>(aOriginFunc)(info.mFullOriginMetadata);
return Ok{}; return Ok{};
}()), }()),
OK_IN_NIGHTLY_PROPAGATE_IN_OTHERS, statusKeeperFunc); OK_IN_NIGHTLY_PROPAGATE_IN_OTHERS, statusKeeperFunc);
@ -7095,77 +6999,6 @@ void QuotaManager::FinalizeOriginEviction(
} }
} }
Result<Ok, nsresult> QuotaManager::ArchiveOrigins(
const nsTArray<FullOriginMetadata>& aFullOriginMetadatas) {
AssertIsOnIOThread();
MOZ_ASSERT(!aFullOriginMetadatas.IsEmpty());
QM_TRY_INSPECT(const auto& storageArchivesDir,
QM_NewLocalFile(*mStorageArchivesPath));
// Create another subdir, so once we decide to remove all temporary archives,
// we can remove only the subdir and the parent directory can still be used
// for something else or similar in future. Otherwise, we would have to
// figure out a new name for it.
QM_TRY(storageArchivesDir->Append(u"0"_ns));
PRExplodedTime now;
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &now);
const auto dateStr =
nsPrintfCString("%04hd-%02" PRId32 "-%02" PRId32, now.tm_year,
now.tm_month + 1, now.tm_mday);
QM_TRY_INSPECT(
const auto& storageArchiveDir,
CloneFileAndAppend(*storageArchivesDir, NS_ConvertASCIItoUTF16(dateStr)));
QM_TRY(storageArchiveDir->CreateUnique(nsIFile::DIRECTORY_TYPE, 0700));
QM_TRY_INSPECT(const auto& defaultStorageArchiveDir,
CloneFileAndAppend(*storageArchiveDir,
nsLiteralString(DEFAULT_DIRECTORY_NAME)));
QM_TRY_INSPECT(const auto& temporaryStorageArchiveDir,
CloneFileAndAppend(*storageArchiveDir,
nsLiteralString(TEMPORARY_DIRECTORY_NAME)));
for (const auto& fullOriginMetadata : aFullOriginMetadatas) {
MOZ_ASSERT(
IsBestEffortPersistenceType(fullOriginMetadata.mPersistenceType));
QM_TRY_INSPECT(const auto& directory,
GetDirectoryForOrigin(fullOriginMetadata.mPersistenceType,
fullOriginMetadata.mOrigin));
// The origin could have been removed, for example due to corruption.
QM_TRY_INSPECT(
const auto& moved,
QM_OR_ELSE_WARN_IF(
// Expression.
ToResult(directory->MoveTo(fullOriginMetadata.mPersistenceType ==
PERSISTENCE_TYPE_DEFAULT
? defaultStorageArchiveDir
: temporaryStorageArchiveDir,
u""_ns))
.map([](Ok) { return true; }),
// Predicate.
([](const nsresult rv) {
return rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ||
rv == NS_ERROR_FILE_NOT_FOUND;
}),
// Fallback.
ErrToOk<false>));
if (moved) {
RemoveQuotaForOrigin(fullOriginMetadata.mPersistenceType,
fullOriginMetadata);
}
}
return Ok{};
}
auto QuotaManager::GetDirectoryLockTable(PersistenceType aPersistenceType) auto QuotaManager::GetDirectoryLockTable(PersistenceType aPersistenceType)
-> DirectoryLockTable& { -> DirectoryLockTable& {
switch (aPersistenceType) { switch (aPersistenceType) {
@ -7859,7 +7692,7 @@ StoragePressureRunnable::Run() {
return NS_OK; return NS_OK;
} }
TimeStamp RecordQuotaInfoLoadTimeHelper::Start() { void RecordQuotaInfoLoadTimeHelper::Start() {
AssertIsOnIOThread(); AssertIsOnIOThread();
// XXX: If a OS sleep/wake occur after mStartTime is initialized but before // XXX: If a OS sleep/wake occur after mStartTime is initialized but before
@ -7867,17 +7700,13 @@ TimeStamp RecordQuotaInfoLoadTimeHelper::Start() {
// key "Normal". We are assumming this is rather rare to happen. // key "Normal". We are assumming this is rather rare to happen.
mStartTime.init(TimeStamp::Now()); mStartTime.init(TimeStamp::Now());
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(this)); MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(this));
return *mStartTime;
} }
TimeStamp RecordQuotaInfoLoadTimeHelper::End() { void RecordQuotaInfoLoadTimeHelper::End() {
AssertIsOnIOThread(); AssertIsOnIOThread();
mEndTime.init(TimeStamp::Now()); mEndTime.init(TimeStamp::Now());
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(this)); MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(this));
return *mEndTime;
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -505,9 +505,7 @@ class QuotaManager final : public BackgroundThreadObject {
Result<Ok, nsresult> CreateEmptyLocalStorageArchive( Result<Ok, nsresult> CreateEmptyLocalStorageArchive(
nsIFile& aLsArchiveFile) const; nsIFile& aLsArchiveFile) const;
template <typename OriginFunc> nsresult InitializeRepository(PersistenceType aPersistenceType);
nsresult InitializeRepository(PersistenceType aPersistenceType,
OriginFunc&& aOriginFunc);
nsresult InitializeOrigin(PersistenceType aPersistenceType, nsresult InitializeOrigin(PersistenceType aPersistenceType,
const OriginMetadata& aOriginMetadata, const OriginMetadata& aOriginMetadata,
@ -533,9 +531,6 @@ class QuotaManager final : public BackgroundThreadObject {
void FinalizeOriginEviction(nsTArray<RefPtr<OriginDirectoryLock>>&& aLocks); void FinalizeOriginEviction(nsTArray<RefPtr<OriginDirectoryLock>>&& aLocks);
Result<Ok, nsresult> ArchiveOrigins(
const nsTArray<FullOriginMetadata>& aFullOriginMetadatas);
void ReleaseIOThreadObjects() { void ReleaseIOThreadObjects() {
AssertIsOnIOThread(); AssertIsOnIOThread();
@ -643,7 +638,6 @@ class QuotaManager final : public BackgroundThreadObject {
const nsString mStorageName; const nsString mStorageName;
LazyInitializedOnce<const nsString> mIndexedDBPath; LazyInitializedOnce<const nsString> mIndexedDBPath;
LazyInitializedOnce<const nsString> mStoragePath; LazyInitializedOnce<const nsString> mStoragePath;
LazyInitializedOnce<const nsString> mStorageArchivesPath;
LazyInitializedOnce<const nsString> mPermanentStoragePath; LazyInitializedOnce<const nsString> mPermanentStoragePath;
LazyInitializedOnce<const nsString> mTemporaryStoragePath; LazyInitializedOnce<const nsString> mTemporaryStoragePath;
LazyInitializedOnce<const nsString> mDefaultStoragePath; LazyInitializedOnce<const nsString> mDefaultStoragePath;

Просмотреть файл

@ -3,8 +3,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/ * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
const INT64_MIN = -0x8000000000000000n;
class RequestError extends Error { class RequestError extends Error {
constructor(resultCode, resultName) { constructor(resultCode, resultName) {
super(`Request failed (code: ${resultCode}, name: ${resultName})`); super(`Request failed (code: ${resultCode}, name: ${resultName})`);

Просмотреть файл

@ -3,8 +3,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/ * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
const PR_USEC_PER_SEC = 1000000;
const NS_ERROR_STORAGE_BUSY = Cr.NS_ERROR_STORAGE_BUSY; const NS_ERROR_STORAGE_BUSY = Cr.NS_ERROR_STORAGE_BUSY;
loadScript("dom/quota/test/common/global.js"); loadScript("dom/quota/test/common/global.js");

Просмотреть файл

@ -1,166 +0,0 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const SEC_PER_MONTH = 60 * 60 * 24 * 30;
async function testSteps() {
function getHostname(index) {
return "www.example" + index + ".com";
}
function getOrigin(index) {
return "https://" + getHostname(index);
}
function getOriginDir(index) {
return getRelativeFile("storage/default/https+++" + getHostname(index));
}
function updateOriginLastAccessTime(index, deltaSec) {
let originDir = getOriginDir(index);
let metadataFile = originDir.clone();
metadataFile.append(".metadata-v2");
let fileStream = Cc["@mozilla.org/network/file-stream;1"].createInstance(
Ci.nsIFileStream
);
fileStream.init(metadataFile, -1, -1, 0);
let binaryInputStream = Cc[
"@mozilla.org/binaryinputstream;1"
].createInstance(Ci.nsIBinaryInputStream);
binaryInputStream.setInputStream(fileStream);
let lastAccessTime = binaryInputStream.read64();
let seekableStream = fileStream.QueryInterface(Ci.nsISeekableStream);
seekableStream.seek(Ci.nsISeekableStream.NS_SEEK_SET, 0);
binaryOutputStream = Cc["@mozilla.org/binaryoutputstream;1"].createInstance(
Ci.nsIBinaryOutputStream
);
binaryOutputStream.setOutputStream(fileStream);
binaryOutputStream.write64(lastAccessTime + deltaSec * PR_USEC_PER_SEC);
binaryOutputStream.close();
binaryInputStream.close();
}
function verifyOriginDir(index, shouldExist) {
let originDir = getOriginDir(index);
let exists = originDir.exists();
if (shouldExist) {
ok(exists, "Origin directory does exist");
} else {
ok(!exists, "Origin directory doesn't exist");
}
}
info("Setting prefs");
Services.prefs.setBoolPref("dom.quotaManager.loadQuotaFromCache", false);
Services.prefs.setBoolPref("dom.quotaManager.checkQuotaInfoLoadTime", true);
Services.prefs.setIntPref(
"dom.quotaManager.longQuotaInfoLoadTimeThresholdMs",
0
);
info("Initializing");
request = init();
await requestFinished(request);
info("Initializing temporary storage");
request = initTemporaryStorage();
await requestFinished(request);
info("Initializing origins");
for (let index = 0; index < 30; index++) {
request = initTemporaryOrigin("default", getPrincipal(getOrigin(index)));
await requestFinished(request);
}
info("Updating last access time of selected origins");
for (let index = 0; index < 10; index++) {
updateOriginLastAccessTime(index, -14 * SEC_PER_MONTH);
}
for (let index = 10; index < 20; index++) {
updateOriginLastAccessTime(index, -7 * SEC_PER_MONTH);
}
info("Resetting");
request = reset();
await requestFinished(request);
info("Setting pref");
Services.prefs.setIntPref(
"dom.quotaManager.unaccessedForLongTimeThresholdSec",
13 * SEC_PER_MONTH
);
info("Initializing");
request = init();
await requestFinished(request);
info("Initializing temporary storage");
request = initTemporaryStorage();
await requestFinished(request);
info("Verifying origin directories");
for (let index = 0; index < 10; index++) {
verifyOriginDir(index, false);
}
for (let index = 10; index < 30; index++) {
verifyOriginDir(index, true);
}
info("Resetting");
request = reset();
await requestFinished(request);
info("Setting pref");
Services.prefs.setIntPref(
"dom.quotaManager.unaccessedForLongTimeThresholdSec",
6 * SEC_PER_MONTH
);
info("Initializing");
request = init();
await requestFinished(request);
info("Initializing temporary storage");
request = initTemporaryStorage();
await requestFinished(request);
info("Verifying origin directories");
for (let index = 0; index < 20; index++) {
verifyOriginDir(index, false);
}
for (let index = 20; index < 30; index++) {
verifyOriginDir(index, true);
}
info("Resetting");
request = reset();
await requestFinished(request);
}

Просмотреть файл

@ -1,65 +0,0 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
async function testSteps() {
const metadataFile = getRelativeFile(
"storage/default/https+++foo.example.com/.metadata-v2"
);
function getLastAccessTime() {
let fileInputStream = Cc[
"@mozilla.org/network/file-input-stream;1"
].createInstance(Ci.nsIFileInputStream);
fileInputStream.init(metadataFile, -1, -1, 0);
let binaryInputStream = Cc[
"@mozilla.org/binaryinputstream;1"
].createInstance(Ci.nsIBinaryInputStream);
binaryInputStream.setInputStream(fileInputStream);
return BigInt.asIntN(64, BigInt(binaryInputStream.read64()));
}
info("Clearing");
let request = clear();
await requestFinished(request);
info("Installing package");
// The profile contains one initialized origin directory, a script for origin
// initialization and the storage database:
// - storage/default/https+++foo.example.com
// - create_db.js
// - storage.sqlite
// The file create_db.js in the package was run locally, specifically it was
// temporarily added to xpcshell.ini and then executed:
// mach xpcshell-test --interactive dom/quota/test/xpcshell/create_db.js
// Note: to make it become the profile in the test, additional manual steps
// are needed.
// 1. Remove the folder "storage/temporary".
// 2. Remove the file "storage/ls-archive.sqlite".
installPackage("unsetLastAccessTime_profile");
info("Verifying last access time");
ok(getLastAccessTime() == INT64_MIN, "Correct last access time");
info("Initializing");
request = init();
await requestFinished(request);
info("Initializing temporary storage");
request = initTemporaryStorage();
await requestFinished(request);
info("Verifying last access time");
ok(getLastAccessTime() != INT64_MIN, "Correct last access time");
}

Двоичный файл не отображается.

Просмотреть файл

@ -22,7 +22,6 @@ support-files =
removeLocalStorage2_profile.zip removeLocalStorage2_profile.zip
tempMetadataCleanup_profile.zip tempMetadataCleanup_profile.zip
unknownFiles_profile.zip unknownFiles_profile.zip
unsetLastAccessTime_profile.zip
[make_unknownFiles.js] [make_unknownFiles.js]
skip-if = true # Only used for recreating unknownFiles_profile.zip skip-if = true # Only used for recreating unknownFiles_profile.zip
@ -49,7 +48,5 @@ skip-if = true # Only used for recreating unknownFiles_profile.zip
[test_specialOrigins.js] [test_specialOrigins.js]
[test_storagePressure.js] [test_storagePressure.js]
[test_tempMetadataCleanup.js] [test_tempMetadataCleanup.js]
[test_unaccessedOrigins.js]
[test_unknownFiles.js] [test_unknownFiles.js]
[test_unsetLastAccessTime.js]
[test_validOrigins.js] [test_validOrigins.js]

Просмотреть файл

@ -2805,17 +2805,6 @@
value: "storage" value: "storage"
mirror: never mirror: never
# An upper limit for the "age" of an origin. Any origin which is older than the
# threshold is considered as unaccessed. That doesn't necessarily mean that
# such origins will be immediatelly archived. They will be archived only when
# dom.quotaManager.checkQuotaInfoLoadTime is true and loading of quota info
# takes a long time (dom.quotaManager.longQuotaInfoLoadTimeThresholdMs is used
# to decide what is a long quota info load time).
- name: dom.quotaManager.unaccessedForLongTimeThresholdSec
type: RelaxedAtomicUint32
value: 33696000 # 13 months
mirror: always
# Should we try to load origin information from the cache? # Should we try to load origin information from the cache?
# See bug 1563023 for more details. # See bug 1563023 for more details.
- name: dom.quotaManager.loadQuotaFromCache - name: dom.quotaManager.loadQuotaFromCache
@ -2836,20 +2825,6 @@
value: true value: true
mirror: always mirror: always
# Should we check quota info load time and eventually archive some unaccessed
# origins if loading of quota info takes a long time ?
- name: dom.quotaManager.checkQuotaInfoLoadTime
type: RelaxedAtomicBool
value: true
mirror: always
# An upper limit for quota info load time, anything which takes longer than the
# threshold is considered as long quota info load time.
- name: dom.quotaManager.longQuotaInfoLoadTimeThresholdMs
type: RelaxedAtomicUint32
value: 21000 # 21 seconds
mirror: always
# Preference that users can set to override temporary storage smart limit # Preference that users can set to override temporary storage smart limit
# calculation. # calculation.
- name: dom.quotaManager.temporaryStorage.fixedLimit - name: dom.quotaManager.temporaryStorage.fixedLimit

Просмотреть файл

@ -901,14 +901,6 @@ nsSafeFileOutputStream::Finish() {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsFileStream // nsFileStream
nsresult nsFileStream::Create(nsISupports* aOuter, REFNSIID aIID,
void** aResult) {
NS_ENSURE_NO_AGGREGATION(aOuter);
RefPtr<nsFileStream> stream = new nsFileStream();
return stream->QueryInterface(aIID, aResult);
}
NS_IMPL_ISUPPORTS_INHERITED(nsFileStream, nsFileStreamBase, nsIInputStream, NS_IMPL_ISUPPORTS_INHERITED(nsFileStream, nsFileStreamBase, nsIInputStream,
nsIOutputStream, nsIFileStream) nsIOutputStream, nsIFileStream)

Просмотреть файл

@ -258,8 +258,6 @@ class nsFileStream : public nsFileStreamBase,
public nsIOutputStream, public nsIOutputStream,
public nsIFileStream { public nsIFileStream {
public: public:
static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIFILESTREAM NS_DECL_NSIFILESTREAM
NS_FORWARD_NSIINPUTSTREAM(nsFileStreamBase::) NS_FORWARD_NSIINPUTSTREAM(nsFileStreamBase::)

Просмотреть файл

@ -142,12 +142,6 @@ Classes = [
'legacy_constructor': 'nsFileOutputStream::Create', 'legacy_constructor': 'nsFileOutputStream::Create',
'headers': ['nsFileStreams.h'], 'headers': ['nsFileStreams.h'],
}, },
{
'cid': '{648705e9-757a-4d4b-a5bF-0248e512c309}',
'contract_ids': ['@mozilla.org/network/file-stream;1'],
'legacy_constructor': 'nsFileStream::Create',
'headers': ['nsFileStreams.h'],
},
{ {
'name': 'HttpActivityDistributor', 'name': 'HttpActivityDistributor',
'cid': '{15629ada-a41c-4a09-961f-6553cd60b1a2}', 'cid': '{15629ada-a41c-4a09-961f-6553cd60b1a2}',

Просмотреть файл

@ -342,14 +342,6 @@
} \ } \
} }
#define NS_LOCALFILESTREAM_CONTRACTID "@mozilla.org/network/file-stream;1"
#define NS_LOCALFILESTREAM_CID \
{ /* 648705e9-757a-4d4b-a5bF-0248e512c309 */ \
0x648705e9, 0x757a, 0x4d4b, { \
0xa5, 0xbF, 0x02, 0x48, 0xe5, 0x12, 0xc3, 0x09 \
} \
}
#define NS_BUFFEREDINPUTSTREAM_CONTRACTID \ #define NS_BUFFEREDINPUTSTREAM_CONTRACTID \
"@mozilla.org/network/buffered-input-stream;1" "@mozilla.org/network/buffered-input-stream;1"
#define NS_BUFFEREDINPUTSTREAM_CID \ #define NS_BUFFEREDINPUTSTREAM_CID \