OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium 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 DEVICE_BLUETOOTH_DBUS_DBUS_THREAD_MANAGER_LINUX_H_ |
| 6 #define DEVICE_BLUETOOTH_DBUS_DBUS_THREAD_MANAGER_LINUX_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "device/bluetooth/bluetooth_export.h" |
| 13 |
| 14 namespace base { |
| 15 class Thread; |
| 16 } // namespace base |
| 17 |
| 18 namespace dbus { |
| 19 class Bus; |
| 20 } // namespace dbus |
| 21 |
| 22 namespace bluez { |
| 23 |
| 24 // LinuxDBusManager manages the D-Bus thread, the thread dedicated to |
| 25 // handling asynchronous D-Bus operations. |
| 26 class DEVICE_BLUETOOTH_EXPORT DBusThreadManagerLinux { |
| 27 public: |
| 28 // Sets the global instance. Must be called before any calls to Get(). |
| 29 // We explicitly initialize and shut down the global object, rather than |
| 30 // making it a Singleton, to ensure clean startup and shutdown. |
| 31 static void Initialize(); |
| 32 |
| 33 // Destroys the global instance. |
| 34 static void Shutdown(); |
| 35 |
| 36 // Gets the global instance. Initialize() must be called first. |
| 37 static DBusThreadManagerLinux* Get(); |
| 38 |
| 39 // Returns various D-Bus bus instances, owned by LinuxDBusManager. |
| 40 dbus::Bus* GetSystemBus(); |
| 41 |
| 42 private: |
| 43 explicit DBusThreadManagerLinux(); |
| 44 ~DBusThreadManagerLinux(); |
| 45 |
| 46 // Creates a global instance of LinuxDBusManager with the real |
| 47 // implementations for all clients that are listed in |unstub_client_mask| and |
| 48 // stub implementations for all clients that are not included. Cannot be |
| 49 // called more than once. |
| 50 static void CreateGlobalInstance(); |
| 51 |
| 52 scoped_ptr<base::Thread> dbus_thread_; |
| 53 scoped_refptr<dbus::Bus> system_bus_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerLinux); |
| 56 }; |
| 57 |
| 58 } // namespace bluez |
| 59 |
| 60 #endif // DEVICE_BLUETOOTH_DBUS_DBUS_THREAD_MANAGER_LINUX_H_ |
OLD | NEW |