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/MojoHelper.h" | 7 #include "platform/MojoHelper.h" |
8 #include "public/platform/Platform.h" | 8 #include "public/platform/Platform.h" |
9 #include "public/platform/ServiceRegistry.h" | |
9 #include "wtf/Assertions.h" | 10 #include "wtf/Assertions.h" |
10 #include "wtf/PassOwnPtr.h" | 11 #include "wtf/PassOwnPtr.h" |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 | 14 |
14 BatteryDispatcher& BatteryDispatcher::instance() | 15 BatteryDispatcher& BatteryDispatcher::instance() |
15 { | 16 { |
16 DEFINE_STATIC_LOCAL(BatteryDispatcher, batteryDispatcher, (new BatteryDispat cher)); | 17 DEFINE_STATIC_LOCAL(BatteryDispatcher, batteryDispatcher, (new BatteryDispat cher)); |
17 return batteryDispatcher; | 18 return batteryDispatcher; |
18 } | 19 } |
(...skipping 27 matching lines...) Expand all Loading... | |
46 void BatteryDispatcher::updateBatteryStatus(const BatteryStatus& batteryStatus) | 47 void BatteryDispatcher::updateBatteryStatus(const BatteryStatus& batteryStatus) |
47 { | 48 { |
48 m_batteryStatus = batteryStatus; | 49 m_batteryStatus = batteryStatus; |
49 m_hasLatestData = true; | 50 m_hasLatestData = true; |
50 notifyControllers(); | 51 notifyControllers(); |
51 } | 52 } |
52 | 53 |
53 void BatteryDispatcher::startListening() | 54 void BatteryDispatcher::startListening() |
54 { | 55 { |
55 ASSERT(!m_monitor.is_bound()); | 56 ASSERT(!m_monitor.is_bound()); |
56 Platform::current()->connectToRemoteService(mojo::GetProxy(&m_monitor)); | 57 Platform::current()->serviceRegistry()->connectToRemoteService( |
58 mojo::GetProxy(&m_monitor)); | |
57 // m_monitor can be null during testing. | 59 // m_monitor can be null during testing. |
timvolodine
2016/04/05 16:58:04
not really related to this path: I was wondering i
Sam McNally
2016/04/06 01:32:53
I don't think this ever was true. In tests m_monit
| |
58 if (m_monitor) | 60 if (m_monitor) |
59 queryNextStatus(); | 61 queryNextStatus(); |
60 } | 62 } |
61 | 63 |
62 void BatteryDispatcher::stopListening() | 64 void BatteryDispatcher::stopListening() |
63 { | 65 { |
64 // m_monitor can be null during testing. | 66 // m_monitor can be null during testing. |
65 if (m_monitor) | 67 if (m_monitor) |
66 m_monitor.reset(); | 68 m_monitor.reset(); |
67 m_hasLatestData = false; | 69 m_hasLatestData = false; |
68 } | 70 } |
69 | 71 |
70 } // namespace blink | 72 } // namespace blink |
OLD | NEW |