Bug 983576: Annotate all assertions for non-main threads in BlueZ backend, r=echou

This patch adds an annotation to each assertion for non-main threads in
the BlueZ backend of Bluetooth. This should make is easy and obvious to
see in which context a method or function is expected to run.
This commit is contained in:
Thomas Zimmermann 2014-03-27 11:43:49 +01:00
parent ce990a5595
commit 076abc8a39

View File

@ -652,7 +652,7 @@ RunDBusCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable,
// being gtk based, sometimes we'll get signals/reply coming in on the main // being gtk based, sometimes we'll get signals/reply coming in on the main
// thread. There's not a lot we can do about that for the time being and it // thread. There's not a lot we can do about that for the time being and it
// (technically) shouldn't hurt anything. However, on gonk, die. // (technically) shouldn't hurt anything. However, on gonk, die.
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
#endif #endif
nsRefPtr<BluetoothReplyRunnable> replyRunnable = nsRefPtr<BluetoothReplyRunnable> replyRunnable =
dont_AddRef(static_cast< BluetoothReplyRunnable* >(aBluetoothReplyRunnable)); dont_AddRef(static_cast< BluetoothReplyRunnable* >(aBluetoothReplyRunnable));
@ -717,7 +717,7 @@ public:
, mConnect(aConnect) , mConnect(aConnect)
, mErrorString(aErrorString) , mErrorString(aErrorString)
{ {
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
} }
nsresult Run() nsresult Run()
@ -752,7 +752,7 @@ private:
static void static void
CheckDBusReply(DBusMessage* aMsg, void* aServiceClass, bool aConnect) CheckDBusReply(DBusMessage* aMsg, void* aServiceClass, bool aConnect)
{ {
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
NS_ENSURE_TRUE_VOID(aMsg); NS_ENSURE_TRUE_VOID(aMsg);
@ -1063,7 +1063,7 @@ public:
void Handle(DBusMessage* aReply) MOZ_OVERRIDE void Handle(DBusMessage* aReply) MOZ_OVERRIDE
{ {
MOZ_ASSERT(!NS_IsMainThread()); // DBus thread MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
if (!aReply || (dbus_message_get_type(aReply) == DBUS_MESSAGE_TYPE_ERROR)) { if (!aReply || (dbus_message_get_type(aReply) == DBUS_MESSAGE_TYPE_ERROR)) {
return; return;
@ -1373,7 +1373,7 @@ public:
void Handle(DBusMessage* aReply) void Handle(DBusMessage* aReply)
{ {
MOZ_ASSERT(!NS_IsMainThread()); // DBus thread MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
MOZ_ASSERT(sDBusConnection); MOZ_ASSERT(sDBusConnection);
if (!aReply || (dbus_message_get_type(aReply) == DBUS_MESSAGE_TYPE_ERROR)) { if (!aReply || (dbus_message_get_type(aReply) == DBUS_MESSAGE_TYPE_ERROR)) {
@ -1408,7 +1408,7 @@ public:
nullptr, AgentEventFilter, nullptr, nullptr, nullptr, nullptr nullptr, AgentEventFilter, nullptr, nullptr, nullptr, nullptr
}; };
MOZ_ASSERT(!NS_IsMainThread()); // DBus thread MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
if (!aReply || (dbus_message_get_type(aReply) == DBUS_MESSAGE_TYPE_ERROR)) { if (!aReply || (dbus_message_get_type(aReply) == DBUS_MESSAGE_TYPE_ERROR)) {
return; return;
@ -1568,7 +1568,7 @@ class RequestPlayStatusTask : public nsRunnable
public: public:
RequestPlayStatusTask() RequestPlayStatusTask()
{ {
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
} }
nsresult Run() nsresult Run()
@ -1592,6 +1592,7 @@ public:
static DBusHandlerResult static DBusHandlerResult
EventFilter(DBusConnection* aConn, DBusMessage* aMsg, void* aData) EventFilter(DBusConnection* aConn, DBusMessage* aMsg, void* aData)
{ {
// I/O thread
MOZ_ASSERT(!NS_IsMainThread(), "Shouldn't be called from Main Thread!"); MOZ_ASSERT(!NS_IsMainThread(), "Shouldn't be called from Main Thread!");
if (dbus_message_get_type(aMsg) != DBUS_MESSAGE_TYPE_SIGNAL) { if (dbus_message_get_type(aMsg) != DBUS_MESSAGE_TYPE_SIGNAL) {
@ -1853,7 +1854,7 @@ EventFilter(DBusConnection* aConn, DBusMessage* aMsg, void* aData)
static void static void
OnDefaultAdapterReply(DBusMessage* aReply, void* aData) OnDefaultAdapterReply(DBusMessage* aReply, void* aData)
{ {
MOZ_ASSERT(!NS_IsMainThread()); // DBus thread MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
if (!aReply || dbus_message_is_error(aReply, DBUS_ERROR_TIMEOUT)) { if (!aReply || dbus_message_is_error(aReply, DBUS_ERROR_TIMEOUT)) {
return; return;
@ -2166,7 +2167,7 @@ public:
void Handle(DBusMessage* aReply) MOZ_OVERRIDE void Handle(DBusMessage* aReply) MOZ_OVERRIDE
{ {
MOZ_ASSERT(!NS_IsMainThread()); // DBus thread MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
if (!aReply || (dbus_message_get_type(aReply) == DBUS_MESSAGE_TYPE_ERROR)) { if (!aReply || (dbus_message_get_type(aReply) == DBUS_MESSAGE_TYPE_ERROR)) {
const char* errStr = "Timeout in DefaultAdapterPathReplyHandler"; const char* errStr = "Timeout in DefaultAdapterPathReplyHandler";
@ -2203,7 +2204,7 @@ protected:
DBusError error; DBusError error;
dbus_error_init(&error); dbus_error_init(&error);
MOZ_ASSERT(!NS_IsMainThread()); // DBus thread MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
MOZ_ASSERT(sDBusConnection); MOZ_ASSERT(sDBusConnection);
UnpackObjectPathMessage(aReply, &error, value, aReplyError); UnpackObjectPathMessage(aReply, &error, value, aReplyError);
@ -2239,7 +2240,7 @@ protected:
DBusError error; DBusError error;
dbus_error_init(&error); dbus_error_init(&error);
MOZ_ASSERT(!NS_IsMainThread()); // DBus thread MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
bool success = UnpackPropertiesMessage(aReply, &error, value, bool success = UnpackPropertiesMessage(aReply, &error, value,
DBUS_ADAPTER_IFACE); DBUS_ADAPTER_IFACE);
@ -2315,7 +2316,7 @@ BluetoothDBusService::GetDefaultAdapterPathInternal(
static void static void
OnSendDiscoveryMessageReply(DBusMessage *aReply, void *aData) OnSendDiscoveryMessageReply(DBusMessage *aReply, void *aData)
{ {
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
nsAutoString errorStr; nsAutoString errorStr;
@ -2530,7 +2531,7 @@ public:
void Handle(DBusMessage* aReply) MOZ_OVERRIDE void Handle(DBusMessage* aReply) MOZ_OVERRIDE
{ {
MOZ_ASSERT(!NS_IsMainThread()); // DBus thread MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
MOZ_ASSERT(!mObjectPath.IsEmpty()); MOZ_ASSERT(!mObjectPath.IsEmpty());
MOZ_ASSERT(mProcessedDeviceAddresses < mDeviceAddresses.Length()); MOZ_ASSERT(mProcessedDeviceAddresses < mDeviceAddresses.Length());
@ -3473,7 +3474,7 @@ public:
void Handle(DBusMessage* aReply) void Handle(DBusMessage* aReply)
{ {
MOZ_ASSERT(!NS_IsMainThread()); // DBus thread MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
// The default channel is an invalid value of -1. We // The default channel is an invalid value of -1. We
// update it if we have received a correct reply. Both // update it if we have received a correct reply. Both