mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Bug 891866: Support nsRefPtr<RawDBusConnection>, r=qdot
Instances of RawDBusConnection can now be contained in nsRefPtr. This allows to share the DBus connection among multiple threads. --HG-- extra : rebase_source : fb24472b3b55e77abc7354f17ef679661f62b7fb
This commit is contained in:
parent
33fe9a0828
commit
7b3b182145
@ -148,7 +148,7 @@ static const char* sBluetoothDBusSignals[] =
|
||||
* used by any other thread.
|
||||
*
|
||||
*/
|
||||
static nsAutoPtr<RawDBusConnection> gThreadConnection;
|
||||
static nsRefPtr<RawDBusConnection> gThreadConnection;
|
||||
static nsDataHashtable<nsStringHashKey, DBusMessage* > sPairingReqTable;
|
||||
static nsDataHashtable<nsStringHashKey, DBusMessage* > sAuthorizeReqTable;
|
||||
static Atomic<int32_t> sIsPairing;
|
||||
|
@ -486,8 +486,8 @@ private:
|
||||
DBusThread* mConnection;
|
||||
};
|
||||
|
||||
static StaticAutoPtr<DBusThread> gDBusThread;
|
||||
static StaticRefPtr<nsIThread> gDBusServiceThread;
|
||||
static StaticRefPtr<DBusThread> gDBusThread;
|
||||
static StaticRefPtr<nsIThread> gDBusServiceThread;
|
||||
|
||||
// Startup/Shutdown utility functions
|
||||
|
||||
@ -497,7 +497,7 @@ StartDBus()
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
NS_ENSURE_TRUE(!gDBusThread, true);
|
||||
|
||||
nsAutoPtr<DBusThread> dbusThread(new DBusThread());
|
||||
nsRefPtr<DBusThread> dbusThread(new DBusThread());
|
||||
|
||||
bool eventLoopStarted = dbusThread->Initialize();
|
||||
NS_ENSURE_TRUE(eventLoopStarted, false);
|
||||
@ -521,7 +521,7 @@ StartDBus()
|
||||
rv = gDBusServiceThread->Dispatch(pollTask, NS_DISPATCH_NORMAL);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
gDBusThread = dbusThread.forget();
|
||||
gDBusThread = dbusThread;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -11,10 +11,12 @@ using namespace mozilla::ipc;
|
||||
|
||||
bool RawDBusConnection::sDBusIsInit(false);
|
||||
|
||||
RawDBusConnection::RawDBusConnection() {
|
||||
RawDBusConnection::RawDBusConnection()
|
||||
{
|
||||
}
|
||||
|
||||
RawDBusConnection::~RawDBusConnection() {
|
||||
RawDBusConnection::~RawDBusConnection()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult RawDBusConnection::EstablishDBusConnection()
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <stdlib.h>
|
||||
#include "nscore.h"
|
||||
#include "mozilla/Scoped.h"
|
||||
#include <mozilla/RefPtr.h>
|
||||
#include <mozilla/Mutex.h>
|
||||
|
||||
struct DBusConnection;
|
||||
@ -21,7 +22,7 @@ struct DBusConnection;
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
class RawDBusConnection
|
||||
class RawDBusConnection : public detail::RefCounted<RawDBusConnection, detail::AtomicRefCount>
|
||||
{
|
||||
struct ScopedDBusConnectionPtrTraits : ScopedFreePtrTraits<DBusConnection>
|
||||
{
|
||||
@ -30,7 +31,7 @@ class RawDBusConnection
|
||||
|
||||
public:
|
||||
RawDBusConnection();
|
||||
~RawDBusConnection();
|
||||
virtual ~RawDBusConnection();
|
||||
nsresult EstablishDBusConnection();
|
||||
DBusConnection* GetConnection() {
|
||||
return mConnection;
|
||||
|
Loading…
x
Reference in New Issue
Block a user