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/InterfaceProvider.h" |
8 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.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 |
(...skipping 23 matching lines...) Expand all Loading... |
43 void BatteryDispatcher::updateBatteryStatus(const BatteryStatus& batteryStatus) | 43 void BatteryDispatcher::updateBatteryStatus(const BatteryStatus& batteryStatus) |
44 { | 44 { |
45 m_batteryStatus = batteryStatus; | 45 m_batteryStatus = batteryStatus; |
46 m_hasLatestData = true; | 46 m_hasLatestData = true; |
47 notifyControllers(); | 47 notifyControllers(); |
48 } | 48 } |
49 | 49 |
50 void BatteryDispatcher::startListening() | 50 void BatteryDispatcher::startListening() |
51 { | 51 { |
52 DCHECK(!m_monitor.is_bound()); | 52 DCHECK(!m_monitor.is_bound()); |
53 Platform::current()->serviceRegistry()->connectToRemoteService( | 53 Platform::current()->interfaceProvider()->getInterface(mojo::GetProxy(&m_mon
itor)); |
54 mojo::GetProxy(&m_monitor)); | |
55 queryNextStatus(); | 54 queryNextStatus(); |
56 } | 55 } |
57 | 56 |
58 void BatteryDispatcher::stopListening() | 57 void BatteryDispatcher::stopListening() |
59 { | 58 { |
60 m_monitor.reset(); | 59 m_monitor.reset(); |
61 m_hasLatestData = false; | 60 m_hasLatestData = false; |
62 } | 61 } |
63 | 62 |
64 } // namespace blink | 63 } // namespace blink |
OLD | NEW |