1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROMEOS_DBUS_INITIALIZE_DBUS_CLIENT_H_
6 #define CHROMEOS_DBUS_INITIALIZE_DBUS_CLIENT_H_
7 
8 namespace dbus {
9 class Bus;
10 }  // namespace dbus
11 
12 namespace chromeos {
13 
14 // Initializes the appropriate version of D-Bus client.
15 template <typename T>
InitializeDBusClient(dbus::Bus * bus)16 void InitializeDBusClient(dbus::Bus* bus) {
17 #if defined(USE_REAL_DBUS_CLIENTS)
18   T::Initialize(bus);
19 #else
20   // TODO(hashimoto): Always use fakes after adding
21   // use_real_dbus_clients=true to where needed. crbug.com/952745
22   if (bus) {
23     T::Initialize(bus);
24   } else {
25     T::InitializeFake();
26   }
27 #endif
28 }
29 
30 }  // namespace chromeos
31 
32 #endif  // CHROMEOS_DBUS_INITIALIZE_DBUS_CLIENT_H_
33