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

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

Issue 2080083002: Revert of Deletes mojo::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/serial/data_sink_receiver.h » ('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"
(...skipping 12 matching lines...) Expand all
23 // NOTE: DidChange may be called before AddCallback returns. This is done to 23 // NOTE: DidChange may be called before AddCallback returns. This is done to
24 // report current status. 24 // report current status.
25 subscription_ = BatteryStatusService::GetInstance()->AddCallback( 25 subscription_ = BatteryStatusService::GetInstance()->AddCallback(
26 base::Bind(&BatteryMonitorImpl::DidChange, base::Unretained(this))); 26 base::Bind(&BatteryMonitorImpl::DidChange, base::Unretained(this)));
27 } 27 }
28 28
29 BatteryMonitorImpl::~BatteryMonitorImpl() { 29 BatteryMonitorImpl::~BatteryMonitorImpl() {
30 } 30 }
31 31
32 void BatteryMonitorImpl::QueryNextStatus( 32 void BatteryMonitorImpl::QueryNextStatus(
33 const QueryNextStatusCallback& callback) { 33 const BatteryStatusCallback& callback) {
34 if (!callback_.is_null()) { 34 if (!callback_.is_null()) {
35 DVLOG(1) << "Overlapped call to QueryNextStatus!"; 35 DVLOG(1) << "Overlapped call to QueryNextStatus!";
36 delete this; 36 delete this;
37 return; 37 return;
38 } 38 }
39 callback_ = callback; 39 callback_ = callback;
40 40
41 if (status_to_report_) 41 if (status_to_report_)
42 ReportStatus(); 42 ReportStatus();
43 } 43 }
(...skipping 10 matching lines...) Expand all
54 } 54 }
55 55
56 void BatteryMonitorImpl::ReportStatus() { 56 void BatteryMonitorImpl::ReportStatus() {
57 callback_.Run(status_.Clone()); 57 callback_.Run(status_.Clone());
58 callback_.Reset(); 58 callback_.Reset();
59 59
60 status_to_report_ = false; 60 status_to_report_ = false;
61 } 61 }
62 62
63 } // namespace device 63 } // namespace device
OLDNEW
« no previous file with comments | « device/battery/battery_monitor_impl.h ('k') | device/serial/data_sink_receiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698