Line data Source code
1 : /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
2 : /* vim: set ts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_ipc_DBusConnectionRefPtr_h
8 : #define mozilla_ipc_DBusConnectionRefPtr_h
9 :
10 : #include <dbus/dbus.h>
11 : #include "mozilla/RefPtr.h"
12 :
13 : namespace mozilla {
14 :
15 : /*
16 : * |RefPtrTraits<DBusConnection>| specializes |RefPtrTraits<>|
17 : * for managing |DBusConnection| with |RefPtr|.
18 : *
19 : * |RefPtrTraits<DBusConnection>| will _not_ close the DBus
20 : * connection upon the final unref. The caller is responsible
21 : * for closing the connection.
22 : *
23 : * See |DBusConnectionDelete| for auto-closing of connections.
24 : */
25 : template<>
26 : struct RefPtrTraits<DBusConnection>
27 : {
28 0 : static void AddRef(DBusConnection* aConnection) {
29 0 : MOZ_ASSERT(aConnection);
30 0 : dbus_connection_ref(aConnection);
31 0 : }
32 0 : static void Release(DBusConnection* aConnection) {
33 0 : MOZ_ASSERT(aConnection);
34 0 : dbus_connection_unref(aConnection);
35 0 : }
36 : };
37 :
38 : } // namespace mozilla
39 :
40 : #endif // mozilla_ipc_DBusConnectionRefPtr_h
|