Bug 1888878 - Bring back nsIIndexedDatabaseManager; r=dom-storage-reviewers,asuth

Differential Revision: https://phabricator.services.mozilla.com/D206224
This commit is contained in:
Jan Varga 2024-06-20 07:28:39 +00:00
Родитель f318180137
Коммит 902e0bf65c
5 изменённых файлов: 57 добавлений и 2 удалений

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

@ -281,6 +281,13 @@ IndexedDatabaseManager* IndexedDatabaseManager::Get() {
return gDBManager;
}
// static
already_AddRefed<IndexedDatabaseManager>
IndexedDatabaseManager::FactoryCreate() {
RefPtr<IndexedDatabaseManager> indexedDatabaseManager = GetOrCreate();
return indexedDatabaseManager.forget();
}
nsresult IndexedDatabaseManager::Init() {
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -646,6 +653,10 @@ nsresult IndexedDatabaseManager::FlushPendingFileDeletions() {
return NS_OK;
}
NS_IMPL_ADDREF(IndexedDatabaseManager)
NS_IMPL_RELEASE_WITH_DESTROY(IndexedDatabaseManager, Destroy())
NS_IMPL_QUERY_INTERFACE(IndexedDatabaseManager, nsIIndexedDatabaseManager)
// static
void IndexedDatabaseManager::LoggingModePrefChangedCallback(
const char* /* aPrefName */, void* /* aClosure */) {

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

@ -14,6 +14,7 @@
#include "mozilla/Mutex.h"
#include "nsClassHashtable.h"
#include "nsHashKeys.h"
#include "nsIIndexedDatabaseManager.h"
#include "SafeRefPtr.h"
namespace mozilla {
@ -32,7 +33,7 @@ class FileManagerInfo;
} // namespace indexedDB
class IndexedDatabaseManager final {
class IndexedDatabaseManager final : public nsIIndexedDatabaseManager {
using PersistenceType = mozilla::dom::quota::PersistenceType;
using DatabaseFileManager = mozilla::dom::indexedDB::DatabaseFileManager;
using FileManagerInfo = mozilla::dom::indexedDB::FileManagerInfo;
@ -46,7 +47,8 @@ class IndexedDatabaseManager final {
Logging_DetailedProfilerMarks
};
NS_INLINE_DECL_REFCOUNTING_WITH_DESTROY(IndexedDatabaseManager, Destroy())
NS_DECL_ISUPPORTS
NS_DECL_NSIINDEXEDDATABASEMANAGER
// Returns a non-owning reference.
static IndexedDatabaseManager* GetOrCreate();
@ -54,6 +56,9 @@ class IndexedDatabaseManager final {
// Returns a non-owning reference.
static IndexedDatabaseManager* Get();
// No one should call this but the factory.
static already_AddRefed<IndexedDatabaseManager> FactoryCreate();
static bool IsClosed();
static bool IsMainProcess()

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

@ -0,0 +1,17 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
Classes = [
{
'cid': '{1a26a7b7-d06e-4f45-8b45-d7ad60f7a9ab}',
'contract_ids': ['@mozilla.org/dom/indexeddb/manager;1'],
'interfaces': ['nsIIndexedDatabaseManager'],
'singleton': True,
'type': 'mozilla::dom::IndexedDatabaseManager',
'headers': ['mozilla/dom/IndexedDatabaseManager.h'],
'constructor': 'mozilla::dom::IndexedDatabaseManager::FactoryCreate',
},
]

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

@ -26,6 +26,12 @@ XPCSHELL_TESTS_MANIFESTS += [
TEST_DIRS += ["test/gtest"]
XPIDL_SOURCES += [
"nsIIndexedDatabaseManager.idl",
]
XPIDL_MODULE = "dom_indexeddb"
EXPORTS.mozilla.dom += [
"DatabaseFileInfoFwd.h",
"FlippedOnce.h",
@ -54,6 +60,10 @@ EXPORTS.mozilla.dom.indexedDB += [
"ThreadLocal.h",
]
XPCOM_MANIFESTS += [
"components.conf",
]
UNIFIED_SOURCES += [
"ActorsChild.cpp",
"ActorsParentCommon.cpp",

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

@ -0,0 +1,12 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=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/. */
#include "nsISupports.idl"
[scriptable, builtinclass, uuid(6c62d204-cb7f-4762-8703-ebcccdd88Bde)]
interface nsIIndexedDatabaseManager : nsISupports
{
};