forked from mirrors/gecko-dev
This patch makes use of the IsValidPersistenceType function it adds at places where individual checks were done before. It also moves some checks to the parameter validation phase. Differential Revision: https://phabricator.services.mozilla.com/D66947 --HG-- extra : moz-landing-system : lando
62 lines
2.1 KiB
C
62 lines
2.1 KiB
C
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef mozilla_dom_quota_persistencetype_h__
|
|
#define mozilla_dom_quota_persistencetype_h__
|
|
|
|
#include "mozilla/dom/quota/QuotaCommon.h"
|
|
|
|
#include "mozilla/dom/StorageTypeBinding.h"
|
|
|
|
BEGIN_QUOTA_NAMESPACE
|
|
|
|
enum PersistenceType {
|
|
PERSISTENCE_TYPE_PERSISTENT = 0,
|
|
PERSISTENCE_TYPE_TEMPORARY,
|
|
PERSISTENCE_TYPE_DEFAULT,
|
|
|
|
// Only needed for IPC serialization helper, should never be used in code.
|
|
PERSISTENCE_TYPE_INVALID
|
|
};
|
|
|
|
static const PersistenceType kBestEffortPersistenceTypes[] = {
|
|
PERSISTENCE_TYPE_TEMPORARY, PERSISTENCE_TYPE_DEFAULT};
|
|
|
|
static const PersistenceType kAllPersistenceTypes[] = {
|
|
PERSISTENCE_TYPE_PERSISTENT, PERSISTENCE_TYPE_TEMPORARY,
|
|
PERSISTENCE_TYPE_DEFAULT};
|
|
|
|
bool IsValidPersistenceType(PersistenceType aPersistenceType);
|
|
|
|
nsLiteralCString PersistenceTypeToString(PersistenceType aPersistenceType);
|
|
|
|
Maybe<PersistenceType> PersistenceTypeFromString(const nsACString& aString,
|
|
const fallible_t&);
|
|
|
|
PersistenceType PersistenceTypeFromString(const nsACString& aString);
|
|
|
|
StorageType PersistenceTypeToStorageType(PersistenceType aPersistenceType);
|
|
|
|
PersistenceType PersistenceTypeFromStorageType(StorageType aStorageType);
|
|
|
|
Maybe<PersistenceType> PersistenceTypeFromInt32(int32_t aInt32,
|
|
const fallible_t&);
|
|
|
|
inline PersistenceType ComplementaryPersistenceType(
|
|
const PersistenceType aPersistenceType) {
|
|
MOZ_ASSERT(aPersistenceType == PERSISTENCE_TYPE_DEFAULT ||
|
|
aPersistenceType == PERSISTENCE_TYPE_TEMPORARY);
|
|
|
|
if (aPersistenceType == PERSISTENCE_TYPE_DEFAULT) {
|
|
return PERSISTENCE_TYPE_TEMPORARY;
|
|
}
|
|
|
|
return PERSISTENCE_TYPE_DEFAULT;
|
|
}
|
|
|
|
END_QUOTA_NAMESPACE
|
|
|
|
#endif // mozilla_dom_quota_persistencetype_h__
|