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

Unified Diff: device/battery/battery_monitor_impl.cc

Issue 2398833003: Fix double-delete in BatteryMonitor. (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/battery/battery_monitor_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/battery/battery_monitor_impl.cc
diff --git a/device/battery/battery_monitor_impl.cc b/device/battery/battery_monitor_impl.cc
index e27f043bf5a0afbc9640aeadd77d22ebd63d4081..76511153514e47e5e42960e84a91d5c3ca4363e4 100644
--- a/device/battery/battery_monitor_impl.cc
+++ b/device/battery/battery_monitor_impl.cc
@@ -8,14 +8,17 @@
#include "base/bind.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
namespace device {
// static
void BatteryMonitorImpl::Create(BatteryMonitorRequest request) {
- mojo::MakeStrongBinding(base::MakeUnique<BatteryMonitorImpl>(),
- std::move(request));
+ auto* impl = new BatteryMonitorImpl;
+ auto binding =
+ mojo::MakeStrongBinding(base::WrapUnique(impl), std::move(request));
+ impl->binding_ = binding;
}
BatteryMonitorImpl::BatteryMonitorImpl() : status_to_report_(false) {
@@ -32,7 +35,7 @@ void BatteryMonitorImpl::QueryNextStatus(
const QueryNextStatusCallback& callback) {
if (!callback_.is_null()) {
DVLOG(1) << "Overlapped call to QueryNextStatus!";
- delete this;
+ binding_->Close();
return;
}
callback_ = callback;
« no previous file with comments | « device/battery/battery_monitor_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698