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

Side by Side Diff: device/battery/battery_status_manager_linux.h

Issue 2818673003: [DeviceService] Expose battery monitoring solely via the Device Service (Closed)
Patch Set: Java file format change Created 3 years, 7 months 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
OLDNEW
(Empty)
1 // Copyright 2014 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 #ifndef DEVICE_BATTERY_BATTERY_STATUS_MANAGER_LINUX_H_
5 #define DEVICE_BATTERY_BATTERY_STATUS_MANAGER_LINUX_H_
6
7 #include "device/battery/battery_export.h"
8 #include "device/battery/battery_status.mojom.h"
9 #include "device/battery/battery_status_manager.h"
10
11 namespace dbus {
12 class Bus;
13 } // namespace dbus
14
15 namespace device {
16 // UPowerDeviceState reflects the possible UPower.Device.State values,
17 // see upower.freedesktop.org/docs/Device.html#Device:State.
18 enum UPowerDeviceState {
19 UPOWER_DEVICE_STATE_UNKNOWN = 0,
20 UPOWER_DEVICE_STATE_CHARGING = 1,
21 UPOWER_DEVICE_STATE_DISCHARGING = 2,
22 UPOWER_DEVICE_STATE_EMPTY = 3,
23 UPOWER_DEVICE_STATE_FULL = 4,
24 UPOWER_DEVICE_STATE_PENDING_CHARGE = 5,
25 UPOWER_DEVICE_STATE_PENDING_DISCHARGE = 6,
26 };
27
28 // UPowerDeviceType reflects the possible UPower.Device.Type values,
29 // see upower.freedesktop.org/docs/Device.html#Device:Type.
30 enum UPowerDeviceType {
31 UPOWER_DEVICE_TYPE_UNKNOWN = 0,
32 UPOWER_DEVICE_TYPE_LINE_POWER = 1,
33 UPOWER_DEVICE_TYPE_BATTERY = 2,
34 UPOWER_DEVICE_TYPE_UPS = 3,
35 UPOWER_DEVICE_TYPE_MONITOR = 4,
36 UPOWER_DEVICE_TYPE_MOUSE = 5,
37 UPOWER_DEVICE_TYPE_KEYBOARD = 6,
38 UPOWER_DEVICE_TYPE_PDA = 7,
39 UPOWER_DEVICE_TYPE_PHONE = 8,
40 };
41
42 // Creates a notification thread and delegates Start/Stop calls to it.
43 class DEVICE_BATTERY_EXPORT BatteryStatusManagerLinux
44 : public BatteryStatusManager {
45 public:
46 explicit BatteryStatusManagerLinux(
47 const BatteryStatusService::BatteryUpdateCallback& callback);
48 ~BatteryStatusManagerLinux() override;
49
50 private:
51 friend class BatteryStatusManagerLinuxTest;
52 class BatteryStatusNotificationThread;
53
54 // BatteryStatusManager:
55 bool StartListeningBatteryChange() override;
56 void StopListeningBatteryChange() override;
57
58 // Starts the notifier thread if not already started and returns true on
59 // success.
60 bool StartNotifierThreadIfNecessary();
61 base::Thread* GetNotifierThreadForTesting();
62
63 static std::unique_ptr<BatteryStatusManagerLinux> CreateForTesting(
64 const BatteryStatusService::BatteryUpdateCallback& callback,
65 dbus::Bus* bus);
66
67 BatteryStatusService::BatteryUpdateCallback callback_;
68 std::unique_ptr<BatteryStatusNotificationThread> notifier_thread_;
69
70 DISALLOW_COPY_AND_ASSIGN(BatteryStatusManagerLinux);
71 };
72
73 } // namespace device
74
75 #endif // DEVICE_BATTERY_BATTERY_STATUS_MANAGER_LINUX_H_
OLDNEW
« no previous file with comments | « device/battery/battery_status_manager_default.cc ('k') | device/battery/battery_status_manager_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698