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 ac2ac7b2a632e29494d3f8fbb47e39cb5f3335af..efe431ee13109728c7dc930fa346a7bceee91e29 100644 |
--- a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc |
+++ b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc |
@@ -27,6 +27,8 @@ |
#include "device/bluetooth/bluetooth_common.h" |
#include "device/bluetooth/bluetooth_discovery_session.h" |
+#include "base/logging.h" |
+ |
using device::BluetoothUUID; |
using UUIDSet = device::BluetoothDevice::UUIDSet; |
@@ -289,6 +291,7 @@ BluetoothDeviceChooserController::BluetoothDeviceChooserController( |
base::Unretained(this)), |
/*is_repeating=*/false), |
weak_ptr_factory_(this) { |
+ LOG(ERROR) << "[DJKim] BluetoothDeviceChooserController::BluetoothDeviceChooserController"; |
CHECK(adapter_); |
} |
@@ -308,6 +311,7 @@ void BluetoothDeviceChooserController::GetDevice( |
blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, |
const SuccessCallback& success_callback, |
const ErrorCallback& error_callback) { |
+ LOG(ERROR) << "[DJKim] BluetoothDeviceChooserController::GetDevice"; |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
// GetDevice should only be called once. |
@@ -466,6 +470,13 @@ void BluetoothDeviceChooserController::AdapterPoweredChanged(bool powered) { |
} |
} |
+void BluetoothDeviceChooserController::AdapterDiscoveringChanged( |
+ bool discovering) { |
+ LOG(ERROR) << "[DJKim] BluetoothDeviceChooserController::AdapterDiscoveringChanged"; |
+ if (!discovering && IsDiscoverySessionActive()) |
+ StopDeviceDiscovery(); |
+} |
+ |
int BluetoothDeviceChooserController::CalculateSignalStrengthLevel( |
int8_t rssi) { |
RecordRSSISignalStrength(rssi); |
@@ -501,17 +512,33 @@ void BluetoothDeviceChooserController::PopulateConnectedDevices() { |
} |
void BluetoothDeviceChooserController::StartDeviceDiscovery() { |
+ LOG(ERROR) << "[DJKim] BluetoothDeviceChooserController::StartDeviceDiscovery >> start"; |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
- if (discovery_session_.get() && discovery_session_->IsActive()) { |
+ LOG(ERROR) << "[DJKim] BluetoothDeviceChooserController::StartDeviceDiscovery >> #1"; |
+ if (IsDiscoverySessionActive()) { |
// Already running; just increase the timeout. |
discovery_session_timer_.Reset(); |
return; |
} |
+ LOG(ERROR) << "[DJKim] BluetoothDeviceChooserController::StartDeviceDiscovery >> #2"; |
scanning_start_time_ = base::TimeTicks::Now(); |
- chooser_->ShowDiscoveryState(BluetoothChooser::DiscoveryState::DISCOVERING); |
+ LOG(ERROR) << "[DJKim] BluetoothDeviceChooserController::StartDeviceDiscovery >> #2-1"; |
+ if (chooser_) |
+ chooser_->ShowDiscoveryState(BluetoothChooser::DiscoveryState::DISCOVERING); |
+ else |
+ LOG(ERROR) << "[DJKim] BluetoothDeviceChooserController::StartDeviceDiscovery >> #2-2"; |
+ |
+ LOG(ERROR) << "[DJKim] BluetoothDeviceChooserController::StartDeviceDiscovery >> #3"; |
+ |
+ if (adapter_) { |
+ if (!options_) { |
+ LOG(ERROR) << "[DJKim] BluetoothDeviceChooserController::StartDeviceDiscovery >> #3-1 return"; |
+ return; |
+ } |
+ |
adapter_->StartDiscoverySessionWithFilter( |
ComputeScanFilter(options_->filters), |
base::Bind( |
@@ -520,6 +547,9 @@ void BluetoothDeviceChooserController::StartDeviceDiscovery() { |
base::Bind( |
&BluetoothDeviceChooserController::OnStartDiscoverySessionFailed, |
weak_ptr_factory_.GetWeakPtr())); |
+ } |
+ |
+ LOG(ERROR) << "[DJKim] BluetoothDeviceChooserController::StartDeviceDiscovery >> end"; |
} |
void BluetoothDeviceChooserController::StopDeviceDiscovery() { |
@@ -625,4 +655,16 @@ void BluetoothDeviceChooserController::PostErrorCallback( |
} |
} |
+bool BluetoothDeviceChooserController::IsDiscoverySessionActive() { |
+ if (discovery_session_ && discovery_session_->IsActive()) |
+ return true; |
+ |
+ return false; |
+} |
+ |
+void BluetoothDeviceChooserController::StartDeviceDiscoveryForTesting() { |
+ LOG(ERROR) << "[DJKim] BluetoothDeviceChooserController::StartDeviceDiscoveryForTesting"; |
+ StartDeviceDiscovery(); |
+} |
+ |
} // namespace content |