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

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

Issue 924193006: Set unregistered handles to NULL in BatteryStatusObserver::Stop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | 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 "device/battery/battery_status_manager_win.h" 5 #include "device/battery/battery_status_manager_win.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } else { 76 } else {
77 // Could not create a message window, execute callback with the default 77 // Could not create a message window, execute callback with the default
78 // values. 78 // values.
79 callback_.Run(BatteryStatus()); 79 callback_.Run(BatteryStatus());
80 } 80 }
81 81
82 UpdateNumberBatteriesHistogram(); 82 UpdateNumberBatteriesHistogram();
83 } 83 }
84 84
85 void Stop() { 85 void Stop() {
86 if (power_handle_) 86 if (power_handle_) {
87 UnregisterNotification(power_handle_); 87 UnregisterNotification(power_handle_);
88 if (battery_change_handle_) 88 power_handle_ = NULL;
89 }
90 if (battery_change_handle_) {
89 UnregisterNotification(battery_change_handle_); 91 UnregisterNotification(battery_change_handle_);
92 battery_change_handle_ = NULL;
93 }
90 window_.reset(); 94 window_.reset();
91 } 95 }
92 96
93 private: 97 private:
94 void BatteryChanged() { 98 void BatteryChanged() {
95 SYSTEM_POWER_STATUS win_status; 99 SYSTEM_POWER_STATUS win_status;
96 if (GetSystemPowerStatus(&win_status)) 100 if (GetSystemPowerStatus(&win_status))
97 callback_.Run(ComputeWebBatteryStatus(win_status)); 101 callback_.Run(ComputeWebBatteryStatus(win_status));
98 else 102 else
99 callback_.Run(BatteryStatus()); 103 callback_.Run(BatteryStatus());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 207 }
204 208
205 // static 209 // static
206 scoped_ptr<BatteryStatusManager> BatteryStatusManager::Create( 210 scoped_ptr<BatteryStatusManager> BatteryStatusManager::Create(
207 const BatteryStatusService::BatteryUpdateCallback& callback) { 211 const BatteryStatusService::BatteryUpdateCallback& callback) {
208 return scoped_ptr<BatteryStatusManager>( 212 return scoped_ptr<BatteryStatusManager>(
209 new BatteryStatusManagerWin(callback)); 213 new BatteryStatusManagerWin(callback));
210 } 214 }
211 215
212 } // namespace device 216 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698