Chromium Code Reviews| 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 082d1e8b42f0aad21f6cd7546f85663df1f7df26..83f18f896104cd256bce1ef86629d5f7958dcb85 100644 |
| --- a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc |
| +++ b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| +#include "base/metrics/histogram_macros.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "content/browser/bluetooth/bluetooth_blacklist.h" |
| @@ -54,7 +55,7 @@ constexpr size_t kMaxLengthForDeviceName = |
| 29; // max length of device name in filter. |
| // The duration of a Bluetooth Scan in seconds. |
| -constexpr int kScanDuration = 10; |
| +constexpr int kScanDuration = 60; |
| constexpr int kTestScanDuration = 0; |
| void LogRequestDeviceOptions( |
| @@ -197,15 +198,17 @@ UMARequestDeviceOutcome OutcomeFromChooserEvent(BluetoothChooser::Event event) { |
| NOTREACHED(); |
| return UMARequestDeviceOutcome::SUCCESS; |
| case BluetoothChooser::Event::RESCAN: |
| - // Rescanning doesn't result in a IPC message for the request being sent |
| - // so no need to histogram it. |
| - NOTREACHED(); |
| - return UMARequestDeviceOutcome::SUCCESS; |
| + return UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_RESCAN; |
| } |
| NOTREACHED(); |
| return UMARequestDeviceOutcome::SUCCESS; |
| } |
| +void RecordScanningDuration(const base::TimeDelta& duration) { |
| + UMA_HISTOGRAM_LONG_TIMES("Bluetooth.Web.RequestDevice.ScanningDuration", |
| + duration); |
| +} |
| + |
| } // namespace |
| BluetoothDeviceChooserController::BluetoothDeviceChooserController( |
| @@ -232,6 +235,12 @@ BluetoothDeviceChooserController::BluetoothDeviceChooserController( |
| } |
| BluetoothDeviceChooserController::~BluetoothDeviceChooserController() { |
| + if (scanning_start_time_) { |
| + RecordScanningDuration(base::TimeTicks::Now() - |
| + scanning_start_time_.value()); |
| + scanning_start_time_.reset(); |
|
scheib
2016/11/17 22:23:06
Why do we need to clear the optional<timer> when d
juncai
2016/11/17 22:44:41
Done.
|
| + } |
| + |
| if (chooser_) { |
| DCHECK(!error_callback_.is_null()); |
| error_callback_.Run(blink::mojom::WebBluetoothResult::CHOOSER_CANCELLED); |
| @@ -439,6 +448,8 @@ void BluetoothDeviceChooserController::StartDeviceDiscovery() { |
| return; |
| } |
| + scanning_start_time_ = base::TimeTicks::Now(); |
| + |
| chooser_->ShowDiscoveryState(BluetoothChooser::DiscoveryState::DISCOVERING); |
| adapter_->StartDiscoverySessionWithFilter( |
| ComputeScanFilter(options_->filters), |
| @@ -486,6 +497,7 @@ void BluetoothDeviceChooserController::OnBluetoothChooserEvent( |
| switch (event) { |
| case BluetoothChooser::Event::RESCAN: |
| + RecordRequestDeviceOutcome(OutcomeFromChooserEvent(event)); |
| PopulateConnectedDevices(); |
| DCHECK(chooser_); |
| StartDeviceDiscovery(); |