| Index: content/browser/battery_status/battery_status_manager_mac.cc
|
| diff --git a/content/browser/battery_status/battery_status_manager_mac.cc b/content/browser/battery_status/battery_status_manager_mac.cc
|
| index 8d6f35b3166d608ab9a2f7c7dd21e3a072304a3b..5da151a4ab0873766fb176007e1ce12604c2be9f 100644
|
| --- a/content/browser/battery_status/battery_status_manager_mac.cc
|
| +++ b/content/browser/battery_status/battery_status_manager_mac.cc
|
| @@ -11,6 +11,7 @@
|
| #include "base/mac/foundation_util.h"
|
| #include "base/mac/scoped_cftyperef.h"
|
| #include "base/memory/ref_counted.h"
|
| +#include "base/metrics/histogram.h"
|
| #include "base/time/time.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "third_party/WebKit/public/platform/WebBatteryStatus.h"
|
| @@ -52,6 +53,11 @@ bool CFStringsAreEqual(CFStringRef string1, CFStringRef string2) {
|
| return CFStringCompare(string1, string2, 0) == kCFCompareEqualTo;
|
| }
|
|
|
| +void UpdateNumberBatteriesHistogram(int count) {
|
| + UMA_HISTOGRAM_CUSTOM_COUNTS(
|
| + "BatteryStatus.NumberBatteriesMac", count, 1, 5, 6);
|
| +}
|
| +
|
| void FetchBatteryStatus(CFDictionaryRef description,
|
| blink::WebBatteryStatus& status) {
|
| CFStringRef current_state =
|
| @@ -116,7 +122,7 @@ void OnBatteryStatusChanged(const BatteryCallback& callback) {
|
| IOPSCopyPowerSourcesList(info));
|
| CFIndex count = CFArrayGetCount(power_sources_list);
|
|
|
| - bool internal_source_found = false;
|
| + int num_internal_sources = 0;
|
|
|
| for (CFIndex i = 0; i < count; ++i) {
|
| CFDictionaryRef description = IOPSGetPowerSourceDescription(info,
|
| @@ -138,12 +144,13 @@ void OnBatteryStatusChanged(const BatteryCallback& callback) {
|
| // TODO(timvolodine): implement the case when there are multiple internal
|
| // sources, e.g. when multiple batteries are present. Currently this will
|
| // fail a DCHECK.
|
| - DCHECK(!internal_source_found);
|
| + DCHECK(num_internal_sources == 0);
|
| FetchBatteryStatus(description, status);
|
| - internal_source_found = true;
|
| + num_internal_sources++;
|
| }
|
| }
|
|
|
| + UpdateNumberBatteriesHistogram(num_internal_sources);
|
| callback.Run(status);
|
| }
|
|
|
|
|