зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1423917 - P9 - Remove asmjs client in the 2_1to2_2 upgrade for QuotaManager; r=luke
Differential Revision: https://phabricator.services.mozilla.com/D21732 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
2019dc0bc0
Коммит
3b352c7bbf
|
@ -106,46 +106,6 @@ nsresult WriteMetadataFile(nsIFile* aMetadataFile, const Metadata& aMetadata) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult ReadMetadataFile(nsIFile* aMetadataFile, Metadata& aMetadata) {
|
||||
int32_t openFlags = PR_RDONLY;
|
||||
|
||||
ScopedPRFileDesc fd;
|
||||
nsresult rv = aMetadataFile->OpenNSPRFileDesc(openFlags, 0644, &fd.rwget());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Read the buildid and check that it matches the current buildid
|
||||
|
||||
JS::BuildIdCharVector currentBuildId;
|
||||
bool ok = GetBuildId(¤tBuildId);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
uint32_t length;
|
||||
int32_t bytesRead = PR_Read(fd, &length, sizeof(length));
|
||||
NS_ENSURE_TRUE(bytesRead == sizeof(length), NS_ERROR_UNEXPECTED);
|
||||
|
||||
NS_ENSURE_TRUE(currentBuildId.length() == length, NS_ERROR_UNEXPECTED);
|
||||
|
||||
JS::BuildIdCharVector fileBuildId;
|
||||
ok = fileBuildId.resize(length);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
bytesRead = PR_Read(fd, fileBuildId.begin(), length);
|
||||
NS_ENSURE_TRUE(bytesRead == int32_t(length), NS_ERROR_UNEXPECTED);
|
||||
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
if (currentBuildId[i] != fileBuildId[i]) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
// Read the Metadata struct
|
||||
|
||||
bytesRead = PR_Read(fd, &aMetadata, sizeof(aMetadata));
|
||||
NS_ENSURE_TRUE(bytesRead == sizeof(aMetadata), NS_ERROR_UNEXPECTED);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult GetCacheFile(nsIFile* aDirectory, unsigned aModuleIndex,
|
||||
nsIFile** aCacheFile) {
|
||||
nsCOMPtr<nsIFile> cacheFile;
|
||||
|
@ -715,50 +675,9 @@ nsresult ParentRunnable::ReadMetadata() {
|
|||
return rv;
|
||||
}
|
||||
|
||||
rv = mDirectory->Append(NS_LITERAL_STRING(ASMJSCACHE_DIRECTORY_NAME));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool exists;
|
||||
rv = mDirectory->Exists(&exists);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!exists) {
|
||||
rv = mDirectory->Create(nsIFile::DIRECTORY_TYPE, 0755);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
DebugOnly<bool> isDirectory;
|
||||
MOZ_ASSERT(NS_SUCCEEDED(mDirectory->IsDirectory(&isDirectory)));
|
||||
MOZ_ASSERT(isDirectory, "Should have caught this earlier!");
|
||||
}
|
||||
|
||||
rv = mDirectory->Clone(getter_AddRefs(mMetadataFile));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mMetadataFile->Append(NS_LITERAL_STRING(ASMJSCACHE_METADATA_FILE_NAME));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mMetadataFile->Exists(&exists);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (exists && NS_FAILED(ReadMetadataFile(mMetadataFile, mMetadata))) {
|
||||
exists = false;
|
||||
}
|
||||
|
||||
if (!exists) {
|
||||
// If we are reading, we can't possibly have a cache hit.
|
||||
if (mOpenMode == eOpenForRead) {
|
||||
return NS_ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
// Initialize Metadata with a valid empty state for the LRU cache.
|
||||
for (unsigned i = 0; i < Metadata::kNumEntries; i++) {
|
||||
Metadata::Entry& entry = mMetadata.mEntries[i];
|
||||
entry.mModuleIndex = i;
|
||||
entry.clear();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
// XXX Bug 1520931 will fully remove asmjs. Just stop creating any new storage
|
||||
// here.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult ParentRunnable::OpenCacheFileForWrite() {
|
||||
|
|
|
@ -3,8 +3,12 @@ support-files =
|
|||
file_slow.js
|
||||
|
||||
[test_cachingBasic.html]
|
||||
disabled = bug 1520931
|
||||
[test_workers.html]
|
||||
disabled = bug 1520931
|
||||
[test_cachingMulti.html]
|
||||
disabled = bug 1520931
|
||||
[test_slow.html]
|
||||
# bug 929498
|
||||
skip-if = os == 'android'
|
||||
disabled = bug 1520931
|
||||
|
|
|
@ -1513,6 +1513,10 @@ class RepositoryOperationBase : public StorageOperationBase {
|
|||
private:
|
||||
virtual nsresult PrepareOriginDirectory(OriginProps& aOriginProps,
|
||||
bool* aRemoved) = 0;
|
||||
|
||||
virtual nsresult PrepareClientDirectory(nsIFile* aFile,
|
||||
const nsAString& aLeafName,
|
||||
bool& aRemoved);
|
||||
};
|
||||
|
||||
class CreateOrUpgradeDirectoryMetadataHelper final
|
||||
|
@ -1585,6 +1589,9 @@ class UpgradeStorageFrom2_1To2_2Helper final : public RepositoryOperationBase {
|
|||
bool* aRemoved) override;
|
||||
|
||||
nsresult ProcessOriginDirectory(const OriginProps& aOriginProps) override;
|
||||
|
||||
nsresult PrepareClientDirectory(nsIFile* aFile, const nsAString& aLeafName,
|
||||
bool& aRemoved) override;
|
||||
};
|
||||
|
||||
class RestoreDirectoryMetadata2Helper final : public StorageOperationBase {
|
||||
|
@ -4375,7 +4382,8 @@ nsresult QuotaManager::UpgradeStorageFrom2_1To2_2(
|
|||
AssertIsOnIOThread();
|
||||
MOZ_ASSERT(aConnection);
|
||||
|
||||
// The upgrade is mainly to clean obsolete origins in the repositoies.
|
||||
// The upgrade is mainly to clean obsolete origins in the repositoies, remove
|
||||
// asmjs client, and ".tmp" file in the idb folers.
|
||||
|
||||
nsresult rv = UpgradeStorage<UpgradeStorageFrom2_1To2_2Helper>(
|
||||
MakeStorageVersion(2, 1), MakeStorageVersion(2, 2), aConnection);
|
||||
|
@ -8765,6 +8773,12 @@ nsresult RepositoryOperationBase::MaybeUpgradeClients(
|
|||
continue;
|
||||
}
|
||||
|
||||
bool removed;
|
||||
rv = PrepareClientDirectory(file, leafName, removed);
|
||||
if (NS_FAILED(rv) || removed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Client::Type clientType;
|
||||
rv = Client::TypeFromText(leafName, clientType);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -8784,6 +8798,14 @@ nsresult RepositoryOperationBase::MaybeUpgradeClients(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult RepositoryOperationBase::PrepareClientDirectory(
|
||||
nsIFile* aFile, const nsAString& aLeafName, bool& aRemoved) {
|
||||
AssertIsOnIOThread();
|
||||
|
||||
aRemoved = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CreateOrUpgradeDirectoryMetadataHelper::MaybeUpgradeOriginDirectory(
|
||||
nsIFile* aDirectory) {
|
||||
AssertIsOnIOThread();
|
||||
|
@ -9371,12 +9393,18 @@ nsresult UpgradeStorageFrom2_1To2_2Helper::PrepareOriginDirectory(
|
|||
MOZ_ASSERT(aOriginProps.mDirectory);
|
||||
MOZ_ASSERT(aRemoved);
|
||||
|
||||
nsresult rv =
|
||||
MaybeUpgradeClients(aOriginProps, &Client::UpgradeStorageFrom2_1To2_2);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
int64_t timestamp;
|
||||
nsCString group;
|
||||
nsCString origin;
|
||||
Nullable<bool> isApp;
|
||||
nsresult rv = GetDirectoryMetadata(aOriginProps.mDirectory, timestamp, group,
|
||||
origin, isApp);
|
||||
rv = GetDirectoryMetadata(aOriginProps.mDirectory, timestamp, group, origin,
|
||||
isApp);
|
||||
if (NS_FAILED(rv) || isApp.IsNull()) {
|
||||
aOriginProps.mNeedsRestore = true;
|
||||
}
|
||||
|
@ -9424,6 +9452,24 @@ nsresult UpgradeStorageFrom2_1To2_2Helper::ProcessOriginDirectory(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult UpgradeStorageFrom2_1To2_2Helper::PrepareClientDirectory(
|
||||
nsIFile* aFile, const nsAString& aLeafName, bool& aRemoved) {
|
||||
AssertIsOnIOThread();
|
||||
|
||||
if (Client::IsDeprecatedClient(aLeafName)) {
|
||||
nsresult rv = aFile->Remove(true);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
aRemoved = true;
|
||||
} else {
|
||||
aRemoved = false;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult RestoreDirectoryMetadata2Helper::RestoreMetadata2File() {
|
||||
AssertIsOnIOThread();
|
||||
|
||||
|
|
|
@ -18,11 +18,13 @@ class nsIFile;
|
|||
class nsIRunnable;
|
||||
|
||||
#define IDB_DIRECTORY_NAME "idb"
|
||||
#define ASMJSCACHE_DIRECTORY_NAME "asmjs"
|
||||
#define DOMCACHE_DIRECTORY_NAME "cache"
|
||||
#define SDB_DIRECTORY_NAME "sdb"
|
||||
#define LS_DIRECTORY_NAME "ls"
|
||||
|
||||
// Deprecated
|
||||
#define ASMJSCACHE_DIRECTORY_NAME "asmjs"
|
||||
|
||||
BEGIN_QUOTA_NAMESPACE
|
||||
|
||||
class OriginScope;
|
||||
|
@ -63,10 +65,6 @@ class Client {
|
|||
aText.AssignLiteral(IDB_DIRECTORY_NAME);
|
||||
break;
|
||||
|
||||
case ASMJS:
|
||||
aText.AssignLiteral(ASMJSCACHE_DIRECTORY_NAME);
|
||||
break;
|
||||
|
||||
case DOMCACHE:
|
||||
aText.AssignLiteral(DOMCACHE_DIRECTORY_NAME);
|
||||
break;
|
||||
|
@ -94,8 +92,6 @@ class Client {
|
|||
static nsresult TypeFromText(const nsAString& aText, Type& aType) {
|
||||
if (aText.EqualsLiteral(IDB_DIRECTORY_NAME)) {
|
||||
aType = IDB;
|
||||
} else if (aText.EqualsLiteral(ASMJSCACHE_DIRECTORY_NAME)) {
|
||||
aType = ASMJS;
|
||||
} else if (aText.EqualsLiteral(DOMCACHE_DIRECTORY_NAME)) {
|
||||
aType = DOMCACHE;
|
||||
} else if (aText.EqualsLiteral(SDB_DIRECTORY_NAME)) {
|
||||
|
@ -104,6 +100,7 @@ class Client {
|
|||
aText.EqualsLiteral(LS_DIRECTORY_NAME)) {
|
||||
aType = LS;
|
||||
} else {
|
||||
MOZ_RELEASE_ASSERT(!IsDeprecatedClient(aText));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -127,6 +124,10 @@ class Client {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static bool IsDeprecatedClient(const nsAString& aText) {
|
||||
return aText.EqualsLiteral(ASMJSCACHE_DIRECTORY_NAME);
|
||||
}
|
||||
|
||||
// Methods which are called on the IO thread.
|
||||
virtual nsresult UpgradeStorageFrom1_0To2_0(nsIFile* aDirectory) {
|
||||
return NS_OK;
|
||||
|
@ -136,6 +137,10 @@ class Client {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
virtual nsresult UpgradeStorageFrom2_1To2_2(nsIFile* aDirectory) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
virtual nsresult InitOrigin(PersistenceType aPersistenceType,
|
||||
const nsACString& aGroup,
|
||||
const nsACString& aOrigin,
|
||||
|
|
|
@ -12,7 +12,9 @@ async function testSteps()
|
|||
{
|
||||
const obsoleteOriginPaths = [
|
||||
"storage/default/chrome+++content+browser.xul/",
|
||||
"storage/default/moz-safe-about+++home/"
|
||||
"storage/default/moz-safe-about+++home/",
|
||||
// Deprecated client
|
||||
"storage/default/https+++example.com/asmjs/"
|
||||
];
|
||||
const invalidOriginPath = "storage/default/invalid+++example.com/"
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче