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

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

Issue 2458163003: Add UMA for WebBluetooth RSSI signal strength level (Closed)
Patch Set: updated histogram_macros.h comments Created 4 years, 1 month 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..4bf4b2e761b64a268464d46d833d922ed80dc200 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,25 @@ void BluetoothDeviceChooserController::AdapterPoweredChanged(bool powered) {
int BluetoothDeviceChooserController::CalculateSignalStrengthLevel(
int8_t rssi) {
- if (rssi <= kMinRSSI)
+ RecordRSSISignalStrength(rssi);
+
+ 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]);
scheib 2016/10/31 22:22:32 DCHECK(kNumSignalStrengthLevels == arraysize(kRSSI
juncai 2016/10/31 23:29:50 Done.
+ return level;
}
void BluetoothDeviceChooserController::SetTestScanDurationForTesting() {

Powered by Google App Engine
This is Rietveld 408576698