Bug 1246931: Add support for |RefPtr<DBusMessage>|, r=shuang
authorThomas Zimmermann <tdz@users.sourceforge.net>
Tue, 12 Apr 2016 16:14:39 +0200
changeset 330703 acc96f61b9a8e13cb25619719bfaa67d501285cf
parent 330702 e615179b56a289f8cc4a4f226d1a28721ae9fa97
child 330704 2af67c46b79965f2322f454f57eb675df364d4cc
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshuang
bugs1246931
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1246931: Add support for |RefPtr<DBusMessage>|, r=shuang |RefPtr<DBusMessage>| manages instances of |DBusMessage| and frees each instance when its last reference gets released.
ipc/dbus/DBusMessageRefPtr.h
ipc/dbus/moz.build
new file mode 100644
--- /dev/null
+++ b/ipc/dbus/DBusMessageRefPtr.h
@@ -0,0 +1,30 @@
+/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_ipc_DBusMessageRefPtr_h
+#define mozilla_ipc_DBusMessageRefPtr_h
+
+#include <dbus/dbus.h>
+#include "mozilla/RefPtr.h"
+
+namespace mozilla {
+
+template<>
+struct RefPtrTraits<DBusMessage>
+{
+  static void AddRef(DBusMessage* aMessage) {
+    MOZ_ASSERT(aMessage);
+    dbus_message_ref(aMessage);
+  }
+  static void Release(DBusMessage* aMessage) {
+    MOZ_ASSERT(aMessage);
+    dbus_message_unref(aMessage);
+  }
+};
+
+} // namespace mozilla
+
+#endif // mozilla_ipc_DBusMessageRefPtr_h
--- a/ipc/dbus/moz.build
+++ b/ipc/dbus/moz.build
@@ -1,16 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 EXPORTS.mozilla.ipc += [
     'DBusConnectionRefPtr.h',
+    'DBusMessageRefPtr.h',
     'DBusUtils.h',
     'DBusWatcher.h',
     'RawDBusConnection.h',
 ]
 
 SOURCES += [
     'DBusUtils.cpp',
     'DBusWatcher.cpp',