| 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/Connector.h" |
| 9 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
| 10 #include "services/device/public/interfaces/constants.mojom-blink.h" |
| 10 #include "wtf/Assertions.h" | 11 #include "wtf/Assertions.h" |
| 11 | 12 |
| 12 namespace blink { | 13 namespace blink { |
| 13 | 14 |
| 14 BatteryDispatcher& BatteryDispatcher::instance() { | 15 BatteryDispatcher& BatteryDispatcher::instance() { |
| 15 DEFINE_STATIC_LOCAL(BatteryDispatcher, batteryDispatcher, | 16 DEFINE_STATIC_LOCAL(BatteryDispatcher, batteryDispatcher, |
| 16 (new BatteryDispatcher)); | 17 (new BatteryDispatcher)); |
| 17 return batteryDispatcher; | 18 return batteryDispatcher; |
| 18 } | 19 } |
| 19 | 20 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 37 | 38 |
| 38 void BatteryDispatcher::updateBatteryStatus( | 39 void BatteryDispatcher::updateBatteryStatus( |
| 39 const BatteryStatus& batteryStatus) { | 40 const BatteryStatus& batteryStatus) { |
| 40 m_batteryStatus = batteryStatus; | 41 m_batteryStatus = batteryStatus; |
| 41 m_hasLatestData = true; | 42 m_hasLatestData = true; |
| 42 notifyControllers(); | 43 notifyControllers(); |
| 43 } | 44 } |
| 44 | 45 |
| 45 void BatteryDispatcher::startListening() { | 46 void BatteryDispatcher::startListening() { |
| 46 DCHECK(!m_monitor.is_bound()); | 47 DCHECK(!m_monitor.is_bound()); |
| 47 Platform::current()->interfaceProvider()->getInterface( | 48 Platform::current()->connector()->getInterface( |
| 48 mojo::MakeRequest(&m_monitor)); | 49 device::mojom::blink::kServiceName, mojo::MakeRequest(&m_monitor)); |
| 49 queryNextStatus(); | 50 queryNextStatus(); |
| 50 } | 51 } |
| 51 | 52 |
| 52 void BatteryDispatcher::stopListening() { | 53 void BatteryDispatcher::stopListening() { |
| 53 m_monitor.reset(); | 54 m_monitor.reset(); |
| 54 m_hasLatestData = false; | 55 m_hasLatestData = false; |
| 55 } | 56 } |
| 56 | 57 |
| 57 } // namespace blink | 58 } // namespace blink |
| OLD | NEW |