1 // Copyright (c) 2012 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.
5 #ifndef CHROMEOS_DBUS_SERVICES_CROS_DBUS_SERVICE_H_
6 #define CHROMEOS_DBUS_SERVICES_CROS_DBUS_SERVICE_H_
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/threading/platform_thread.h"
13 #include "chromeos/chromeos_export.h"
22 // CrosDBusService is used to run a D-Bus service inside Chrome for Chrome
23 // OS. The service will be registered as follows:
25 // Service name: org.chromium.LibCrosService (kLibCrosServiceName)
26 // Object path: chromium/LibCrosService (kLibCrosServicePath)
28 // For historical reasons, the rather irrelevant name "LibCrosService" is
29 // used in the D-Bus constants such as the service name.
31 // CrosDBusService exports D-Bus methods through service provider classes
32 // that implement CrosDBusService::ServiceProviderInterface.
34 class CHROMEOS_EXPORT CrosDBusService
{
36 // CrosDBusService consists of service providers that implement this
38 class ServiceProviderInterface
{
40 // Starts the service provider. |exported_object| is used to export
43 scoped_refptr
<dbus::ExportedObject
> exported_object
) = 0;
45 virtual ~ServiceProviderInterface();
48 // Initializes the global instance.
49 static void Initialize(
50 ScopedVector
<ServiceProviderInterface
> service_providers
);
51 // Destroys the global instance.
52 static void Shutdown();
55 virtual ~CrosDBusService();
58 friend class CrosDBusServiceTest
;
60 // Initializes the global instance for testing.
61 static void InitializeForTesting(
63 ScopedVector
<ServiceProviderInterface
> service_providers
);
66 } // namespace chromeos
68 #endif // CHROMEOS_DBUS_SERVICES_CROS_DBUS_SERVICE_H_