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

Side by Side 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: Add issue to TODO 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // NETWORK_ERROR Note: 5 // NETWORK_ERROR Note:
6 // When a device can't be found in the BluetoothAdapter, that generally 6 // When a device can't be found in the BluetoothAdapter, that generally
7 // indicates that it's gone out of range. We reject with a NetworkError in that 7 // indicates that it's gone out of range. We reject with a NetworkError in that
8 // case. 8 // case.
9 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothdevice-conne ctgatt 9 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothdevice-conne ctgatt
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 MAX_ERROR, 42 MAX_ERROR,
43 }; 43 };
44 44
45 enum class UMARequestDeviceOutcome { 45 enum class UMARequestDeviceOutcome {
46 SUCCESS = 0, 46 SUCCESS = 0,
47 NO_BLUETOOTH_ADAPTER = 1, 47 NO_BLUETOOTH_ADAPTER = 1,
48 NO_RENDER_FRAME = 2, 48 NO_RENDER_FRAME = 2,
49 DISCOVERY_START_FAILED = 3, 49 DISCOVERY_START_FAILED = 3,
50 DISCOVERY_STOP_FAILED = 4, 50 DISCOVERY_STOP_FAILED = 4,
51 NO_MATCHING_DEVICES_FOUND = 5, 51 NO_MATCHING_DEVICES_FOUND = 5,
52 BLUETOOTH_ADAPTER_NOT_PRESENT = 6,
53 BLUETOOTH_ADAPTER_OFF = 7,
52 // NOTE: Add new requestDevice() outcomes immediately above this line. Make 54 // NOTE: Add new requestDevice() outcomes immediately above this line. Make
53 // sure to update the enum list in 55 // sure to update the enum list in
54 // tools/metrics/histogram/histograms.xml accordingly. 56 // tools/metrics/histogram/histograms.xml accordingly.
55 COUNT 57 COUNT
56 }; 58 };
57 59
58 void RecordRequestDeviceOutcome(UMARequestDeviceOutcome outcome) { 60 void RecordRequestDeviceOutcome(UMARequestDeviceOutcome outcome) {
59 UMA_HISTOGRAM_ENUMERATION("Bluetooth.RequestDevice.Outcome", 61 UMA_HISTOGRAM_ENUMERATION("Bluetooth.RequestDevice.Outcome",
60 static_cast<int>(outcome), 62 static_cast<int>(outcome),
61 static_cast<int>(UMARequestDeviceOutcome::COUNT)); 63 static_cast<int>(UMARequestDeviceOutcome::COUNT));
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 .insert(std::make_pair( 291 .insert(std::make_pair(
290 std::make_pair(thread_id, request_id), 292 std::make_pair(thread_id, request_id),
291 RequestDeviceSession(filters, optional_services))) 293 RequestDeviceSession(filters, optional_services)))
292 .second) { 294 .second) {
293 LOG(ERROR) << "2 requestDevice() calls with the same thread_id (" 295 LOG(ERROR) << "2 requestDevice() calls with the same thread_id ("
294 << thread_id << ") and request_id (" << request_id 296 << thread_id << ") and request_id (" << request_id
295 << ") shouldn't arrive at the same BluetoothDispatcherHost."; 297 << ") shouldn't arrive at the same BluetoothDispatcherHost.";
296 bad_message::ReceivedBadMessage( 298 bad_message::ReceivedBadMessage(
297 this, bad_message::BDH_DUPLICATE_REQUEST_DEVICE_ID); 299 this, bad_message::BDH_DUPLICATE_REQUEST_DEVICE_ID);
298 } 300 }
301 if (!adapter_->IsPresent()) {
302 VLOG(1) << "Bluetooth Adapter not present. Can't serve requestDevice.";
303 RecordRequestDeviceOutcome(
304 UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_NOT_PRESENT);
305 Send(new BluetoothMsg_RequestDeviceError(
306 thread_id, request_id, WebBluetoothError::NoBluetoothAdapter));
307 request_device_sessions_.erase(std::make_pair(thread_id, request_id));
308 return;
309 }
310 // TODO(jyasskin): Once the dialog is available, the dialog should check for
311 // the status of the adapter, i.e. check IsPowered() and
312 // BluetoothAdapter::Observer::PoweredChanged, and inform the user. But
313 // until the dialog is available we log/histogram the status and return
314 // with a message.
315 // https://crbug.com/517237
316 if (!adapter_->IsPowered()) {
317 VLOG(1) << "Bluetooth Adapter is not powered. Can't serve requestDevice.";
318 RecordRequestDeviceOutcome(
319 UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_OFF);
320 Send(new BluetoothMsg_RequestDeviceError(
321 thread_id, request_id, WebBluetoothError::BluetoothAdapterOff));
322 request_device_sessions_.erase(std::make_pair(thread_id, request_id));
323 return;
324 }
299 adapter_->StartDiscoverySessionWithFilter( 325 adapter_->StartDiscoverySessionWithFilter(
300 ComputeScanFilter(filters), 326 ComputeScanFilter(filters),
301 base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStarted, 327 base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStarted,
302 weak_ptr_factory_.GetWeakPtr(), thread_id, request_id), 328 weak_ptr_factory_.GetWeakPtr(), thread_id, request_id),
303 base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStartedError, 329 base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStartedError,
304 weak_ptr_factory_.GetWeakPtr(), thread_id, request_id)); 330 weak_ptr_factory_.GetWeakPtr(), thread_id, request_id));
305 } else { 331 } else {
306 DLOG(WARNING) << "No BluetoothAdapter. Can't serve requestDevice."; 332 DLOG(WARNING) << "No BluetoothAdapter. Can't serve requestDevice.";
307 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_BLUETOOTH_ADAPTER); 333 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_BLUETOOTH_ADAPTER);
308 Send(new BluetoothMsg_RequestDeviceError( 334 Send(new BluetoothMsg_RequestDeviceError(
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 729
704 void BluetoothDispatcherHost::OnWriteValueFailed( 730 void BluetoothDispatcherHost::OnWriteValueFailed(
705 int thread_id, 731 int thread_id,
706 int request_id, 732 int request_id,
707 device::BluetoothGattService::GattErrorCode error_code) { 733 device::BluetoothGattService::GattErrorCode error_code) {
708 Send(new BluetoothMsg_WriteCharacteristicValueError( 734 Send(new BluetoothMsg_WriteCharacteristicValueError(
709 thread_id, request_id, TranslateGATTError(error_code))); 735 thread_id, request_id, TranslateGATTError(error_code)));
710 } 736 }
711 737
712 } // namespace content 738 } // namespace content
OLDNEW
« 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