| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ | 5 #ifndef CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ |
| 6 #define CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ | 6 #define CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chromeos/chromeos_export.h" | 11 #include "chromeos/chromeos_export.h" |
| 12 #include "chromeos/dbus/dbus_client_bundle.h" |
| 12 | 13 |
| 13 namespace base { | 14 namespace base { |
| 14 class Thread; | 15 class Thread; |
| 15 } // namespace base | 16 } // namespace base |
| 16 | 17 |
| 17 namespace dbus { | 18 namespace dbus { |
| 18 class Bus; | 19 class Bus; |
| 19 class ObjectPath; | 20 class ObjectPath; |
| 20 } // namespace dbus | 21 } // namespace dbus |
| 21 | 22 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // Returns true if DBusThreadManager has been initialized. Call this to | 108 // Returns true if DBusThreadManager has been initialized. Call this to |
| 108 // avoid initializing + shutting down DBusThreadManager more than once. | 109 // avoid initializing + shutting down DBusThreadManager more than once. |
| 109 static bool IsInitialized(); | 110 static bool IsInitialized(); |
| 110 | 111 |
| 111 // Destroys the global instance. | 112 // Destroys the global instance. |
| 112 static void Shutdown(); | 113 static void Shutdown(); |
| 113 | 114 |
| 114 // Gets the global instance. Initialize() must be called first. | 115 // Gets the global instance. Initialize() must be called first. |
| 115 static DBusThreadManager* Get(); | 116 static DBusThreadManager* Get(); |
| 116 | 117 |
| 118 // Returns true if |client| is stubbed. |
| 119 static bool IsUsingStub(DBusClientBundle::DBusClientType client); |
| 120 |
| 117 // Returns various D-Bus bus instances, owned by DBusThreadManager. | 121 // Returns various D-Bus bus instances, owned by DBusThreadManager. |
| 118 virtual dbus::Bus* GetSystemBus() = 0; | 122 virtual dbus::Bus* GetSystemBus() = 0; |
| 119 | 123 |
| 120 // All returned objects are owned by DBusThreadManager. Do not cache these | 124 // All returned objects are owned by DBusThreadManager. Do not cache these |
| 121 // pointers and use them after DBusThreadManager has been shut down. | 125 // pointers and use them after DBusThreadManager has been shut down. |
| 122 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() = 0; | 126 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() = 0; |
| 123 virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient() = 0; | 127 virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient() = 0; |
| 124 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() = 0; | 128 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() = 0; |
| 125 virtual BluetoothGattCharacteristicClient* | 129 virtual BluetoothGattCharacteristicClient* |
| 126 GetBluetoothGattCharacteristicClient() = 0; | 130 GetBluetoothGattCharacteristicClient() = 0; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 156 virtual SMSClient* GetSMSClient() = 0; | 160 virtual SMSClient* GetSMSClient() = 0; |
| 157 virtual SystemClockClient* GetSystemClockClient() = 0; | 161 virtual SystemClockClient* GetSystemClockClient() = 0; |
| 158 virtual UpdateEngineClient* GetUpdateEngineClient() = 0; | 162 virtual UpdateEngineClient* GetUpdateEngineClient() = 0; |
| 159 | 163 |
| 160 virtual ~DBusThreadManager(); | 164 virtual ~DBusThreadManager(); |
| 161 | 165 |
| 162 protected: | 166 protected: |
| 163 DBusThreadManager(); | 167 DBusThreadManager(); |
| 164 | 168 |
| 165 private: | 169 private: |
| 170 // Initialize global thread manager instance. |
| 171 static void InitializeRegular(); |
| 172 |
| 173 // Initialize with stub implementations for only certain clients that are |
| 174 // not included in comma-separated |unstub_clients| list. |
| 175 static void InitializeWithPartialStub(const std::string& unstub_clients); |
| 176 |
| 166 // InitializeClients is called after g_dbus_thread_manager is set. | 177 // InitializeClients is called after g_dbus_thread_manager is set. |
| 167 // NOTE: Clients that access other clients in their Init() must be | 178 // NOTE: Clients that access other clients in their Init() must be |
| 168 // initialized in the correct order. | 179 // initialized in the correct order. |
| 169 static void InitializeClients(); | 180 static void InitializeClients(); |
| 170 | 181 |
| 171 // Initializes |client| with the |system_bus_|. | 182 // Initializes |client| with the |system_bus_|. |
| 172 static void InitClient(DBusClient* client); | 183 static void InitClient(DBusClient* client); |
| 173 | 184 |
| 185 // Bitmask that defines which dbus clients are not stubbed out. Bitmap flags |
| 186 // are defined within DBusClientBundle::DBusClientType enum. |
| 187 static DBusClientBundle::DBusClientTypeMask unstub_client_mask_; |
| 188 |
| 174 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); | 189 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); |
| 175 }; | 190 }; |
| 176 | 191 |
| 177 } // namespace chromeos | 192 } // namespace chromeos |
| 178 | 193 |
| 179 #endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ | 194 #endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ |
| OLD | NEW |