Commit ab7555f4 authored by timvolodine's avatar timvolodine Committed by Commit bot

Battery Status API: add UMA logging for Linux.

Adds UMA logging to track how many batteries are reported
by the system at the start of Battery Status API.

BUG=

Review URL: https://codereview.chromium.org/480113003

Cr-Commit-Position: refs/heads/master@{#292398}
parent 141787d8
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "content/browser/battery_status/battery_status_manager_linux.h" #include "content/browser/battery_status/battery_status_manager_linux.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/metrics/histogram.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/values.h" #include "base/values.h"
#include "content/browser/battery_status/battery_status_manager.h" #include "content/browser/battery_status/battery_status_manager.h"
...@@ -96,6 +97,11 @@ scoped_ptr<PathsVector> GetPowerSourcesPaths(dbus::ObjectProxy* proxy) { ...@@ -96,6 +97,11 @@ scoped_ptr<PathsVector> GetPowerSourcesPaths(dbus::ObjectProxy* proxy) {
return paths.Pass();; return paths.Pass();;
} }
void UpdateNumberBatteriesHistogram(int count) {
UMA_HISTOGRAM_CUSTOM_COUNTS(
"BatteryStatus.NumberBatteriesLinux", count, 1, 5, 6);
}
// Class that represents a dedicated thread which communicates with DBus to // Class that represents a dedicated thread which communicates with DBus to
// obtain battery information and receives battery change notifications. // obtain battery information and receives battery change notifications.
class BatteryStatusNotificationThread : public base::Thread { class BatteryStatusNotificationThread : public base::Thread {
...@@ -131,6 +137,7 @@ class BatteryStatusNotificationThread : public base::Thread { ...@@ -131,6 +137,7 @@ class BatteryStatusNotificationThread : public base::Thread {
system_bus_->GetObjectProxy(kUPowerServiceName, system_bus_->GetObjectProxy(kUPowerServiceName,
dbus::ObjectPath(kUPowerPath)); dbus::ObjectPath(kUPowerPath));
scoped_ptr<PathsVector> device_paths = GetPowerSourcesPaths(power_proxy); scoped_ptr<PathsVector> device_paths = GetPowerSourcesPaths(power_proxy);
int num_batteries = 0;
for (size_t i = 0; i < device_paths->size(); ++i) { for (size_t i = 0; i < device_paths->size(); ++i) {
const dbus::ObjectPath& device_path = device_paths->at(i); const dbus::ObjectPath& device_path = device_paths->at(i);
...@@ -157,14 +164,16 @@ class BatteryStatusNotificationThread : public base::Thread { ...@@ -157,14 +164,16 @@ class BatteryStatusNotificationThread : public base::Thread {
// TODO(timvolodine): add support for multiple batteries. Currently we // TODO(timvolodine): add support for multiple batteries. Currently we
// only collect information from the first battery we encounter // only collect information from the first battery we encounter
// (crbug.com/400780). // (crbug.com/400780).
// TODO(timvolodine): add UMA logging for this case.
LOG(WARNING) << "multiple batteries found, " LOG(WARNING) << "multiple batteries found, "
<< "using status data of the first battery only."; << "using status data of the first battery only.";
} else { } else {
battery_proxy_ = device_proxy; battery_proxy_ = device_proxy;
} }
num_batteries++;
} }
UpdateNumberBatteriesHistogram(num_batteries);
if (!battery_proxy_) { if (!battery_proxy_) {
callback_.Run(blink::WebBatteryStatus()); callback_.Run(blink::WebBatteryStatus());
return; return;
......
...@@ -1927,6 +1927,15 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -1927,6 +1927,15 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary> </summary>
</histogram> </histogram>
<histogram name="BatteryStatus.NumberBatteriesLinux"
enum="BatteryStatusNumberBatteriesLinux">
<owner>timvolodine@chromium.org</owner>
<summary>
Number of batteries reported by the UPower service on Linux at the start of
the Battery Status API.
</summary>
</histogram>
<histogram name="BatteryStatus.StartAndroid" enum="BooleanSuccess"> <histogram name="BatteryStatus.StartAndroid" enum="BooleanSuccess">
<owner>timvolodine@chromium.org</owner> <owner>timvolodine@chromium.org</owner>
<summary> <summary>
...@@ -37848,6 +37857,10 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -37848,6 +37857,10 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="2" label="Bad"/> <int value="2" label="Bad"/>
</enum> </enum>
<enum name="BatteryStatusNumberBatteriesLinux" type="int">
<int value="5" label="5+"/>
</enum>
<enum name="BlacklistSetup" type="int"> <enum name="BlacklistSetup" type="int">
<int value="0" label="Blacklist enabled"/> <int value="0" label="Blacklist enabled"/>
<int value="1" label="Blacklist ran successfully."/> <int value="1" label="Blacklist ran successfully."/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment