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

Side by Side Diff: device/battery/battery_monitor_impl.cc

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 | « device/battery/battery_monitor_impl.h ('k') | device/battery/battery_status.mojom » ('j') | 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 "device/battery/battery_monitor_impl.h" 5 #include "device/battery/battery_monitor_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "mojo/public/cpp/bindings/strong_binding.h" 12 #include "mojo/public/cpp/bindings/strong_binding.h"
13 13
14 namespace device { 14 namespace device {
15 15
16 // static 16 // static
17 void BatteryMonitorImpl::Create(BatteryMonitorRequest request) { 17 void BatteryMonitorImpl::Create(mojom::BatteryMonitorRequest request) {
18 auto* impl = new BatteryMonitorImpl; 18 auto* impl = new BatteryMonitorImpl;
19 auto binding = 19 auto binding =
20 mojo::MakeStrongBinding(base::WrapUnique(impl), std::move(request)); 20 mojo::MakeStrongBinding(base::WrapUnique(impl), std::move(request));
21 impl->binding_ = binding; 21 impl->binding_ = binding;
22 } 22 }
23 23
24 BatteryMonitorImpl::BatteryMonitorImpl() : status_to_report_(false) { 24 BatteryMonitorImpl::BatteryMonitorImpl() : status_to_report_(false) {
25 // NOTE: DidChange may be called before AddCallback returns. This is done to 25 // NOTE: DidChange may be called before AddCallback returns. This is done to
26 // report current status. 26 // report current status.
27 subscription_ = BatteryStatusService::GetInstance()->AddCallback( 27 subscription_ = BatteryStatusService::GetInstance()->AddCallback(
(...skipping 12 matching lines...) Expand all
40 } 40 }
41 callback_ = callback; 41 callback_ = callback;
42 42
43 if (status_to_report_) 43 if (status_to_report_)
44 ReportStatus(); 44 ReportStatus();
45 } 45 }
46 46
47 void BatteryMonitorImpl::RegisterSubscription() { 47 void BatteryMonitorImpl::RegisterSubscription() {
48 } 48 }
49 49
50 void BatteryMonitorImpl::DidChange(const BatteryStatus& battery_status) { 50 void BatteryMonitorImpl::DidChange(const mojom::BatteryStatus& battery_status) {
51 status_ = battery_status; 51 status_ = battery_status;
52 status_to_report_ = true; 52 status_to_report_ = true;
53 53
54 if (!callback_.is_null()) 54 if (!callback_.is_null())
55 ReportStatus(); 55 ReportStatus();
56 } 56 }
57 57
58 void BatteryMonitorImpl::ReportStatus() { 58 void BatteryMonitorImpl::ReportStatus() {
59 callback_.Run(status_.Clone()); 59 callback_.Run(status_.Clone());
60 callback_.Reset(); 60 callback_.Reset();
61 61
62 status_to_report_ = false; 62 status_to_report_ = false;
63 } 63 }
64 64
65 } // namespace device 65 } // namespace device
OLDNEW
« no previous file with comments | « device/battery/battery_monitor_impl.h ('k') | device/battery/battery_status.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698