OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMEOS_DBUS_SERVICES_LIVENESS_SERVICE_PROVIDER_H_ | 5 #ifndef CHROMEOS_DBUS_SERVICES_LIVENESS_SERVICE_PROVIDER_H_ |
6 #define CHROMEOS_DBUS_SERVICES_LIVENESS_SERVICE_PROVIDER_H_ | 6 #define CHROMEOS_DBUS_SERVICES_LIVENESS_SERVICE_PROVIDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "chromeos/chromeos_export.h" | 14 #include "chromeos/chromeos_export.h" |
15 #include "chromeos/dbus/services/cros_dbus_service.h" | 15 #include "chromeos/dbus/services/cros_dbus_service.h" |
16 #include "dbus/exported_object.h" | 16 #include "dbus/exported_object.h" |
17 | 17 |
18 namespace dbus { | 18 namespace dbus { |
19 class MethodCall; | 19 class MethodCall; |
20 } | 20 } |
21 | 21 |
22 namespace chromeos { | 22 namespace chromeos { |
23 | 23 |
24 // This class exports a "CheckLiveness" D-Bus method that the session manager | 24 // This class exports a "CheckLiveness" D-Bus method that the session manager |
25 // calls periodically to confirm that Chrome's UI thread is responsive to D-Bus | 25 // calls periodically to confirm that Chrome's UI thread is responsive to D-Bus |
26 // messages. It can be tested with the following command: | 26 // messages. It can be tested with the following command: |
27 // | 27 // |
28 // % dbus-send --system --type=method_call --print-reply | 28 // % dbus-send --system --type=method_call --print-reply |
29 // --dest=org.chromium.LibCrosService | 29 // --dest=org.chromium.LivenessService |
30 // /org/chromium/LibCrosService | 30 // /org/chromium/LivenessService |
31 // org.chromium.LibCrosServiceInterface.CheckLiveness | 31 // org.chromium.LivenessServiceInterface.CheckLiveness |
32 // | 32 // |
33 // -> method return sender=:1.9 -> dest=:1.27 reply_serial=2 | 33 // -> method return sender=:1.9 -> dest=:1.27 reply_serial=2 |
34 // | 34 // |
35 // (An empty response should be returned.) | 35 // (An empty response should be returned.) |
36 class CHROMEOS_EXPORT LivenessServiceProvider | 36 class CHROMEOS_EXPORT LivenessServiceProvider |
37 : public CrosDBusService::ServiceProviderInterface { | 37 : public CrosDBusService::ServiceProviderInterface { |
38 public: | 38 public: |
39 LivenessServiceProvider(); | 39 explicit LivenessServiceProvider(const char* service_interface); |
Daniel Erat
2017/03/11 01:27:42
const std::string& ?
i'd also add a TODO to remov
teravest
2017/03/13 16:02:28
Done.
| |
40 ~LivenessServiceProvider() override; | 40 ~LivenessServiceProvider() override; |
41 | 41 |
42 // CrosDBusService::ServiceProviderInterface overrides: | 42 // CrosDBusService::ServiceProviderInterface overrides: |
43 void Start(scoped_refptr<dbus::ExportedObject> exported_object) override; | 43 void Start(scoped_refptr<dbus::ExportedObject> exported_object) override; |
44 | 44 |
45 private: | 45 private: |
46 // Called from ExportedObject when CheckLiveness() is exported as a D-Bus | 46 // Called from ExportedObject when CheckLiveness() is exported as a D-Bus |
47 // method or failed to be exported. | 47 // method or failed to be exported. |
48 void OnExported(const std::string& interface_name, | 48 void OnExported(const std::string& interface_name, |
49 const std::string& method_name, | 49 const std::string& method_name, |
50 bool success); | 50 bool success); |
51 | 51 |
52 // Called on UI thread in response to a D-Bus request. | 52 // Called on UI thread in response to a D-Bus request. |
53 void CheckLiveness(dbus::MethodCall* method_call, | 53 void CheckLiveness(dbus::MethodCall* method_call, |
54 dbus::ExportedObject::ResponseSender response_sender); | 54 dbus::ExportedObject::ResponseSender response_sender); |
55 | 55 |
56 const char* service_interface_; | |
Daniel Erat
2017/03/11 01:27:42
std::string?
teravest
2017/03/13 16:02:28
Done.
| |
57 | |
56 // Keep this last so that all weak pointers will be invalidated at the | 58 // Keep this last so that all weak pointers will be invalidated at the |
57 // beginning of destruction. | 59 // beginning of destruction. |
58 base::WeakPtrFactory<LivenessServiceProvider> weak_ptr_factory_; | 60 base::WeakPtrFactory<LivenessServiceProvider> weak_ptr_factory_; |
59 | 61 |
60 DISALLOW_COPY_AND_ASSIGN(LivenessServiceProvider); | 62 DISALLOW_COPY_AND_ASSIGN(LivenessServiceProvider); |
61 }; | 63 }; |
62 | 64 |
63 } // namespace chromeos | 65 } // namespace chromeos |
64 | 66 |
65 #endif // CHROMEOS_DBUS_SERVICES_LIVENESS_SERVICE_PROVIDER_H_ | 67 #endif // CHROMEOS_DBUS_SERVICES_LIVENESS_SERVICE_PROVIDER_H_ |
OLD | NEW |