Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chromeos / dbus / services / liveness_service_provider.h
bloba261ff2fe0273fc1151320cf22d7e29b7a962c0c
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_LIVENESS_SERVICE_PROVIDER_H_
6 #define CHROMEOS_DBUS_SERVICES_LIVENESS_SERVICE_PROVIDER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h"
14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/services/cros_dbus_service.h"
16 #include "dbus/exported_object.h"
18 namespace dbus {
19 class MethodCall;
20 class Response;
23 namespace chromeos {
25 // This class exports a "CheckLiveness" D-Bus method that the session manager
26 // calls periodically to confirm that Chrome's UI thread is responsive to D-Bus
27 // messages. It can be tested with the following command:
29 // % dbus-send --system --type=method_call --print-reply
30 // --dest=org.chromium.LibCrosService
31 // /org/chromium/LibCrosService
32 // org.chromium.LibCrosServiceInterface.CheckLiveness
34 // -> method return sender=:1.9 -> dest=:1.27 reply_serial=2
36 // (An empty response should be returned.)
37 class CHROMEOS_EXPORT LivenessServiceProvider
38 : public CrosDBusService::ServiceProviderInterface {
39 public:
40 LivenessServiceProvider();
41 ~LivenessServiceProvider() override;
43 // CrosDBusService::ServiceProviderInterface overrides:
44 void Start(scoped_refptr<dbus::ExportedObject> exported_object) override;
46 private:
47 // Called from ExportedObject when CheckLiveness() is exported as a D-Bus
48 // method or failed to be exported.
49 void OnExported(const std::string& interface_name,
50 const std::string& method_name,
51 bool success);
53 // Called on UI thread in response to a D-Bus request.
54 void CheckLiveness(dbus::MethodCall* method_call,
55 dbus::ExportedObject::ResponseSender response_sender);
57 // Keep this last so that all weak pointers will be invalidated at the
58 // beginning of destruction.
59 base::WeakPtrFactory<LivenessServiceProvider> weak_ptr_factory_;
61 DISALLOW_COPY_AND_ASSIGN(LivenessServiceProvider);
64 } // namespace chromeos
66 #endif // CHROMEOS_DBUS_SERVICES_LIVENESS_SERVICE_PROVIDER_H_