summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/dbus_client_bundle.h
blob: a9a115bc9e25589563ba8992044c9c5d8aa00a63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_DBUS_DBUS_CLIENT_BUNDLE_H_
#define CHROMEOS_DBUS_DBUS_CLIENT_BUNDLE_H_

#include <string>

#include "base/memory/scoped_ptr.h"
#include "chromeos/chromeos_export.h"

namespace chromeos {

class AmplifierClient;
class ApManagerClient;
class AudioDspClient;
class BluetoothAdapterClient;
class BluetoothAgentManagerClient;
class BluetoothDeviceClient;
class BluetoothGattCharacteristicClient;
class BluetoothGattDescriptorClient;
class BluetoothGattManagerClient;
class BluetoothGattServiceClient;
class BluetoothInputClient;
class BluetoothLEAdvertisingManagerClient;
class BluetoothMediaClient;
class BluetoothMediaTransportClient;
class BluetoothProfileManagerClient;
class CrasAudioClient;
class CrosDisksClient;
class CryptohomeClient;
class DebugDaemonClient;
class EasyUnlockClient;
class GsmSMSClient;
class ImageBurnerClient;
class IntrospectableClient;
class LorgnetteManagerClient;
class ModemMessagingClient;
class NfcAdapterClient;
class NfcDeviceClient;
class NfcManagerClient;
class NfcRecordClient;
class NfcTagClient;
class PeerDaemonManagerClient;
class PermissionBrokerClient;
class PowerManagerClient;
class PrivetDaemonManagerClient;
class SMSClient;
class SessionManagerClient;
class ShillDeviceClient;
class ShillIPConfigClient;
class ShillManagerClient;
class ShillProfileClient;
class ShillServiceClient;
class ShillThirdPartyVpnDriverClient;
class SystemClockClient;
class UpdateEngineClient;

// The bundle of all D-Bus clients used in DBusThreadManager. The bundle
// is used to delete them at once in the right order before shutting down the
// system bus. See also the comment in the destructor of DBusThreadManager.
class CHROMEOS_EXPORT DBusClientBundle {
 public:
  typedef int DBusClientTypeMask;

  // TODO(zelidrag): We might want to collapse few more of these subsystems if
  // their dbus interfaced correspond to the same daemon.
  enum DBusClientType {
    NO_CLIENT =            0,
    BLUETOOTH  =           1 << 0,
    CRAS =                 1 << 1,
    CROS_DISKS =           1 << 2,
    CRYPTOHOME =           1 << 3,
    DEBUG_DAEMON =         1 << 4,
    EASY_UNLOCK =          1 << 5,
    LORGNETTE_MANAGER =    1 << 6,
    SHILL =                1 << 7,
    GSM_SMS =              1 << 8,
    IMAGE_BURNER =         1 << 9,
    INTROSPECTABLE =       1 << 10,
    MODEM_MESSAGING =      1 << 11,
    NFC =                  1 << 12,
    PERMISSION_BROKER =    1 << 13,
    POWER_MANAGER =        1 << 14,
    SESSION_MANAGER =      1 << 15,
    SMS =                  1 << 16,
    SYSTEM_CLOCK =         1 << 17,
    UPDATE_ENGINE =        1 << 18,
    PEER_DAEMON =          1 << 19,
    AP_MANAGER =           1 << 20,
    PRIVET_DAEMON =        1 << 21,
    AMPLIFIER =            1 << 22,
    AUDIO_DSP =            1 << 23,
  };

  explicit DBusClientBundle(DBusClientTypeMask unstub_client_mask);
  ~DBusClientBundle();

  // Returns true if |client| is stubbed.
  bool IsUsingStub(DBusClientType client);

  // Returns true if any real DBusClient is used.
  bool IsUsingAnyRealClient();

  // Initialize proper runtime environment for its dbus clients.
  void SetupDefaultEnvironment();

  // Parses command line param values for dbus subsystem that should be
  // un-stubbed.
  static DBusClientTypeMask ParseUnstubList(const std::string& unstub_list);

  AmplifierClient* amplifier_client() { return amplifier_client_.get(); }

  ApManagerClient* ap_manager_client() { return ap_manager_client_.get(); }

  AudioDspClient* audio_dsp_client() { return audio_dsp_client_.get(); }

