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

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

Issue 2762023002: work in progress 2
Patch Set: Created 3 years, 9 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 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

Powered by Google App Engine
This is Rietveld 408576698