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

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

Issue 833983002: Stop using [Client=...] feature of Mojom for BatteryMonitor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixup content integration tests 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 : binding_(this),
16 listener_(listener) {
16 DCHECK(listener_); 17 DCHECK(listener_);
17 18
18 RenderThread::Get()->GetServiceRegistry()->ConnectToRemoteService(&monitor_); 19 RenderThread::Get()->GetServiceRegistry()->ConnectToRemoteService(&monitor_);
jamesr 2015/01/05 23:33:09 i'm not as familiar with content::'s service regis
19 monitor_.set_client(this); 20
21 device::BatteryMonitorClientPtr proxy;
22 binding_.Bind(&proxy);
23 monitor_->SetClient(proxy.Pass());
20 } 24 }
21 25
22 BatteryStatusDispatcher::~BatteryStatusDispatcher() { 26 BatteryStatusDispatcher::~BatteryStatusDispatcher() {
23 } 27 }
24 28
25 void BatteryStatusDispatcher::DidChange( 29 void BatteryStatusDispatcher::DidChange(
26 device::BatteryStatusPtr battery_status) { 30 device::BatteryStatusPtr battery_status) {
27 DCHECK(battery_status); 31 DCHECK(battery_status);
28 blink::WebBatteryStatus web_battery_status; 32 blink::WebBatteryStatus web_battery_status;
29 web_battery_status.charging = battery_status->charging; 33 web_battery_status.charging = battery_status->charging;
30 web_battery_status.chargingTime = battery_status->charging_time; 34 web_battery_status.chargingTime = battery_status->charging_time;
31 web_battery_status.dischargingTime = battery_status->discharging_time; 35 web_battery_status.dischargingTime = battery_status->discharging_time;
32 web_battery_status.level = battery_status->level; 36 web_battery_status.level = battery_status->level;
33 listener_->updateBatteryStatus(web_battery_status); 37 listener_->updateBatteryStatus(web_battery_status);
34 } 38 }
35 39
36 } // namespace content 40 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698