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 "platform/battery/battery_dispatcher_proxy.h" | 5 #include "platform/battery/battery_dispatcher_proxy.h" |
6 | 6 |
7 #include "platform/battery/battery_status.h" | 7 #include "platform/battery/battery_status.h" |
8 #include "platform/threading/BindForMojo.h" | 8 #include "platform/threading/BindForMojo.h" |
9 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
10 #include "public/platform/ServiceRegistry.h" | |
10 #include "wtf/Assertions.h" | 11 #include "wtf/Assertions.h" |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 | 14 |
14 BatteryDispatcherProxy::BatteryDispatcherProxy(Listener* listener) | 15 BatteryDispatcherProxy::BatteryDispatcherProxy(Listener* listener) |
15 : listener_(listener) { | 16 : listener_(listener) { |
16 ASSERT(listener_); | 17 ASSERT(listener_); |
17 } | 18 } |
18 | 19 |
19 BatteryDispatcherProxy::~BatteryDispatcherProxy() {} | 20 BatteryDispatcherProxy::~BatteryDispatcherProxy() {} |
20 | 21 |
21 void BatteryDispatcherProxy::StartListening() { | 22 void BatteryDispatcherProxy::StartListening() { |
22 ASSERT(!monitor_.is_bound()); | 23 ASSERT(!monitor_.is_bound()); |
23 Platform::current()->connectToRemoteService(mojo::GetProxy(&monitor_)); | 24 if (!Platform::current()->serviceRegistry()) |
esprehn
2016/03/29 05:26:20
how do we get here with a null registry? I think t
Sam McNally
2016/03/30 00:20:53
The equivalent of a null registry here would have
| |
25 return; | |
26 | |
27 Platform::current()->serviceRegistry()->connectToRemoteService( | |
28 mojo::GetProxy(&monitor_)); | |
24 // monitor_ can be null during testing. | 29 // monitor_ can be null during testing. |
25 if (monitor_) | 30 if (monitor_) |
26 QueryNextStatus(); | 31 QueryNextStatus(); |
27 } | 32 } |
28 | 33 |
29 void BatteryDispatcherProxy::StopListening() { | 34 void BatteryDispatcherProxy::StopListening() { |
30 // monitor_ can be null during testing. | 35 // monitor_ can be null during testing. |
31 if (monitor_) | 36 if (monitor_) |
32 monitor_.reset(); | 37 monitor_.reset(); |
33 } | 38 } |
(...skipping 12 matching lines...) Expand all Loading... | |
46 DCHECK(battery_status); | 51 DCHECK(battery_status); |
47 | 52 |
48 BatteryStatus status(battery_status->charging, | 53 BatteryStatus status(battery_status->charging, |
49 battery_status->charging_time, | 54 battery_status->charging_time, |
50 battery_status->discharging_time, | 55 battery_status->discharging_time, |
51 battery_status->level); | 56 battery_status->level); |
52 listener_->OnUpdateBatteryStatus(status); | 57 listener_->OnUpdateBatteryStatus(status); |
53 } | 58 } |
54 | 59 |
55 } // namespace blink | 60 } // namespace blink |
OLD | NEW |