"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "storage/mozStorageService.cpp" between
UXP-RELBASE_20210427.tar.gz and UXP-RELBASE_20210608.tar.gz

About: Basilisk is a full-featured, optimized browser derived from the code behind the pre-Servo Firefox browser (29–56 era). UXP = Unified XUL Platform. Source code.

mozStorageService.cpp  (UXP-RELBASE_20210427):mozStorageService.cpp  (UXP-RELBASE_20210608)
skipping to change at line 256 skipping to change at line 256
int32_t int32_t
Service::getSynchronousPref() Service::getSynchronousPref()
{ {
return sSynchronousPref; return sSynchronousPref;
} }
int32_t Service::sDefaultPageSize = PREF_TS_PAGESIZE_DEFAULT; int32_t Service::sDefaultPageSize = PREF_TS_PAGESIZE_DEFAULT;
Service::Service() Service::Service()
: mMutex("Service::mMutex") : mMutex("Service::mMutex")
, mSqliteVFS(nullptr)
, mRegistrationMutex("Service::mRegistrationMutex") , mRegistrationMutex("Service::mRegistrationMutex")
, mConnections() , mConnections()
{ {
} }
Service::~Service() Service::~Service()
{ {
mozilla::UnregisterWeakMemoryReporter(this); mozilla::UnregisterWeakMemoryReporter(this);
mozilla::UnregisterStorageSQLiteDistinguishedAmount(); 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 // Shutdown the sqlite3 API. Warn if shutdown did not turn out okay, but
// there is nothing actionable we can do in that case. // there is nothing actionable we can do in that case.
int rc = ::sqlite3_shutdown(); rc = ::sqlite3_shutdown();
if (rc != SQLITE_OK) if (rc != SQLITE_OK)
NS_WARNING("sqlite3 did not shutdown cleanly."); NS_WARNING("sqlite3 did not shutdown cleanly.");
DebugOnly<bool> shutdownObserved = !sXPConnect; DebugOnly<bool> shutdownObserved = !sXPConnect;
NS_ASSERTION(shutdownObserved, "Shutdown was not observed!"); NS_ASSERTION(shutdownObserved, "Shutdown was not observed!");
gService = nullptr; gService = nullptr;
delete mSqliteVFS;
mSqliteVFS = nullptr;
} }
void void
Service::registerConnection(Connection *aConnection) Service::registerConnection(Connection *aConnection)
{ {
mRegistrationMutex.AssertNotCurrentThreadOwns(); mRegistrationMutex.AssertNotCurrentThreadOwns();
MutexAutoLock mutex(mRegistrationMutex); MutexAutoLock mutex(mRegistrationMutex);
(void)mConnections.AppendElement(aConnection); (void)mConnections.AppendElement(aConnection);
} }
skipping to change at line 368 skipping to change at line 375
} }
} }
} }
void void
Service::shutdown() Service::shutdown()
{ {
NS_IF_RELEASE(sXPConnect); NS_IF_RELEASE(sXPConnect);
} }
sqlite3_vfs *ConstructTelemetryVFS();
#ifdef MOZ_STORAGE_MEMORY #ifdef MOZ_STORAGE_MEMORY
namespace { namespace {
// By default, SQLite tracks the size of all its heap blocks by adding an extra // By default, SQLite tracks the size of all its heap blocks by adding an extra
// 8 bytes at the start of the block to hold the size. Unfortunately, this // 8 bytes at the start of the block to hold the size. Unfortunately, this
// causes a lot of 2^N-sized allocations to be rounded up by jemalloc // causes a lot of 2^N-sized allocations to be rounded up by jemalloc
// allocator, wasting memory. For example, a request for 1024 bytes has 8 // allocator, wasting memory. For example, a request for 1024 bytes has 8
// bytes added, becoming a request for 1032 bytes, and jemalloc rounds this up // bytes added, becoming a request for 1032 bytes, and jemalloc rounds this up
// to 2048 bytes, wasting 1012 bytes. (See bug 676189 for more details.) // to 2048 bytes, wasting 1012 bytes. (See bug 676189 for more details.)
skipping to change at line 475 skipping to change at line 484
// have figured the impact on our consumers and memory. // have figured the impact on our consumers and memory.
sqlite3_config(SQLITE_CONFIG_PAGECACHE, NULL, 0, 0); sqlite3_config(SQLITE_CONFIG_PAGECACHE, NULL, 0, 0);
// Explicitly initialize sqlite3. Although this is implicitly called by // Explicitly initialize sqlite3. Although this is implicitly called by
// various sqlite3 functions (and the sqlite3_open calls in our case), // various sqlite3 functions (and the sqlite3_open calls in our case),
// the documentation suggests calling this directly. So we do. // the documentation suggests calling this directly. So we do.
rc = ::sqlite3_initialize(); rc = ::sqlite3_initialize();
if (rc != SQLITE_OK) if (rc != SQLITE_OK)
return convertResultCode(rc); 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 // Register for xpcom-shutdown so we can cleanup after ourselves. The
// observer service can only be used on the main thread. // observer service can only be used on the main thread.
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
NS_ENSURE_TRUE(os, NS_ERROR_FAILURE); NS_ENSURE_TRUE(os, NS_ERROR_FAILURE);
for (size_t i = 0; i < ArrayLength(sObserverTopics); ++i) { for (size_t i = 0; i < ArrayLength(sObserverTopics); ++i) {
nsresult rv = os->AddObserver(this, sObserverTopics[i], false); nsresult rv = os->AddObserver(this, sObserverTopics[i], false);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
 End of changes. 6 change blocks. 
1 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)