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

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

Issue 1264323002: bluetooth: Return specific message if Bluetooth Adapter is off (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-web-bluetooth-action
Patch Set: Created 5 years, 4 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
« no previous file with comments | « no previous file | content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/bluetooth/bluetooth_dispatcher_host.cc
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.cc b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
index e203b43fb2b1c44b52770ee4da48e9fff90eb18e..a31c731077c8b9cffd79d673c3fab062fa2c0f15 100644
--- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc
+++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
@@ -49,6 +49,8 @@ enum class UMARequestDeviceOutcome {
DISCOVERY_START_FAILED = 3,
DISCOVERY_STOP_FAILED = 4,
NO_MATCHING_DEVICES_FOUND = 5,
+ BLUETOOTH_ADAPTER_NOT_PRESENT = 6,
+ BLUETOOTH_ADAPTER_OFF = 7,
// NOTE: Add new requestDevice() outcomes immediately above this line. Make
// sure to update the enum list in
// tools/metrics/histogram/histograms.xml accordingly.
@@ -296,6 +298,22 @@ void BluetoothDispatcherHost::OnRequestDevice(
bad_message::ReceivedBadMessage(
this, bad_message::BDH_DUPLICATE_REQUEST_DEVICE_ID);
}
+ if (!adapter_->IsPresent()) {
+ VLOG(1) << "Bluetooth Adapter not present. Can't serve requestDevice.";
+ RecordRequestDeviceOutcome(
+ UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_NOT_PRESENT);
+ Send(new BluetoothMsg_RequestDeviceError(
Jeffrey Yasskin 2015/08/05 17:13:14 Every Send needs to be matched to a request_device
ortuno 2015/08/05 18:01:53 Done.
+ thread_id, request_id, WebBluetoothError::NoBluetoothAdapter));
+ return;
+ }
+ if (!adapter_->IsPowered()) {
Jeffrey Yasskin 2015/08/05 17:13:13 This one isn't going to happen once we have the re
ortuno 2015/08/05 18:01:53 True. But the dialog is gonna take a couple of rel
+ VLOG(1) << "Bluetooth Adapter is not powered. Can't serve requestDevice.";
+ RecordRequestDeviceOutcome(
+ UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_OFF);
+ Send(new BluetoothMsg_RequestDeviceError(
+ thread_id, request_id, WebBluetoothError::BluetoothAdapterOff));
+ return;
+ }
adapter_->StartDiscoverySessionWithFilter(
ComputeScanFilter(filters),
base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStarted,
« no previous file with comments | « no previous file | content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698