OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "modules/battery/BatteryDispatcher.h" | 5 #include "modules/battery/BatteryDispatcher.h" |
6 | 6 |
7 #include "platform/mojo/MojoHelper.h" | 7 #include "platform/mojo/MojoHelper.h" |
8 #include "public/platform/Platform.h" | 8 #include "public/platform/Platform.h" |
9 #include "public/platform/ServiceRegistry.h" | 9 #include "public/platform/ServiceRegistry.h" |
10 #include "wtf/Assertions.h" | 10 #include "wtf/Assertions.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 BatteryDispatcher& BatteryDispatcher::instance() | 14 BatteryDispatcher& BatteryDispatcher::instance() |
15 { | 15 { |
16 DEFINE_STATIC_LOCAL(BatteryDispatcher, batteryDispatcher, (new BatteryDispat
cher)); | 16 DEFINE_STATIC_LOCAL(BatteryDispatcher, batteryDispatcher, (new BatteryDispat
cher)); |
17 return batteryDispatcher; | 17 return batteryDispatcher; |
18 } | 18 } |
19 | 19 |
20 BatteryDispatcher::BatteryDispatcher() | 20 BatteryDispatcher::BatteryDispatcher() |
21 : m_hasLatestData(false) | 21 : m_hasLatestData(false) |
22 { | 22 { |
23 } | 23 } |
24 | 24 |
25 void BatteryDispatcher::queryNextStatus() | 25 void BatteryDispatcher::queryNextStatus() |
26 { | 26 { |
27 m_monitor->QueryNextStatus(createBaseCallback(bind(&BatteryDispatcher::onDid
Change, wrapPersistent(this)))); | 27 m_monitor->QueryNextStatus(createBaseCallback(WTF::bind(&BatteryDispatcher::
onDidChange, wrapPersistent(this)))); |
28 } | 28 } |
29 | 29 |
30 void BatteryDispatcher::onDidChange(device::blink::BatteryStatusPtr batteryStatu
s) | 30 void BatteryDispatcher::onDidChange(device::blink::BatteryStatusPtr batteryStatu
s) |
31 { | 31 { |
32 queryNextStatus(); | 32 queryNextStatus(); |
33 | 33 |
34 DCHECK(batteryStatus); | 34 DCHECK(batteryStatus); |
35 | 35 |
36 updateBatteryStatus(BatteryStatus( | 36 updateBatteryStatus(BatteryStatus( |
37 batteryStatus->charging, | 37 batteryStatus->charging, |
(...skipping 17 matching lines...) Expand all Loading... |
55 queryNextStatus(); | 55 queryNextStatus(); |
56 } | 56 } |
57 | 57 |
58 void BatteryDispatcher::stopListening() | 58 void BatteryDispatcher::stopListening() |
59 { | 59 { |
60 m_monitor.reset(); | 60 m_monitor.reset(); |
61 m_hasLatestData = false; | 61 m_hasLatestData = false; |
62 } | 62 } |
63 | 63 |
64 } // namespace blink | 64 } // namespace blink |
OLD | NEW |