initialize_dbus_client.h 817 B

1234567891011121314151617181920212223242526272829303132
  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. #ifndef CHROMEOS_DBUS_INIT_INITIALIZE_DBUS_CLIENT_H_
  5. #define CHROMEOS_DBUS_INIT_INITIALIZE_DBUS_CLIENT_H_
  6. namespace dbus {
  7. class Bus;
  8. } // namespace dbus
  9. namespace chromeos {
  10. // Initializes the appropriate version of D-Bus client.
  11. template <typename T>
  12. void InitializeDBusClient(dbus::Bus* bus) {
  13. #if defined(USE_REAL_DBUS_CLIENTS)
  14. T::Initialize(bus);
  15. #else
  16. // TODO(hashimoto): Always use fakes after adding
  17. // use_real_dbus_clients=true to where needed. crbug.com/952745
  18. if (bus) {
  19. T::Initialize(bus);
  20. } else {
  21. T::InitializeFake();
  22. }
  23. #endif
  24. }
  25. } // namespace chromeos
  26. #endif // CHROMEOS_DBUS_INIT_INITIALIZE_DBUS_CLIENT_H_