Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: chromeos/dbus/services/display_power_service_provider.h

Issue 739123002: Move DisplayPowerServiceProvider to chromeos/dbus/services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/dbus/services/display_power_service_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_ 5 #ifndef CHROMEOS_DBUS_SERVICES_DISPLAY_POWER_SERVICE_PROVIDER_H_
6 #define CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_ 6 #define CHROMEOS_DBUS_SERVICES_DISPLAY_POWER_SERVICE_PROVIDER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/services/cros_dbus_service.h" 16 #include "chromeos/dbus/services/cros_dbus_service.h"
15 #include "dbus/exported_object.h" 17 #include "dbus/exported_object.h"
18 #include "third_party/cros_system_api/dbus/service_constants.h"
16 19
17 namespace dbus { 20 namespace dbus {
18 class MethodCall; 21 class MethodCall;
19 class Response;
20 } 22 }
21 23
22 namespace chromeos { 24 namespace chromeos {
23 25
24 // This class exports "SetDisplayPower" and "SetDisplaySoftwareDimming" 26 // This class exports "SetDisplayPower" and "SetDisplaySoftwareDimming"
25 // D-Bus methods that the power manager calls to instruct Chrome to turn 27 // D-Bus methods that the power manager calls to instruct Chrome to turn
26 // various displays on or off or dim them. 28 // various displays on or off or dim them.
27 class DisplayPowerServiceProvider 29 class CHROMEOS_EXPORT DisplayPowerServiceProvider
28 : public CrosDBusService::ServiceProviderInterface { 30 : public CrosDBusService::ServiceProviderInterface {
29 public: 31 public:
30 DisplayPowerServiceProvider(); 32 class Delegate {
33 public:
34 virtual ~Delegate() {}
35
36 // Sets the display power state.
37 virtual void SetDisplayPower(DisplayPowerState power_state) = 0;
38
39 // Dims or undims the screen.
40 virtual void SetDimming(bool dimmed) = 0;
41 };
42
43 explicit DisplayPowerServiceProvider(scoped_ptr<Delegate> delegate);
31 virtual ~DisplayPowerServiceProvider(); 44 virtual ~DisplayPowerServiceProvider();
32 45
33 // CrosDBusService::ServiceProviderInterface overrides: 46 // CrosDBusService::ServiceProviderInterface overrides:
34 virtual void Start( 47 virtual void Start(
35 scoped_refptr<dbus::ExportedObject> exported_object) override; 48 scoped_refptr<dbus::ExportedObject> exported_object) override;
36 49
37 private: 50 private:
38 // Called from ExportedObject when a handler is exported as a D-Bus 51 // Called from ExportedObject when a handler is exported as a D-Bus
39 // method or failed to be exported. 52 // method or failed to be exported.
40 void OnExported(const std::string& interface_name, 53 void OnExported(const std::string& interface_name,
41 const std::string& method_name, 54 const std::string& method_name,
42 bool success); 55 bool success);
43 56
44 // Called on UI thread in response to D-Bus requests. 57 // Called on UI thread in response to D-Bus requests.
45 void SetDisplayPower(dbus::MethodCall* method_call, 58 void SetDisplayPower(dbus::MethodCall* method_call,
46 dbus::ExportedObject::ResponseSender response_sender); 59 dbus::ExportedObject::ResponseSender response_sender);
47 void SetDisplaySoftwareDimming( 60 void SetDisplaySoftwareDimming(
48 dbus::MethodCall* method_call, 61 dbus::MethodCall* method_call,
49 dbus::ExportedObject::ResponseSender response_sender); 62 dbus::ExportedObject::ResponseSender response_sender);
50 63
64 scoped_ptr<Delegate> delegate_;
65
51 // Keep this last so that all weak pointers will be invalidated at the 66 // Keep this last so that all weak pointers will be invalidated at the
52 // beginning of destruction. 67 // beginning of destruction.
53 base::WeakPtrFactory<DisplayPowerServiceProvider> weak_ptr_factory_; 68 base::WeakPtrFactory<DisplayPowerServiceProvider> weak_ptr_factory_;
54 69
55 DISALLOW_COPY_AND_ASSIGN(DisplayPowerServiceProvider); 70 DISALLOW_COPY_AND_ASSIGN(DisplayPowerServiceProvider);
56 }; 71 };
57 72
58 } // namespace chromeos 73 } // namespace chromeos
59 74
60 #endif // CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_ 75 #endif // CHROMEOS_DBUS_SERVICES_DISPLAY_POWER_SERVICE_PROVIDER_H_
OLDNEW
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/dbus/services/display_power_service_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698