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

Unified Diff: content/browser/bluetooth/bluetooth_device_chooser_controller.cc

Issue 2458163003: Add UMA for WebBluetooth RSSI signal strength level (Closed)
Patch Set: add UMA for WebBluetooth RSSI signal strength level 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
Index: content/browser/bluetooth/bluetooth_device_chooser_controller.cc
diff --git a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
index 95315cdf512aedaaef0d8f4415258688de7d0eda..58283d520f547924301ec46342b53acd0ded7872 100644
--- a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
+++ b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
@@ -35,6 +35,13 @@ const int kMaxRSSI = -55;
// Number of RSSI levels used in the signal strength image.
const int kNumSignalStrengthLevels = 5;
+const content::UMARSSISignalStrengthLevel kRSSISignalStrengthEnumTable[] = {
+ content::UMARSSISignalStrengthLevel::LEVEL_0,
+ content::UMARSSISignalStrengthLevel::LEVEL_1,
+ content::UMARSSISignalStrengthLevel::LEVEL_2,
+ content::UMARSSISignalStrengthLevel::LEVEL_3,
+ content::UMARSSISignalStrengthLevel::LEVEL_4};
+
} // namespace
namespace content {
@@ -384,15 +391,23 @@ void BluetoothDeviceChooserController::AdapterPoweredChanged(bool powered) {
int BluetoothDeviceChooserController::CalculateSignalStrengthLevel(
int8_t rssi) {
- if (rssi <= kMinRSSI)
+ if (rssi <= kMinRSSI) {
+ RecordRSSISignalStrengthLevel(
+ UMARSSISignalStrengthLevel::LESS_THAN_OR_EQUAL_TO_MIN_RSSI);
return 0;
+ }
- if (rssi >= kMaxRSSI)
+ if (rssi >= kMaxRSSI) {
+ RecordRSSISignalStrengthLevel(
+ UMARSSISignalStrengthLevel::GREATER_THAN_OR_EQUAL_TO_MAX_RSSI);
return kNumSignalStrengthLevels - 1;
+ }
double input_range = kMaxRSSI - kMinRSSI;
double output_range = kNumSignalStrengthLevels - 1;
- return static_cast<int>((rssi - kMinRSSI) * output_range / input_range);
+ int level = static_cast<int>((rssi - kMinRSSI) * output_range / input_range);
+ RecordRSSISignalStrengthLevel(kRSSISignalStrengthEnumTable[level]);
+ return level;
}
void BluetoothDeviceChooserController::SetTestScanDurationForTesting() {
« no previous file with comments | « no previous file | content/browser/bluetooth/bluetooth_metrics.h » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698