OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 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" |
| 16 |
| 17 namespace dbus { |
| 18 class MethodCall; |
| 19 class Response; |
| 20 } |
| 21 |
| 22 namespace chromeos { |
| 23 |
| 24 // This class exports a "SetDisplayPower" D-Bus method that the power |
| 25 // manager calls to instruct Chrome to turn various displays on or off. |
| 26 class DisplayPowerServiceProvider |
| 27 : public CrosDBusService::ServiceProviderInterface { |
| 28 public: |
| 29 DisplayPowerServiceProvider(); |
| 30 virtual ~DisplayPowerServiceProvider(); |
| 31 |
| 32 // CrosDBusService::ServiceProviderInterface overrides: |
| 33 virtual void Start( |
| 34 scoped_refptr<dbus::ExportedObject> exported_object) OVERRIDE; |
| 35 |
| 36 private: |
| 37 // Called from ExportedObject when SetDisplayPower() is exported as a D-Bus |
| 38 // method or failed to be exported. |
| 39 void OnExported(const std::string& interface_name, |
| 40 const std::string& method_name, |
| 41 bool success); |
| 42 |
| 43 // Called on UI thread in response to a D-Bus request. |
| 44 void SetDisplayPower(dbus::MethodCall* method_call, |
| 45 dbus::ExportedObject::ResponseSender response_sender); |
| 46 |
| 47 // Keep this last so that all weak pointers will be invalidated at the |
| 48 // beginning of destruction. |
| 49 base::WeakPtrFactory<DisplayPowerServiceProvider> weak_ptr_factory_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(DisplayPowerServiceProvider); |
| 52 }; |
| 53 |
| 54 } // namespace chromeos |
| 55 |
| 56 #endif // CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_ |
OLD | NEW |