forked from mirrors/gecko-dev
Bug 1638256 - Some casts and fixes in mozStorage to make clang-tidy happy. r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D181551
This commit is contained in:
parent
95fe144ede
commit
016cc78dda
4 changed files with 33 additions and 22 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
#include "nsIFileURL.h"
|
#include "nsIFileURL.h"
|
||||||
#include "nsIXPConnect.h"
|
#include "nsIXPConnect.h"
|
||||||
#include "mozilla/AppShutdown.h"
|
#include "mozilla/AppShutdown.h"
|
||||||
|
#include "mozilla/CheckedInt.h"
|
||||||
#include "mozilla/Telemetry.h"
|
#include "mozilla/Telemetry.h"
|
||||||
#include "mozilla/Mutex.h"
|
#include "mozilla/Mutex.h"
|
||||||
#include "mozilla/CondVar.h"
|
#include "mozilla/CondVar.h"
|
||||||
|
|
@ -138,14 +139,21 @@ int sqlite3_T_double(sqlite3_context* aCtx, double aValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int sqlite3_T_text(sqlite3_context* aCtx, const nsCString& 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;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sqlite3_T_text16(sqlite3_context* aCtx, const nsString& aValue) {
|
int sqlite3_T_text16(sqlite3_context* aCtx, const nsString& aValue) {
|
||||||
::sqlite3_result_text16(
|
CheckedInt<int32_t> n_bytes =
|
||||||
aCtx, aValue.get(),
|
CheckedInt<int32_t>(aValue.Length()) * sizeof(char16_t);
|
||||||
aValue.Length() * sizeof(char16_t), // Number of bytes.
|
if (!n_bytes.isValid()) {
|
||||||
|
return SQLITE_MISUSE;
|
||||||
|
}
|
||||||
|
::sqlite3_result_text16(aCtx, aValue.get(), n_bytes.value(),
|
||||||
SQLITE_TRANSIENT);
|
SQLITE_TRANSIENT);
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -1395,8 +1403,9 @@ int Connection::stepStatement(sqlite3* aNativeConnection,
|
||||||
: Telemetry::kSlowSQLThresholdForHelperThreads;
|
: Telemetry::kSlowSQLThresholdForHelperThreads;
|
||||||
if (duration.ToMilliseconds() >= threshold) {
|
if (duration.ToMilliseconds() >= threshold) {
|
||||||
nsDependentCString statementString(::sqlite3_sql(aStatement));
|
nsDependentCString statementString(::sqlite3_sql(aStatement));
|
||||||
Telemetry::RecordSlowSQLStatement(statementString, mTelemetryFilename,
|
Telemetry::RecordSlowSQLStatement(
|
||||||
duration.ToMilliseconds());
|
statementString, mTelemetryFilename,
|
||||||
|
static_cast<uint32_t>(duration.ToMilliseconds()));
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)::sqlite3_extended_result_codes(aNativeConnection, 0);
|
(void)::sqlite3_extended_result_codes(aNativeConnection, 0);
|
||||||
|
|
@ -1474,8 +1483,9 @@ int Connection::executeSql(sqlite3* aNativeConnection, const char* aSqlString) {
|
||||||
: Telemetry::kSlowSQLThresholdForHelperThreads;
|
: Telemetry::kSlowSQLThresholdForHelperThreads;
|
||||||
if (duration.ToMilliseconds() >= threshold) {
|
if (duration.ToMilliseconds() >= threshold) {
|
||||||
nsDependentCString statementString(aSqlString);
|
nsDependentCString statementString(aSqlString);
|
||||||
Telemetry::RecordSlowSQLStatement(statementString, mTelemetryFilename,
|
Telemetry::RecordSlowSQLStatement(
|
||||||
duration.ToMilliseconds());
|
statementString, mTelemetryFilename,
|
||||||
|
static_cast<uint32_t>(duration.ToMilliseconds()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return srv;
|
return srv;
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ Service::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||||
#endif
|
#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,
|
MOZ_COLLECT_REPORT("explicit/storage/sqlite/other", KIND_HEAP, UNITS_BYTES,
|
||||||
other, "All unclassified sqlite memory.");
|
other, "All unclassified sqlite memory.");
|
||||||
|
|
@ -202,7 +202,8 @@ Service::AutoVFSRegistration::~AutoVFSRegistration() {
|
||||||
Service::Service()
|
Service::Service()
|
||||||
: mMutex("Service::mMutex"),
|
: mMutex("Service::mMutex"),
|
||||||
mRegistrationMutex("Service::mRegistrationMutex"),
|
mRegistrationMutex("Service::mRegistrationMutex"),
|
||||||
mConnections() {}
|
mConnections(),
|
||||||
|
mLastSensitivity(mozilla::intl::Collator::Sensitivity::Base) {}
|
||||||
|
|
||||||
Service::~Service() {
|
Service::~Service() {
|
||||||
mozilla::UnregisterWeakMemoryReporter(this);
|
mozilla::UnregisterWeakMemoryReporter(this);
|
||||||
|
|
@ -375,8 +376,8 @@ nsresult Service::initialize() {
|
||||||
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 (auto& sObserverTopic : sObserverTopics) {
|
||||||
nsresult rv = os->AddObserver(this, sObserverTopics[i], false);
|
nsresult rv = os->AddObserver(this, sObserverTopic, false);
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
@ -740,8 +741,8 @@ Service::Observe(nsISupports*, const char* aTopic, const char16_t*) {
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||||
|
|
||||||
for (size_t i = 0; i < ArrayLength(sObserverTopics); ++i) {
|
for (auto& sObserverTopic : sObserverTopics) {
|
||||||
(void)os->RemoveObserver(this, sObserverTopics[i]);
|
(void)os->RemoveObserver(this, sObserverTopic);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinEventLoopUntil("storage::Service::Observe(xpcom-shutdown-threads)"_ns,
|
SpinEventLoopUntil("storage::Service::Observe(xpcom-shutdown-threads)"_ns,
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,7 @@ namespace mozilla::intl {
|
||||||
class Collator;
|
class Collator;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla::storage {
|
||||||
namespace storage {
|
|
||||||
|
|
||||||
class Connection;
|
class Connection;
|
||||||
class Service : public mozIStorageService,
|
class Service : public mozIStorageService,
|
||||||
|
|
@ -179,7 +178,6 @@ class Service : public mozIStorageService,
|
||||||
mozilla::intl::Collator::Sensitivity mLastSensitivity;
|
mozilla::intl::Collator::Sensitivity mLastSensitivity;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace storage
|
} // namespace mozilla::storage
|
||||||
} // namespace mozilla
|
|
||||||
|
|
||||||
#endif /* MOZSTORAGESERVICE_H */
|
#endif /* MOZSTORAGESERVICE_H */
|
||||||
|
|
|
||||||
|
|
@ -186,16 +186,18 @@ nsIThread* last_non_watched_thread = nullptr;
|
||||||
* call the real mutex function.
|
* call the real mutex function.
|
||||||
*/
|
*/
|
||||||
extern "C" void wrapped_MutexEnter(sqlite3_mutex* mutex) {
|
extern "C" void wrapped_MutexEnter(sqlite3_mutex* mutex) {
|
||||||
if (PR_GetCurrentThread() == watched_thread)
|
if (PR_GetCurrentThread() == watched_thread) {
|
||||||
mutex_used_on_watched_thread = true;
|
mutex_used_on_watched_thread = true;
|
||||||
else
|
} else {
|
||||||
last_non_watched_thread = NS_GetCurrentThread();
|
last_non_watched_thread = NS_GetCurrentThread();
|
||||||
|
}
|
||||||
orig_mutex_methods.xMutexEnter(mutex);
|
orig_mutex_methods.xMutexEnter(mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int wrapped_MutexTry(sqlite3_mutex* 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;
|
mutex_used_on_watched_thread = true;
|
||||||
|
}
|
||||||
return orig_mutex_methods.xMutexTry(mutex);
|
return orig_mutex_methods.xMutexTry(mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue