Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Side by Side Diff: content/renderer/battery_status/battery_status_dispatcher.cc

Issue 768113006: Resurrect battery_status_dispatcher_unittest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/renderer/battery_status/battery_status_dispatcher.h" 5 #include "content/renderer/battery_status/battery_status_dispatcher.h"
6 6
7 #include "content/public/common/service_registry.h" 7 #include "content/public/common/service_registry.h"
8 #include "content/public/renderer/render_thread.h" 8 #include "content/public/renderer/render_thread.h"
9 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h" 9 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 BatteryStatusDispatcher::BatteryStatusDispatcher( 13 BatteryStatusDispatcher::BatteryStatusDispatcher(
14 blink::WebBatteryStatusListener* listener) 14 blink::WebBatteryStatusListener* listener)
15 : listener_(listener) { 15 : listener_(listener) {
16 DCHECK(listener_); 16 DCHECK(listener_);
17 17
18 RenderThread::Get()->GetServiceRegistry()->ConnectToRemoteService(&monitor_); 18 if (ServiceRegistry* registry = RenderThread::Get()->GetServiceRegistry()) {
19 monitor_.set_client(this); 19 // registry can be null during testing.
20 registry->ConnectToRemoteService(&monitor_);
21 monitor_.set_client(this);
22 }
20 } 23 }
21 24
22 BatteryStatusDispatcher::~BatteryStatusDispatcher() { 25 BatteryStatusDispatcher::~BatteryStatusDispatcher() {
23 } 26 }
24 27
25 void BatteryStatusDispatcher::DidChange( 28 void BatteryStatusDispatcher::DidChange(
26 device::BatteryStatusPtr battery_status) { 29 device::BatteryStatusPtr battery_status) {
27 DCHECK(battery_status); 30 DCHECK(battery_status);
28 blink::WebBatteryStatus web_battery_status; 31 blink::WebBatteryStatus web_battery_status;
29 web_battery_status.charging = battery_status->charging; 32 web_battery_status.charging = battery_status->charging;
30 web_battery_status.chargingTime = battery_status->charging_time; 33 web_battery_status.chargingTime = battery_status->charging_time;
31 web_battery_status.dischargingTime = battery_status->discharging_time; 34 web_battery_status.dischargingTime = battery_status->discharging_time;
32 web_battery_status.level = battery_status->level; 35 web_battery_status.level = battery_status->level;
33 listener_->updateBatteryStatus(web_battery_status); 36 listener_->updateBatteryStatus(web_battery_status);
34 } 37 }
35 38
36 } // namespace content 39 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698