blob: 7fb1c13937ca41ac5275b7c2081a7836b3f2da5e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_BATTERY_BATTERY_MONITOR_IMPL_H_
#define DEVICE_BATTERY_BATTERY_MONITOR_IMPL_H_
#include <vector>
#include "base/memory/scoped_ptr.h"
#include "device/battery/battery_export.h"
#include "device/battery/battery_monitor.mojom.h"
#include "device/battery/battery_status_service.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
namespace device {
class BatteryMonitorImpl : public BatteryMonitor {
public:
DEVICE_BATTERY_EXPORT static void Create(
mojo::InterfaceRequest<BatteryMonitor> request);
private:
typedef mojo::Callback<void(BatteryStatusPtr)> BatteryStatusCallback;
explicit BatteryMonitorImpl(mojo::InterfaceRequest<BatteryMonitor> request);
~BatteryMonitorImpl() override;
// BatteryMonitor methods:
void QueryNextStatus(const BatteryStatusCallback& callback) override;
void RegisterSubscription();
void DidChange(const BatteryStatus& battery_status);
void ReportStatus();
mojo::StrongBinding<BatteryMonitor> binding_;
scoped_ptr<BatteryStatusService::BatteryUpdateSubscription> subscription_;
std::vector<BatteryStatusCallback> callbacks_;
BatteryStatus status_;
bool status_to_report_;
DISALLOW_COPY_AND_ASSIGN(BatteryMonitorImpl);
};
} // namespace device
#endif // DEVICE_BATTERY_BATTERY_MONITOR_IMPL_H_
|