  BluetoothAdapterClient* bluetooth_adapter_client() {
    return bluetooth_adapter_client_.get();
  }

  BluetoothLEAdvertisingManagerClient*
  bluetooth_le_advertising_manager_client() {
    return bluetooth_le_advertising_manager_client_.get();
  }

  BluetoothAgentManagerClient* bluetooth_agent_manager_client() {
    return bluetooth_agent_manager_client_.get();
  }

  BluetoothDeviceClient* bluetooth_device_client() {
    return bluetooth_device_client_.get();
  }

  BluetoothGattCharacteristicClient* bluetooth_gatt_characteristic_client() {
    return bluetooth_gatt_characteristic_client_.get();
  }

  BluetoothGattDescriptorClient* bluetooth_gatt_descriptor_client() {
    return bluetooth_gatt_descriptor_client_.get();
  }

  BluetoothGattManagerClient* bluetooth_gatt_manager_client() {
    return bluetooth_gatt_manager_client_.get();
  }

  BluetoothGattServiceClient* bluetooth_gatt_service_client() {
    return bluetooth_gatt_service_client_.get();
  }

  BluetoothInputClient* bluetooth_input_client() {
    return bluetooth_input_client_.get();
  }

  BluetoothMediaClient* bluetooth_media_client() {
    return bluetooth_media_client_.get();
  }

  BluetoothMediaTransportClient* bluetooth_media_transport_client() {
    return bluetooth_media_transport_client_.get();
  }

  BluetoothProfileManagerClient* bluetooth_profile_manager_client() {
    return bluetooth_profile_manager_client_.get();
  }

  CrasAudioClient* cras_audio_client() {
    return cras_audio_client_.get();
  }

  CrosDisksClient* cros_disks_client() {
    return cros_disks_client_.get();
  }

  CryptohomeClient* cryptohome_client() {
    return cryptohome_client_.get();
  }

  DebugDaemonClient* debug_daemon_client() {
    return debug_daemon_client_.get();
  }

  EasyUnlockClient* easy_unlock_client() {
    return easy_unlock_client_.get();
  }

  LorgnetteManagerClient* lorgnette_manager_client() {
    return lorgnette_manager_client_.get();
  }

  ShillDeviceClient* shill_device_client() {
    return shill_device_client_.get();
  }

  ShillIPConfigClient* shill_ipconfig_client() {
    return shill_ipconfig_client_.get();
  }

  ShillManagerClient* shill_manager_client() {
    return shill_manager_client_.get();
  }

  ShillServiceClient* shill_service_client() {
    return shill_service_client_.get();
  }

  ShillProfileClient* shill_profile_client() {
    return shill_profile_client_.get();
  }

  ShillThirdPartyVpnDriverClient* shill_third_party_vpn_driver_client() {
    return shill_third_party_vpn_driver_client_.get();
  }

  GsmSMSClient* gsm_sms_client() {
    return gsm_sms_client_.get();
  }

  ImageBurnerClient* image_burner_client() {
    return image_burner_client_.get();
  }

  IntrospectableClient* introspectable_client() {
    return introspectable_client_.get();
  }

  ModemMessagingClient* modem_messaging_client() {
    return modem_messaging_client_.get();
  }

  NfcManagerClient* nfc_manager_client() {
    return nfc_manager_client_.get();
  }

  NfcAdapterClient* nfc_adapter_client() {
    return nfc_adapter_client_.get();
  }

  NfcDeviceClient* nfc_device_client() {
    return nfc_device_client_.get();
  }

  NfcTagClient* nfc_tag_client() {
    return nfc_tag_client_.get();
  }

  NfcRecordClient* nfc_record_client() {
    return nfc_record_client_.get();
  }

  PeerDaemonManagerClient* peer_daemon_manager_client() {
    return peer_daemon_manager_client_.get();
  }

  PermissionBrokerClient* permission_broker_client() {
    return permission_broker_client_.get();
  }

  PrivetDaemonManagerClient* privet_daemon_manager_client() {
    return privet_daemon_manager_client_.get();
  }

  SystemClockClient* system_clock_client() {
    return system_clock_client_.get();
  }

  PowerManagerClient* power_manager_client() {
    return power_manager_client_.get();
  }

