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.
5 #ifndef DEVICE_BATTERY_BATTERY_MONITOR_IMPL_H_
6 #define DEVICE_BATTERY_BATTERY_MONITOR_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "device/battery/battery_export.h"
10 #include "device/battery/battery_monitor.mojom.h"
11 #include "device/battery/battery_status_service.h"
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
16 class BatteryMonitorImpl
: public BatteryMonitor
{
18 DEVICE_BATTERY_EXPORT
static void Create(
19 mojo::InterfaceRequest
<BatteryMonitor
> request
);
22 typedef mojo::Callback
<void(BatteryStatusPtr
)> BatteryStatusCallback
;
24 explicit BatteryMonitorImpl(mojo::InterfaceRequest
<BatteryMonitor
> request
);
25 ~BatteryMonitorImpl() override
;
27 // BatteryMonitor methods:
28 void QueryNextStatus(const BatteryStatusCallback
& callback
) override
;
30 void RegisterSubscription();
31 void DidChange(const BatteryStatus
& battery_status
);
34 mojo::StrongBinding
<BatteryMonitor
> binding_
;
35 scoped_ptr
<BatteryStatusService::BatteryUpdateSubscription
> subscription_
;
36 BatteryStatusCallback callback_
;
37 BatteryStatus status_
;
38 bool status_to_report_
;
40 DISALLOW_COPY_AND_ASSIGN(BatteryMonitorImpl
);
45 #endif // DEVICE_BATTERY_BATTERY_MONITOR_IMPL_H_