DirectoryLockCategory.h (2388B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef DOM_QUOTA_DIRECTORYLOCKCATEGORY_H_ 8 #define DOM_QUOTA_DIRECTORYLOCKCATEGORY_H_ 9 10 #include "mozilla/EnumSet.h" 11 12 namespace mozilla::dom::quota { 13 14 enum class DirectoryLockCategory : uint8_t { 15 None = 0, 16 // Used by operations which uninitialize storage. 17 UninitStorage, 18 // Used by operations which uninitialize origins. 19 UninitOrigins, 20 // Used by operations which uninitialize clients. 21 UninitClients, 22 }; 23 24 // Pre-defined sets used for doing IsBlockedBy checks in OpenClientDirectory 25 // and in individual initialization methods. 26 // 27 // These sets account for the containment hierarchy between uninitialization 28 // operations: 29 // - Storage uninitialization implicitly uninitializes all origins and clients. 30 // - Origin uninitialization implicitly uninitializes all clients. 31 // Therefore, checks for a given category must include any broader categories 32 // that would also invalidate the target state. 33 34 // Used to check if creation and execution of storage initialization can be 35 // avoided if the storage has been already initialized. 36 constexpr EnumSet<DirectoryLockCategory> kUninitStorageOnlyCategory = { 37 DirectoryLockCategory::UninitStorage}; 38 39 // Used to check if creation and execution of origin initialization can be 40 // avoided if the origin has been already initialized. 41 // 42 // Includes UninitStorage because storage-level uninitialization also 43 // uninitializes origins. 44 constexpr EnumSet<DirectoryLockCategory> kUninitOriginsAndBroaderCategories = { 45 DirectoryLockCategory::UninitOrigins, DirectoryLockCategory::UninitStorage}; 46 47 // Used to check if creation and execution of client initialization can be 48 // avoided if the client has been already initialized. 49 // 50 // Includes UninitOrigins and UninitStorage because both implicitly uninitialize 51 // clients. 52 constexpr EnumSet<DirectoryLockCategory> kUninitClientsAndBroaderCategories = { 53 DirectoryLockCategory::UninitClients, DirectoryLockCategory::UninitOrigins, 54 DirectoryLockCategory::UninitStorage}; 55 56 } // namespace mozilla::dom::quota 57 58 #endif // DOM_QUOTA_DIRECTORYLOCKCATEGORY_H_