OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CLIENT_BUNDLE_H_ | 5 #ifndef CHROMEOS_DBUS_DBUS_CLIENT_BUNDLE_H_ |
6 #define CHROMEOS_DBUS_DBUS_CLIENT_BUNDLE_H_ | 6 #define CHROMEOS_DBUS_DBUS_CLIENT_BUNDLE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "chromeos/chromeos_export.h" | 12 #include "chromeos/chromeos_export.h" |
| 13 #include "chromeos/dbus/dbus_client_types.h" |
13 | 14 |
14 namespace chromeos { | 15 namespace chromeos { |
15 | 16 |
16 class ArcObbMounterClient; | 17 class ArcObbMounterClient; |
17 class CrasAudioClient; | 18 class CrasAudioClient; |
18 class CrosDisksClient; | 19 class CrosDisksClient; |
19 class CryptohomeClient; | 20 class CryptohomeClient; |
20 class DebugDaemonClient; | 21 class DebugDaemonClient; |
21 class EasyUnlockClient; | 22 class EasyUnlockClient; |
22 class GsmSMSClient; | 23 class GsmSMSClient; |
(...skipping 11 matching lines...) Expand all Loading... |
34 class ShillServiceClient; | 35 class ShillServiceClient; |
35 class ShillThirdPartyVpnDriverClient; | 36 class ShillThirdPartyVpnDriverClient; |
36 class SystemClockClient; | 37 class SystemClockClient; |
37 class UpdateEngineClient; | 38 class UpdateEngineClient; |
38 | 39 |
39 // The bundle of all D-Bus clients used in DBusThreadManager. The bundle | 40 // The bundle of all D-Bus clients used in DBusThreadManager. The bundle |
40 // is used to delete them at once in the right order before shutting down the | 41 // is used to delete them at once in the right order before shutting down the |
41 // system bus. See also the comment in the destructor of DBusThreadManager. | 42 // system bus. See also the comment in the destructor of DBusThreadManager. |
42 class CHROMEOS_EXPORT DBusClientBundle { | 43 class CHROMEOS_EXPORT DBusClientBundle { |
43 public: | 44 public: |
44 typedef int DBusClientTypeMask; | 45 // Creates real implementations for |real_client_mask| and fakes for all |
45 | 46 // others. Fakes are used when running on Linux desktop and in tests. |
46 // TODO(zelidrag): We might want to collapse few more of these subsystems if | 47 explicit DBusClientBundle(DBusClientTypeMask real_client_mask); |
47 // their dbus interfaced correspond to the same daemon. | |
48 enum DBusClientType { | |
49 NO_CLIENT = 0, | |
50 BLUETOOTH = 1 << 0, | |
51 CRAS = 1 << 1, | |
52 CROS_DISKS = 1 << 2, | |
53 CRYPTOHOME = 1 << 3, | |
54 DEBUG_DAEMON = 1 << 4, | |
55 EASY_UNLOCK = 1 << 5, | |
56 LORGNETTE_MANAGER = 1 << 6, | |
57 SHILL = 1 << 7, | |
58 GSM_SMS = 1 << 8, | |
59 IMAGE_BURNER = 1 << 9, | |
60 MODEM_MESSAGING = 1 << 10, | |
61 PERMISSION_BROKER = 1 << 11, | |
62 POWER_MANAGER = 1 << 12, | |
63 SESSION_MANAGER = 1 << 13, | |
64 SMS = 1 << 14, | |
65 SYSTEM_CLOCK = 1 << 15, | |
66 UPDATE_ENGINE = 1 << 16, | |
67 ARC_OBB_MOUNTER = 1 << 17, | |
68 }; | |
69 | |
70 explicit DBusClientBundle(DBusClientTypeMask unstub_client_mask); | |
71 ~DBusClientBundle(); | 48 ~DBusClientBundle(); |
72 | 49 |
73 // Returns true if |client| is stubbed. | 50 // Returns true if |client| has a real (non-fake) client implementation. |
74 bool IsUsingStub(DBusClientType client); | 51 bool IsUsingReal(DBusClientType client) const; |
75 | 52 |
76 // Returns true if any real DBusClient is used. | 53 // Returns true if any real DBusClient is used. |
77 bool IsUsingAnyRealClient(); | 54 bool IsUsingAnyRealClient() const; |
78 | 55 |
79 // Initialize proper runtime environment for its dbus clients. | 56 // Initialize proper runtime environment for its dbus clients. |
80 void SetupDefaultEnvironment(); | 57 void SetupDefaultEnvironment(); |
81 | 58 |
82 // Parses command line param values for dbus subsystem that should be | |
83 // un-stubbed. | |
84 static DBusClientTypeMask ParseUnstubList(const std::string& unstub_list); | |
85 | |
86 ArcObbMounterClient* arc_obb_mounter_client() { | 59 ArcObbMounterClient* arc_obb_mounter_client() { |
87 return arc_obb_mounter_client_.get(); | 60 return arc_obb_mounter_client_.get(); |
88 } | 61 } |
89 | 62 |
90 CrasAudioClient* cras_audio_client() { | 63 CrasAudioClient* cras_audio_client() { |
91 return cras_audio_client_.get(); | 64 return cras_audio_client_.get(); |
92 } | 65 } |
93 | 66 |
94 CrosDisksClient* cros_disks_client() { | 67 CrosDisksClient* cros_disks_client() { |
95 return cros_disks_client_.get(); | 68 return cros_disks_client_.get(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 return sms_client_.get(); | 140 return sms_client_.get(); |
168 } | 141 } |
169 | 142 |
170 UpdateEngineClient* update_engine_client() { | 143 UpdateEngineClient* update_engine_client() { |
171 return update_engine_client_.get(); | 144 return update_engine_client_.get(); |
172 } | 145 } |
173 | 146 |
174 private: | 147 private: |
175 friend class DBusThreadManagerSetter; | 148 friend class DBusThreadManagerSetter; |
176 | 149 |
177 // Bitmask that defines which dbus clients are not stubbed out. Bitmap flags | 150 // Bitmask for clients with real implementations. |
178 // are defined within DBusClientType enum. | 151 const DBusClientTypeMask real_client_mask_; |
179 DBusClientTypeMask unstub_client_mask_; | |
180 | 152 |
181 std::unique_ptr<ArcObbMounterClient> arc_obb_mounter_client_; | 153 std::unique_ptr<ArcObbMounterClient> arc_obb_mounter_client_; |
182 std::unique_ptr<CrasAudioClient> cras_audio_client_; | 154 std::unique_ptr<CrasAudioClient> cras_audio_client_; |
183 std::unique_ptr<CrosDisksClient> cros_disks_client_; | 155 std::unique_ptr<CrosDisksClient> cros_disks_client_; |
184 std::unique_ptr<CryptohomeClient> cryptohome_client_; | 156 std::unique_ptr<CryptohomeClient> cryptohome_client_; |
185 std::unique_ptr<DebugDaemonClient> debug_daemon_client_; | 157 std::unique_ptr<DebugDaemonClient> debug_daemon_client_; |
186 std::unique_ptr<EasyUnlockClient> easy_unlock_client_; | 158 std::unique_ptr<EasyUnlockClient> easy_unlock_client_; |
187 std::unique_ptr<LorgnetteManagerClient> lorgnette_manager_client_; | 159 std::unique_ptr<LorgnetteManagerClient> lorgnette_manager_client_; |
188 std::unique_ptr<ShillDeviceClient> shill_device_client_; | 160 std::unique_ptr<ShillDeviceClient> shill_device_client_; |
189 std::unique_ptr<ShillIPConfigClient> shill_ipconfig_client_; | 161 std::unique_ptr<ShillIPConfigClient> shill_ipconfig_client_; |
(...skipping 11 matching lines...) Expand all Loading... |
201 std::unique_ptr<SessionManagerClient> session_manager_client_; | 173 std::unique_ptr<SessionManagerClient> session_manager_client_; |
202 std::unique_ptr<SMSClient> sms_client_; | 174 std::unique_ptr<SMSClient> sms_client_; |
203 std::unique_ptr<UpdateEngineClient> update_engine_client_; | 175 std::unique_ptr<UpdateEngineClient> update_engine_client_; |
204 | 176 |
205 DISALLOW_COPY_AND_ASSIGN(DBusClientBundle); | 177 DISALLOW_COPY_AND_ASSIGN(DBusClientBundle); |
206 }; | 178 }; |
207 | 179 |
208 } // namespace chromeos | 180 } // namespace chromeos |
209 | 181 |
210 #endif // CHROMEOS_DBUS_DBUS_CLIENT_BUNDLE_H_ | 182 #endif // CHROMEOS_DBUS_DBUS_CLIENT_BUNDLE_H_ |
OLD | NEW |