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

Side by Side Diff: third_party/WebKit/Source/modules/battery/BatteryDispatcher.cpp

Issue 2801173004: Add '.mojom' suffix for battery mojom modules. (Closed)
Patch Set: Rebase only Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/modules/battery/BatteryDispatcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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/Platform.h" 8 #include "public/platform/Platform.h"
9 #include "services/device/public/interfaces/constants.mojom-blink.h" 9 #include "services/device/public/interfaces/constants.mojom-blink.h"
10 #include "services/service_manager/public/cpp/connector.h" 10 #include "services/service_manager/public/cpp/connector.h"
11 #include "wtf/Assertions.h" 11 #include "wtf/Assertions.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 BatteryDispatcher& BatteryDispatcher::instance() { 15 BatteryDispatcher& BatteryDispatcher::instance() {
16 DEFINE_STATIC_LOCAL(BatteryDispatcher, batteryDispatcher, 16 DEFINE_STATIC_LOCAL(BatteryDispatcher, batteryDispatcher,
17 (new BatteryDispatcher)); 17 (new BatteryDispatcher));
18 return batteryDispatcher; 18 return batteryDispatcher;
19 } 19 }
20 20
21 BatteryDispatcher::BatteryDispatcher() : m_hasLatestData(false) {} 21 BatteryDispatcher::BatteryDispatcher() : m_hasLatestData(false) {}
22 22
23 void BatteryDispatcher::queryNextStatus() { 23 void BatteryDispatcher::queryNextStatus() {
24 m_monitor->QueryNextStatus(convertToBaseCallback( 24 m_monitor->QueryNextStatus(convertToBaseCallback(
25 WTF::bind(&BatteryDispatcher::onDidChange, wrapPersistent(this)))); 25 WTF::bind(&BatteryDispatcher::onDidChange, wrapPersistent(this))));
26 } 26 }
27 27
28 void BatteryDispatcher::onDidChange( 28 void BatteryDispatcher::onDidChange(
29 device::blink::BatteryStatusPtr batteryStatus) { 29 device::mojom::blink::BatteryStatusPtr batteryStatus) {
30 queryNextStatus(); 30 queryNextStatus();
31 31
32 DCHECK(batteryStatus); 32 DCHECK(batteryStatus);
33 33
34 updateBatteryStatus( 34 updateBatteryStatus(
35 BatteryStatus(batteryStatus->charging, batteryStatus->charging_time, 35 BatteryStatus(batteryStatus->charging, batteryStatus->charging_time,
36 batteryStatus->discharging_time, batteryStatus->level)); 36 batteryStatus->discharging_time, batteryStatus->level));
37 } 37 }
38 38
39 void BatteryDispatcher::updateBatteryStatus( 39 void BatteryDispatcher::updateBatteryStatus(
40 const BatteryStatus& batteryStatus) { 40 const BatteryStatus& batteryStatus) {
41 m_batteryStatus = batteryStatus; 41 m_batteryStatus = batteryStatus;
42 m_hasLatestData = true; 42 m_hasLatestData = true;
43 notifyControllers(); 43 notifyControllers();
44 } 44 }
45 45
46 void BatteryDispatcher::startListening() { 46 void BatteryDispatcher::startListening() {
47 DCHECK(!m_monitor.is_bound()); 47 DCHECK(!m_monitor.is_bound());
48 Platform::current()->connector()->BindInterface( 48 Platform::current()->connector()->BindInterface(
49 device::mojom::blink::kServiceName, mojo::MakeRequest(&m_monitor)); 49 device::mojom::blink::kServiceName, mojo::MakeRequest(&m_monitor));
50 queryNextStatus(); 50 queryNextStatus();
51 } 51 }
52 52
53 void BatteryDispatcher::stopListening() { 53 void BatteryDispatcher::stopListening() {
54 m_monitor.reset(); 54 m_monitor.reset();
55 m_hasLatestData = false; 55 m_hasLatestData = false;
56 } 56 }
57 57
58 } // namespace blink 58 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/battery/BatteryDispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698