Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / chromeos / dbus / display_power_service_provider.h
blob691fb2926324fcf950544bf32167f4404470a5f3
1 // Copyright (c) 2013 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 CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_
6 #define CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_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 "chrome/browser/chromeos/dbus/cros_dbus_service.h"
15 #include "dbus/exported_object.h"
17 namespace dbus {
18 class MethodCall;
19 class Response;
22 namespace chromeos {
24 // This class exports "SetDisplayPower" and "SetDisplaySoftwareDimming"
25 // D-Bus methods that the power manager calls to instruct Chrome to turn
26 // various displays on or off or dim them.
27 class DisplayPowerServiceProvider
28 : public CrosDBusService::ServiceProviderInterface {
29 public:
30 DisplayPowerServiceProvider();
31 virtual ~DisplayPowerServiceProvider();
33 // CrosDBusService::ServiceProviderInterface overrides:
34 virtual void Start(
35 scoped_refptr<dbus::ExportedObject> exported_object) override;
37 private:
38 // Called from ExportedObject when a handler is exported as a D-Bus
39 // method or failed to be exported.
40 void OnExported(const std::string& interface_name,
41 const std::string& method_name,
42 bool success);
44 // Called on UI thread in response to D-Bus requests.
45 void SetDisplayPower(dbus::MethodCall* method_call,
46 dbus::ExportedObject::ResponseSender response_sender);
47 void SetDisplaySoftwareDimming(
48 dbus::MethodCall* method_call,
49 dbus::ExportedObject::ResponseSender response_sender);
51 // Keep this last so that all weak pointers will be invalidated at the
52 // beginning of destruction.
53 base::WeakPtrFactory<DisplayPowerServiceProvider> weak_ptr_factory_;
55 DISALLOW_COPY_AND_ASSIGN(DisplayPowerServiceProvider);
58 } // namespace chromeos
60 #endif // CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_