Loading storage/mozStorageConnection.cpp +19 −9 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ #include "nsIFileURL.h" #include "nsIXPConnect.h" #include "mozilla/AppShutdown.h" #include "mozilla/CheckedInt.h" #include "mozilla/Telemetry.h" #include "mozilla/Mutex.h" #include "mozilla/CondVar.h" Loading Loading @@ -138,14 +139,21 @@ int sqlite3_T_double(sqlite3_context* aCtx, double aValue) { } int sqlite3_T_text(sqlite3_context* aCtx, const nsCString& aValue) { ::sqlite3_result_text(aCtx, aValue.get(), aValue.Length(), SQLITE_TRANSIENT); CheckedInt<int32_t> length(aValue.Length()); if (!length.isValid()) { return SQLITE_MISUSE; } ::sqlite3_result_text(aCtx, aValue.get(), length.value(), SQLITE_TRANSIENT); return SQLITE_OK; } int sqlite3_T_text16(sqlite3_context* aCtx, const nsString& aValue) { ::sqlite3_result_text16( aCtx, aValue.get(), aValue.Length() * sizeof(char16_t), // Number of bytes. CheckedInt<int32_t> n_bytes = CheckedInt<int32_t>(aValue.Length()) * sizeof(char16_t); if (!n_bytes.isValid()) { return SQLITE_MISUSE; } ::sqlite3_result_text16(aCtx, aValue.get(), n_bytes.value(), SQLITE_TRANSIENT); return SQLITE_OK; } Loading Loading @@ -1395,8 +1403,9 @@ int Connection::stepStatement(sqlite3* aNativeConnection, : Telemetry::kSlowSQLThresholdForHelperThreads; if (duration.ToMilliseconds() >= threshold) { nsDependentCString statementString(::sqlite3_sql(aStatement)); Telemetry::RecordSlowSQLStatement(statementString, mTelemetryFilename, duration.ToMilliseconds()); Telemetry::RecordSlowSQLStatement( statementString, mTelemetryFilename, static_cast<uint32_t>(duration.ToMilliseconds())); } (void)::sqlite3_extended_result_codes(aNativeConnection, 0); Loading Loading @@ -1474,8 +1483,9 @@ int Connection::executeSql(sqlite3* aNativeConnection, const char* aSqlString) { : Telemetry::kSlowSQLThresholdForHelperThreads; if (duration.ToMilliseconds() >= threshold) { nsDependentCString statementString(aSqlString); Telemetry::RecordSlowSQLStatement(statementString, mTelemetryFilename, duration.ToMilliseconds()); Telemetry::RecordSlowSQLStatement( statementString, mTelemetryFilename, static_cast<uint32_t>(duration.ToMilliseconds())); } return srv; Loading storage/mozStorageService.cpp +7 −6 Original line number Diff line number Diff line Loading @@ -147,7 +147,7 @@ Service::CollectReports(nsIHandleReportCallback* aHandleReport, #endif } int64_t other = ::sqlite3_memory_used() - totalConnSize; int64_t other = static_cast<int64_t>(::sqlite3_memory_used() - totalConnSize); MOZ_COLLECT_REPORT("explicit/storage/sqlite/other", KIND_HEAP, UNITS_BYTES, other, "All unclassified sqlite memory."); Loading Loading @@ -202,7 +202,8 @@ Service::AutoVFSRegistration::~AutoVFSRegistration() { Service::Service() : mMutex("Service::mMutex"), mRegistrationMutex("Service::mRegistrationMutex"), mConnections() {} mConnections(), mLastSensitivity(mozilla::intl::Collator::Sensitivity::Base) {} Service::~Service() { mozilla::UnregisterWeakMemoryReporter(this); Loading Loading @@ -375,8 +376,8 @@ nsresult Service::initialize() { nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); NS_ENSURE_TRUE(os, NS_ERROR_FAILURE); for (size_t i = 0; i < ArrayLength(sObserverTopics); ++i) { nsresult rv = os->AddObserver(this, sObserverTopics[i], false); for (auto& sObserverTopic : sObserverTopics) { nsresult rv = os->AddObserver(this, sObserverTopic, false); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } Loading Loading @@ -740,8 +741,8 @@ Service::Observe(nsISupports*, const char* aTopic, const char16_t*) { nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); for (size_t i = 0; i < ArrayLength(sObserverTopics); ++i) { (void)os->RemoveObserver(this, sObserverTopics[i]); for (auto& sObserverTopic : sObserverTopics) { (void)os->RemoveObserver(this, sObserverTopic); } SpinEventLoopUntil("storage::Service::Observe(xpcom-shutdown-threads)"_ns, Loading storage/mozStorageService.h +2 −4 Original line number Diff line number Diff line Loading @@ -24,8 +24,7 @@ namespace mozilla::intl { class Collator; } namespace mozilla { namespace storage { namespace mozilla::storage { class Connection; class Service : public mozIStorageService, Loading Loading @@ -179,7 +178,6 @@ class Service : public mozIStorageService, mozilla::intl::Collator::Sensitivity mLastSensitivity; }; } // namespace storage } // namespace mozilla } // namespace mozilla::storage #endif /* MOZSTORAGESERVICE_H */ storage/test/gtest/storage_test_harness.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -186,16 +186,18 @@ nsIThread* last_non_watched_thread = nullptr; * call the real mutex function. */ extern "C" void wrapped_MutexEnter(sqlite3_mutex* mutex) { if (PR_GetCurrentThread() == watched_thread) if (PR_GetCurrentThread() == watched_thread) { mutex_used_on_watched_thread = true; else } else { last_non_watched_thread = NS_GetCurrentThread(); } orig_mutex_methods.xMutexEnter(mutex); } extern "C" int wrapped_MutexTry(sqlite3_mutex* mutex) { if (::PR_GetCurrentThread() == watched_thread) if (::PR_GetCurrentThread() == watched_thread) { mutex_used_on_watched_thread = true; } return orig_mutex_methods.xMutexTry(mutex); } Loading Loading
storage/mozStorageConnection.cpp +19 −9 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ #include "nsIFileURL.h" #include "nsIXPConnect.h" #include "mozilla/AppShutdown.h" #include "mozilla/CheckedInt.h" #include "mozilla/Telemetry.h" #include "mozilla/Mutex.h" #include "mozilla/CondVar.h" Loading Loading @@ -138,14 +139,21 @@ int sqlite3_T_double(sqlite3_context* aCtx, double aValue) { } int sqlite3_T_text(sqlite3_context* aCtx, const nsCString& aValue) { ::sqlite3_result_text(aCtx, aValue.get(), aValue.Length(), SQLITE_TRANSIENT); CheckedInt<int32_t> length(aValue.Length()); if (!length.isValid()) { return SQLITE_MISUSE; } ::sqlite3_result_text(aCtx, aValue.get(), length.value(), SQLITE_TRANSIENT); return SQLITE_OK; } int sqlite3_T_text16(sqlite3_context* aCtx, const nsString& aValue) { ::sqlite3_result_text16( aCtx, aValue.get(), aValue.Length() * sizeof(char16_t), // Number of bytes. CheckedInt<int32_t> n_bytes = CheckedInt<int32_t>(aValue.Length()) * sizeof(char16_t); if (!n_bytes.isValid()) { return SQLITE_MISUSE; } ::sqlite3_result_text16(aCtx, aValue.get(), n_bytes.value(), SQLITE_TRANSIENT); return SQLITE_OK; } Loading Loading @@ -1395,8 +1403,9 @@ int Connection::stepStatement(sqlite3* aNativeConnection, : Telemetry::kSlowSQLThresholdForHelperThreads; if (duration.ToMilliseconds() >= threshold) { nsDependentCString statementString(::sqlite3_sql(aStatement)); Telemetry::RecordSlowSQLStatement(statementString, mTelemetryFilename, duration.ToMilliseconds()); Telemetry::RecordSlowSQLStatement( statementString, mTelemetryFilename, static_cast<uint32_t>(duration.ToMilliseconds())); } (void)::sqlite3_extended_result_codes(aNativeConnection, 0); Loading Loading @@ -1474,8 +1483,9 @@ int Connection::executeSql(sqlite3* aNativeConnection, const char* aSqlString) { : Telemetry::kSlowSQLThresholdForHelperThreads; if (duration.ToMilliseconds() >= threshold) { nsDependentCString statementString(aSqlString); Telemetry::RecordSlowSQLStatement(statementString, mTelemetryFilename, duration.ToMilliseconds()); Telemetry::RecordSlowSQLStatement( statementString, mTelemetryFilename, static_cast<uint32_t>(duration.ToMilliseconds())); } return srv; Loading
storage/mozStorageService.cpp +7 −6 Original line number Diff line number Diff line Loading @@ -147,7 +147,7 @@ Service::CollectReports(nsIHandleReportCallback* aHandleReport, #endif } int64_t other = ::sqlite3_memory_used() - totalConnSize; int64_t other = static_cast<int64_t>(::sqlite3_memory_used() - totalConnSize); MOZ_COLLECT_REPORT("explicit/storage/sqlite/other", KIND_HEAP, UNITS_BYTES, other, "All unclassified sqlite memory."); Loading Loading @@ -202,7 +202,8 @@ Service::AutoVFSRegistration::~AutoVFSRegistration() { Service::Service() : mMutex("Service::mMutex"), mRegistrationMutex("Service::mRegistrationMutex"), mConnections() {} mConnections(), mLastSensitivity(mozilla::intl::Collator::Sensitivity::Base) {} Service::~Service() { mozilla::UnregisterWeakMemoryReporter(this); Loading Loading @@ -375,8 +376,8 @@ nsresult Service::initialize() { nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); NS_ENSURE_TRUE(os, NS_ERROR_FAILURE); for (size_t i = 0; i < ArrayLength(sObserverTopics); ++i) { nsresult rv = os->AddObserver(this, sObserverTopics[i], false); for (auto& sObserverTopic : sObserverTopics) { nsresult rv = os->AddObserver(this, sObserverTopic, false); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } Loading Loading @@ -740,8 +741,8 @@ Service::Observe(nsISupports*, const char* aTopic, const char16_t*) { nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); for (size_t i = 0; i < ArrayLength(sObserverTopics); ++i) { (void)os->RemoveObserver(this, sObserverTopics[i]); for (auto& sObserverTopic : sObserverTopics) { (void)os->RemoveObserver(this, sObserverTopic); } SpinEventLoopUntil("storage::Service::Observe(xpcom-shutdown-threads)"_ns, Loading
storage/mozStorageService.h +2 −4 Original line number Diff line number Diff line Loading @@ -24,8 +24,7 @@ namespace mozilla::intl { class Collator; } namespace mozilla { namespace storage { namespace mozilla::storage { class Connection; class Service : public mozIStorageService, Loading Loading @@ -179,7 +178,6 @@ class Service : public mozIStorageService, mozilla::intl::Collator::Sensitivity mLastSensitivity; }; } // namespace storage } // namespace mozilla } // namespace mozilla::storage #endif /* MOZSTORAGESERVICE_H */
storage/test/gtest/storage_test_harness.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -186,16 +186,18 @@ nsIThread* last_non_watched_thread = nullptr; * call the real mutex function. */ extern "C" void wrapped_MutexEnter(sqlite3_mutex* mutex) { if (PR_GetCurrentThread() == watched_thread) if (PR_GetCurrentThread() == watched_thread) { mutex_used_on_watched_thread = true; else } else { last_non_watched_thread = NS_GetCurrentThread(); } orig_mutex_methods.xMutexEnter(mutex); } extern "C" int wrapped_MutexTry(sqlite3_mutex* mutex) { if (::PR_GetCurrentThread() == watched_thread) if (::PR_GetCurrentThread() == watched_thread) { mutex_used_on_watched_thread = true; } return orig_mutex_methods.xMutexTry(mutex); } Loading