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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // Returns true if DBusThreadManager has been initialized. Call this to | 110 // Returns true if DBusThreadManager has been initialized. Call this to |
110 // avoid initializing + shutting down DBusThreadManager more than once. | 111 // avoid initializing + shutting down DBusThreadManager more than once. |
111 static bool IsInitialized(); | 112 static bool IsInitialized(); |
112 | 113 |
113 // Destroys the global instance. | 114 // Destroys the global instance. |
114 static void Shutdown(); | 115 static void Shutdown(); |
115 | 116 |
116 // Gets the global instance. Initialize() must be called first. | 117 // Gets the global instance. Initialize() must be called first. |
117 static DBusThreadManager* Get(); | 118 static DBusThreadManager* Get(); |
118 | 119 |
| 120 // Returns true if |client| is stubbed. |
| 121 static bool IsUsingStub(DBusClientBundle::DBusClientType client); |
| 122 |
119 // Adds or removes an observer. | 123 // Adds or removes an observer. |
120 virtual void AddObserver(DBusThreadManagerObserver* observer) = 0; | 124 virtual void AddObserver(DBusThreadManagerObserver* observer) = 0; |
121 virtual void RemoveObserver(DBusThreadManagerObserver* observer) = 0; | 125 virtual void RemoveObserver(DBusThreadManagerObserver* observer) = 0; |
122 | 126 |
123 // Returns various D-Bus bus instances, owned by DBusThreadManager. | 127 // Returns various D-Bus bus instances, owned by DBusThreadManager. |
124 virtual dbus::Bus* GetSystemBus() = 0; | 128 virtual dbus::Bus* GetSystemBus() = 0; |
125 | 129 |
126 // All returned objects are owned by DBusThreadManager. Do not cache these | 130 // All returned objects are owned by DBusThreadManager. Do not cache these |
127 // pointers and use them after DBusThreadManager has been shut down. | 131 // pointers and use them after DBusThreadManager has been shut down. |
128 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() = 0; | 132 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() = 0; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 virtual SMSClient* GetSMSClient() = 0; | 166 virtual SMSClient* GetSMSClient() = 0; |
163 virtual SystemClockClient* GetSystemClockClient() = 0; | 167 virtual SystemClockClient* GetSystemClockClient() = 0; |
164 virtual UpdateEngineClient* GetUpdateEngineClient() = 0; | 168 virtual UpdateEngineClient* GetUpdateEngineClient() = 0; |
165 | 169 |
166 virtual ~DBusThreadManager(); | 170 virtual ~DBusThreadManager(); |
167 | 171 |
168 protected: | 172 protected: |
169 DBusThreadManager(); | 173 DBusThreadManager(); |
170 | 174 |
171 private: | 175 private: |
| 176 // Initialize global thread manager instance. |
| 177 static void InitializeRegular(); |
| 178 |
| 179 // Initialize with stub implementations for only certain clients that are |
| 180 // not included in comma-separated |unstub_clients| list. |
| 181 static void InitializeWithPartialStub(const std::string& unstub_clients); |
| 182 |
172 // InitializeClients is called after g_dbus_thread_manager is set. | 183 // InitializeClients is called after g_dbus_thread_manager is set. |
173 // NOTE: Clients that access other clients in their Init() must be | 184 // NOTE: Clients that access other clients in their Init() must be |
174 // initialized in the correct order. | 185 // initialized in the correct order. |
175 static void InitializeClients(); | 186 static void InitializeClients(); |
176 | 187 |
177 // Initializes |client| with the |system_bus_|. | 188 // Initializes |client| with the |system_bus_|. |
178 static void InitClient(DBusClient* client); | 189 static void InitClient(DBusClient* client); |
179 | 190 |
| 191 // Bitmask that defines which dbus clients are not stubbed out. Bitmap flags |
| 192 // are defined within DBusClientBundle::DBusClientType enum. |
| 193 static DBusClientBundle::DBusClientTypeMask unstub_client_mask_; |
| 194 |
180 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); | 195 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); |
181 }; | 196 }; |
182 | 197 |
183 } // namespace chromeos | 198 } // namespace chromeos |
184 | 199 |
185 #endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ | 200 #endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ |
OLD | NEW |