Revert "Issue #21 - Remove TelemertyVFS"

This:
- reverts commit 83ecae9ff7ee1469da1675435dbcf26d094aa1c6
- adds a failure check to Connection::GetQuotaObjects

This resolves #1768.
This commit is contained in:
Moonchild 2021-05-14 00:02:03 +00:00 committed by roytam1
commit 90df4cfb70
9 changed files with 1286 additions and 1 deletions

View file

@ -253,6 +253,7 @@ int32_t Service::sDefaultPageSize = PREF_TS_PAGESIZE_DEFAULT;
Service::Service()
: mMutex("Service::mMutex")
, mSqliteVFS(nullptr)
, mRegistrationMutex("Service::mRegistrationMutex")
, mConnections()
{
@ -263,9 +264,13 @@ Service::~Service()
mozilla::UnregisterWeakMemoryReporter(this);
mozilla::UnregisterStorageSQLiteDistinguishedAmount();
int rc = sqlite3_vfs_unregister(mSqliteVFS);
if (rc != SQLITE_OK)
NS_WARNING("Failed to unregister sqlite vfs wrapper.");
// Shutdown the sqlite3 API. Warn if shutdown did not turn out okay, but
// there is nothing actionable we can do in that case.
int rc = ::sqlite3_shutdown();
rc = ::sqlite3_shutdown();
if (rc != SQLITE_OK)
NS_WARNING("sqlite3 did not shutdown cleanly.");
@ -273,6 +278,8 @@ Service::~Service()
NS_ASSERTION(shutdownObserved, "Shutdown was not observed!");
gService = nullptr;
delete mSqliteVFS;
mSqliteVFS = nullptr;
}
void
@ -365,6 +372,8 @@ Service::shutdown()
NS_IF_RELEASE(sXPConnect);
}
sqlite3_vfs *ConstructTelemetryVFS();
#ifdef MOZ_STORAGE_MEMORY
namespace {
@ -472,6 +481,15 @@ Service::initialize()
if (rc != SQLITE_OK)
return convertResultCode(rc);
mSqliteVFS = ConstructTelemetryVFS();
if (mSqliteVFS) {
rc = sqlite3_vfs_register(mSqliteVFS, 1);
if (rc != SQLITE_OK)
return convertResultCode(rc);
} else {
NS_WARNING("Failed to register telemetry VFS");
}
// Register for xpcom-shutdown so we can cleanup after ourselves. The
// observer service can only be used on the main thread.
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();