blob: a997290a7779e56a1382b991c86a8f4d9c92b4ce [file] [log] [blame]
Paul Stewart8dc5e7b2014-12-11 19:24:50 -08001// Copyright 2015 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHILL_SHARED_DBUS_CONNECTION_H_
6#define SHILL_SHARED_DBUS_CONNECTION_H_
7
8#include <memory>
9
10#include <base/lazy_instance.h>
11#include <base/macros.h>
12
13namespace DBus {
14class Connection;
15namespace Glib {
16class BusDispatcher;
17} // namespace Glib
18} // namespace DBus
19
20namespace shill {
21
22class SharedDBusConnection {
23 public:
24 ~SharedDBusConnection() = default;
25
26 // Since this is a singleton, use SharedDBusConnection::GetInstance()->Foo().
27 static SharedDBusConnection *GetInstance();
28
29 void Init();
30
31 DBus::Connection *GetConnection();
32
33 protected:
34 SharedDBusConnection() = default;
35
36 private:
37 friend struct base::DefaultLazyInstanceTraits<SharedDBusConnection>;
38
39 std::unique_ptr<DBus::Glib::BusDispatcher> dispatcher_;
40 std::unique_ptr<DBus::Connection> connection_;
41
42 DISALLOW_COPY_AND_ASSIGN(SharedDBusConnection);
43};
44
45} // namespace shill
46
47#endif // SHILL_SHARED_DBUS_CONNECTION_H_