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

Unified Diff: content/browser/battery_status/battery_status_manager_mac.cc

Issue 545503002: Battery Status API: add UMA logging for Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698