  SessionManagerClient* session_manager_client() {
    return session_manager_client_.get();
  }

  SMSClient* sms_client() {
    return sms_client_.get();
  }

  UpdateEngineClient* update_engine_client() {
    return update_engine_client_.get();
  }

 private:
  friend class DBusThreadManagerSetter;

  // Bitmask that defines which dbus clients are not stubbed out. Bitmap flags
  // are defined within DBusClientType enum.
  DBusClientTypeMask unstub_client_mask_;

  scoped_ptr<AmplifierClient> amplifier_client_;
  scoped_ptr<ApManagerClient> ap_manager_client_;
  scoped_ptr<AudioDspClient> audio_dsp_client_;
  scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_;
  scoped_ptr<BluetoothLEAdvertisingManagerClient>
      bluetooth_le_advertising_manager_client_;
  scoped_ptr<BluetoothAgentManagerClient> bluetooth_agent_manager_client_;
  scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_;
  scoped_ptr<BluetoothGattCharacteristicClient>
      bluetooth_gatt_characteristic_client_;
  scoped_ptr<BluetoothGattDescriptorClient> bluetooth_gatt_descriptor_client_;
  scoped_ptr<BluetoothGattManagerClient> bluetooth_gatt_manager_client_;
  scoped_ptr<BluetoothGattServiceClient> bluetooth_gatt_service_client_;
  scoped_ptr<BluetoothInputClient> bluetooth_input_client_;
  scoped_ptr<BluetoothMediaClient> bluetooth_media_client_;
  scoped_ptr<BluetoothMediaTransportClient> bluetooth_media_transport_client_;
  scoped_ptr<BluetoothProfileManagerClient> bluetooth_profile_manager_client_;
  scoped_ptr<CrasAudioClient> cras_audio_client_;
  scoped_ptr<CrosDisksClient> cros_disks_client_;
  scoped_ptr<CryptohomeClient> cryptohome_client_;
  scoped_ptr<DebugDaemonClient> debug_daemon_client_;
  scoped_ptr<EasyUnlockClient> easy_unlock_client_;
  scoped_ptr<LorgnetteManagerClient> lorgnette_manager_client_;
  scoped_ptr<PeerDaemonManagerClient> peer_daemon_manager_client_;
  scoped_ptr<PrivetDaemonManagerClient> privet_daemon_manager_client_;
  scoped_ptr<ShillDeviceClient> shill_device_client_;
  scoped_ptr<ShillIPConfigClient> shill_ipconfig_client_;
  scoped_ptr<ShillManagerClient> shill_manager_client_;
  scoped_ptr<ShillServiceClient> shill_service_client_;
  scoped_ptr<ShillProfileClient> shill_profile_client_;
  scoped_ptr<ShillThirdPartyVpnDriverClient>
      shill_third_party_vpn_driver_client_;
  scoped_ptr<GsmSMSClient> gsm_sms_client_;
  scoped_ptr<ImageBurnerClient> image_burner_client_;
  scoped_ptr<IntrospectableClient> introspectable_client_;
  scoped_ptr<ModemMessagingClient> modem_messaging_client_;
  // The declaration order for NFC client objects is important. See
  // DBusThreadManager::InitializeClients for the dependencies.
  scoped_ptr<NfcManagerClient> nfc_manager_client_;
  scoped_ptr<NfcAdapterClient> nfc_adapter_client_;
  scoped_ptr<NfcDeviceClient> nfc_device_client_;
  scoped_ptr<NfcTagClient> nfc_tag_client_;
  scoped_ptr<NfcRecordClient> nfc_record_client_;
  scoped_ptr<PermissionBrokerClient> permission_broker_client_;
  scoped_ptr<SystemClockClient> system_clock_client_;
  scoped_ptr<PowerManagerClient> power_manager_client_;
  scoped_ptr<SessionManagerClient> session_manager_client_;
  scoped_ptr<SMSClient> sms_client_;
  scoped_ptr<UpdateEngineClient> update_engine_client_;

  DISALLOW_COPY_AND_ASSIGN(DBusClientBundle);
};

}  // namespace chromeos

#endif  // CHROMEOS_DBUS_DBUS_CLIENT_BUNDLE_H_