Bug 1246931: Use |DBusConnection| in |DBusWatcher|, r=shuang

This patch replaces all references to |RawDBusConnection| in |DBusWatcher|
with |DBusConnection|.
This commit is contained in:
Thomas Zimmermann 2016-04-12 16:14:39 +02:00
parent c78e56f403
commit 4ec30bc8a8
3 changed files with 8 additions and 12 deletions

View File

@ -7,12 +7,11 @@
#include "DBusWatcher.h" #include "DBusWatcher.h"
#include "mozilla/unused.h" #include "mozilla/unused.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "RawDBusConnection.h"
namespace mozilla { namespace mozilla {
namespace ipc { namespace ipc {
DBusWatcher::DBusWatcher(RawDBusConnection* aConnection, DBusWatch* aWatch) DBusWatcher::DBusWatcher(DBusConnection* aConnection, DBusWatch* aWatch)
: mConnection(aConnection) : mConnection(aConnection)
, mWatch(aWatch) , mWatch(aWatch)
{ {
@ -23,7 +22,7 @@ DBusWatcher::DBusWatcher(RawDBusConnection* aConnection, DBusWatch* aWatch)
DBusWatcher::~DBusWatcher() DBusWatcher::~DBusWatcher()
{ } { }
RawDBusConnection* DBusConnection*
DBusWatcher::GetConnection() DBusWatcher::GetConnection()
{ {
return mConnection; return mConnection;
@ -82,7 +81,7 @@ DBusWatcher::AddWatchFunction(DBusWatch* aWatch, void* aData)
{ {
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread());
auto connection = static_cast<RawDBusConnection*>(aData); auto connection = static_cast<DBusConnection*>(aData);
UniquePtr<DBusWatcher> dbusWatcher = UniquePtr<DBusWatcher> dbusWatcher =
MakeUnique<DBusWatcher>(connection, aWatch); MakeUnique<DBusWatcher>(connection, aWatch);
@ -134,8 +133,7 @@ DBusWatcher::OnFileCanReadWithoutBlocking(int aFd)
DBusDispatchStatus dbusDispatchStatus; DBusDispatchStatus dbusDispatchStatus;
do { do {
dbusDispatchStatus = dbusDispatchStatus = dbus_connection_dispatch(mConnection);
dbus_connection_dispatch(mConnection->GetConnection());
} while (dbusDispatchStatus == DBUS_DISPATCH_DATA_REMAINS); } while (dbusDispatchStatus == DBUS_DISPATCH_DATA_REMAINS);
} }

View File

@ -13,12 +13,10 @@
namespace mozilla { namespace mozilla {
namespace ipc { namespace ipc {
class RawDBusConnection;
class DBusWatcher : public MessageLoopForIO::Watcher class DBusWatcher : public MessageLoopForIO::Watcher
{ {
public: public:
DBusWatcher(RawDBusConnection* aConnection, DBusWatch* aWatch); DBusWatcher(DBusConnection* aConnection, DBusWatch* aWatch);
~DBusWatcher(); ~DBusWatcher();
void StartWatching(); void StartWatching();
@ -29,7 +27,7 @@ public:
static void RemoveWatchFunction(DBusWatch* aWatch, void* aData); static void RemoveWatchFunction(DBusWatch* aWatch, void* aData);
static void ToggleWatchFunction(DBusWatch* aWatch, void* aData); static void ToggleWatchFunction(DBusWatch* aWatch, void* aData);
RawDBusConnection* GetConnection(); DBusConnection* GetConnection();
private: private:
void OnFileCanReadWithoutBlocking(int aFd); void OnFileCanReadWithoutBlocking(int aFd);
@ -42,7 +40,7 @@ private:
MessageLoopForIO::FileDescriptorWatcher mWriteWatcher; MessageLoopForIO::FileDescriptorWatcher mWriteWatcher;
// DBus structures // DBus structures
RawDBusConnection* mConnection; DBusConnection* mConnection;
DBusWatch* mWatch; DBusWatch* mWatch;
}; };

View File

@ -110,7 +110,7 @@ bool RawDBusConnection::Watch()
DBusWatcher::AddWatchFunction, DBusWatcher::AddWatchFunction,
DBusWatcher::RemoveWatchFunction, DBusWatcher::RemoveWatchFunction,
DBusWatcher::ToggleWatchFunction, DBusWatcher::ToggleWatchFunction,
this, nullptr); this->GetConnection(), nullptr);
NS_ENSURE_TRUE(success == TRUE, false); NS_ENSURE_TRUE(success == TRUE, false);
return true; return true;