Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: chromeos/dbus/dbus_client_bundle.h

Issue 2319783002: mash: Allow a subset of D-Bus clients to be created in DBusThreadManager (Closed)
Patch Set: cleanup Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 18 matching lines...) Expand all
29 class SessionManagerClient; 29 class SessionManagerClient;
30 class ShillDeviceClient; 30 class ShillDeviceClient;
31 class ShillIPConfigClient; 31 class ShillIPConfigClient;
32 class ShillManagerClient; 32 class ShillManagerClient;
33 class ShillProfileClient; 33 class ShillProfileClient;
34 class ShillServiceClient; 34 class ShillServiceClient;
35 class ShillThirdPartyVpnDriverClient; 35 class ShillThirdPartyVpnDriverClient;
36 class SystemClockClient; 36 class SystemClockClient;
37 class UpdateEngineClient; 37 class UpdateEngineClient;
38 38
39 // Declared outside of DBusClientBundle to make identifiers shorter in outside
40 // classes.
41 using DBusClientTypeMask = int;
42
39 // The bundle of all D-Bus clients used in DBusThreadManager. The bundle 43 // 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 44 // 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. 45 // system bus. See also the comment in the destructor of DBusThreadManager.
42 class CHROMEOS_EXPORT DBusClientBundle { 46 class CHROMEOS_EXPORT DBusClientBundle {
43 public: 47 public:
44 typedef int DBusClientTypeMask;
45
46 // TODO(zelidrag): We might want to collapse few more of these subsystems if
47 // their dbus interfaced correspond to the same daemon.
48 enum DBusClientType { 48 enum DBusClientType {
49 NO_CLIENT = 0, 49 NO_CLIENT = 0,
50 BLUETOOTH = 1 << 0, 50 BLUETOOTH = 1 << 0,
51 CRAS = 1 << 1, 51 CRAS = 1 << 1,
52 CROS_DISKS = 1 << 2, 52 CROS_DISKS = 1 << 2,
53 CRYPTOHOME = 1 << 3, 53 CRYPTOHOME = 1 << 3,
54 DEBUG_DAEMON = 1 << 4, 54 DEBUG_DAEMON = 1 << 4,
55 EASY_UNLOCK = 1 << 5, 55 EASY_UNLOCK = 1 << 5,
56 LORGNETTE_MANAGER = 1 << 6, 56 LORGNETTE_MANAGER = 1 << 6,
57 SHILL = 1 << 7, 57 SHILL = 1 << 7,
58 GSM_SMS = 1 << 8, 58 GSM_SMS = 1 << 8,
59 IMAGE_BURNER = 1 << 9, 59 IMAGE_BURNER = 1 << 9,
60 MODEM_MESSAGING = 1 << 10, 60 MODEM_MESSAGING = 1 << 10,
61 PERMISSION_BROKER = 1 << 11, 61 PERMISSION_BROKER = 1 << 11,
62 POWER_MANAGER = 1 << 12, 62 POWER_MANAGER = 1 << 12,
63 SESSION_MANAGER = 1 << 13, 63 SESSION_MANAGER = 1 << 13,
64 SMS = 1 << 14, 64 SMS = 1 << 14,
65 SYSTEM_CLOCK = 1 << 15, 65 SYSTEM_CLOCK = 1 << 15,
66 UPDATE_ENGINE = 1 << 16, 66 UPDATE_ENGINE = 1 << 16,
67 ARC_OBB_MOUNTER = 1 << 17, 67 ARC_OBB_MOUNTER = 1 << 17,
68 ALL_CLIENTS = ~NO_CLIENT,
68 }; 69 };
69 70
70 explicit DBusClientBundle(DBusClientTypeMask unstub_client_mask); 71 // Creates real implementations for |real_client_mask| and fakes for
72 // |fake_client_mask|. The masks must be mutually exclusive. Fakes are used
73 // when running on Linux desktop and in tests. If a client does not appear in
74 // either mask then no implementation will be created and the getters below
75 // will return null.
76 DBusClientBundle(DBusClientTypeMask real_client_mask,
77 DBusClientTypeMask fake_client_mask);
71 ~DBusClientBundle(); 78 ~DBusClientBundle();
72 79
73 // Returns true if |client| is stubbed. 80 // Returns true if |client| is faked.
74 bool IsUsingStub(DBusClientType client); 81 bool IsUsingFake(DBusClientType client) const;
82
83 // Returns true if |client| has the real client implementation.
84 bool IsUsingReal(DBusClientType client) const;
75 85
76 // Returns true if any real DBusClient is used. 86 // Returns true if any real DBusClient is used.
77 bool IsUsingAnyRealClient(); 87 bool IsUsingAnyRealClient();
78 88
79 // Initialize proper runtime environment for its dbus clients. 89 // Initialize proper runtime environment for its dbus clients.
80 void SetupDefaultEnvironment(); 90 void SetupDefaultEnvironment();
81 91
82 // Parses command line param values for dbus subsystem that should be 92 // Parses command line param values for dbus subsystems that should be forced
83 // un-stubbed. 93 // to use real implementations.
84 static DBusClientTypeMask ParseUnstubList(const std::string& unstub_list); 94 static DBusClientTypeMask ParseUnstubList(const std::string& unstub_list);
James Cook 2016/09/07 19:56:07 I did not rename the --dbus-unstub-clients flag be
85 95
86 ArcObbMounterClient* arc_obb_mounter_client() { 96 ArcObbMounterClient* arc_obb_mounter_client() {
87 return arc_obb_mounter_client_.get(); 97 return arc_obb_mounter_client_.get();
88 } 98 }
89 99
90 CrasAudioClient* cras_audio_client() { 100 CrasAudioClient* cras_audio_client() {
91 return cras_audio_client_.get(); 101 return cras_audio_client_.get();
92 } 102 }
93 103
94 CrosDisksClient* cros_disks_client() { 104 CrosDisksClient* cros_disks_client() {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return sms_client_.get(); 177 return sms_client_.get();
168 } 178 }
169 179
170 UpdateEngineClient* update_engine_client() { 180 UpdateEngineClient* update_engine_client() {
171 return update_engine_client_.get(); 181 return update_engine_client_.get();
172 } 182 }
173 183
174 private: 184 private:
175 friend class DBusThreadManagerSetter; 185 friend class DBusThreadManagerSetter;
176 186
177 // Bitmask that defines which dbus clients are not stubbed out. Bitmap flags 187 // Bitmask for clients with real implementations. See DBusClientType.
178 // are defined within DBusClientType enum. 188 const DBusClientTypeMask real_client_mask_;
179 DBusClientTypeMask unstub_client_mask_;
180 189
190 // Bitmask for clients with fake implementations. See DBusClientType.
191 const DBusClientTypeMask fake_client_mask_;
192
193 // May be null if the current process does not use the client (e.g. in the
194 // ash process on mustash).
181 std::unique_ptr<ArcObbMounterClient> arc_obb_mounter_client_; 195 std::unique_ptr<ArcObbMounterClient> arc_obb_mounter_client_;
182 std::unique_ptr<CrasAudioClient> cras_audio_client_; 196 std::unique_ptr<CrasAudioClient> cras_audio_client_;
183 std::unique_ptr<CrosDisksClient> cros_disks_client_; 197 std::unique_ptr<CrosDisksClient> cros_disks_client_;
184 std::unique_ptr<CryptohomeClient> cryptohome_client_; 198 std::unique_ptr<CryptohomeClient> cryptohome_client_;
185 std::unique_ptr<DebugDaemonClient> debug_daemon_client_; 199 std::unique_ptr<DebugDaemonClient> debug_daemon_client_;
186 std::unique_ptr<EasyUnlockClient> easy_unlock_client_; 200 std::unique_ptr<EasyUnlockClient> easy_unlock_client_;
187 std::unique_ptr<LorgnetteManagerClient> lorgnette_manager_client_; 201 std::unique_ptr<LorgnetteManagerClient> lorgnette_manager_client_;
188 std::unique_ptr<ShillDeviceClient> shill_device_client_; 202 std::unique_ptr<ShillDeviceClient> shill_device_client_;
189 std::unique_ptr<ShillIPConfigClient> shill_ipconfig_client_; 203 std::unique_ptr<ShillIPConfigClient> shill_ipconfig_client_;
190 std::unique_ptr<ShillManagerClient> shill_manager_client_; 204 std::unique_ptr<ShillManagerClient> shill_manager_client_;
(...skipping 10 matching lines...) Expand all
201 std::unique_ptr<SessionManagerClient> session_manager_client_; 215 std::unique_ptr<SessionManagerClient> session_manager_client_;
202 std::unique_ptr<SMSClient> sms_client_; 216 std::unique_ptr<SMSClient> sms_client_;
203 std::unique_ptr<UpdateEngineClient> update_engine_client_; 217 std::unique_ptr<UpdateEngineClient> update_engine_client_;
204 218
205 DISALLOW_COPY_AND_ASSIGN(DBusClientBundle); 219 DISALLOW_COPY_AND_ASSIGN(DBusClientBundle);
206 }; 220 };
207 221
208 } // namespace chromeos 222 } // namespace chromeos
209 223
210 #endif // CHROMEOS_DBUS_DBUS_CLIENT_BUNDLE_H_ 224 #endif // CHROMEOS_DBUS_DBUS_CLIENT_BUNDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698