| OLD | NEW |
| 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 #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_event
_router.h" | 5 #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_event
_router.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 const ErrorCallback& error_callback, | 1662 const ErrorCallback& error_callback, |
| 1663 BluetoothDevice::ConnectErrorCode error_code) { | 1663 BluetoothDevice::ConnectErrorCode error_code) { |
| 1664 VLOG(2) << "Failed to create GATT connection: " << error_code; | 1664 VLOG(2) << "Failed to create GATT connection: " << error_code; |
| 1665 | 1665 |
| 1666 const std::string connect_id = extension_id + device_address; | 1666 const std::string connect_id = extension_id + device_address; |
| 1667 DCHECK_NE(0U, connecting_devices_.count(connect_id)); | 1667 DCHECK_NE(0U, connecting_devices_.count(connect_id)); |
| 1668 | 1668 |
| 1669 connecting_devices_.erase(connect_id); | 1669 connecting_devices_.erase(connect_id); |
| 1670 Status error_status = kStatusErrorFailed; | 1670 Status error_status = kStatusErrorFailed; |
| 1671 switch (error_code) { | 1671 switch (error_code) { |
| 1672 case BluetoothDevice::ERROR_ATTRIBUTE_LENGTH_INVALID: | |
| 1673 error_status = kStatusErrorAttributeLengthInvalid; | |
| 1674 break; | |
| 1675 case BluetoothDevice::ERROR_AUTH_CANCELED: | 1672 case BluetoothDevice::ERROR_AUTH_CANCELED: |
| 1676 error_status = kStatusErrorCanceled; | 1673 error_status = kStatusErrorCanceled; |
| 1677 break; | 1674 break; |
| 1678 case BluetoothDevice::ERROR_AUTH_FAILED: | 1675 case BluetoothDevice::ERROR_AUTH_FAILED: |
| 1679 error_status = kStatusErrorAuthenticationFailed; | 1676 error_status = kStatusErrorAuthenticationFailed; |
| 1680 break; | 1677 break; |
| 1681 case BluetoothDevice::ERROR_AUTH_REJECTED: | 1678 case BluetoothDevice::ERROR_AUTH_REJECTED: |
| 1682 error_status = kStatusErrorAuthenticationFailed; | 1679 error_status = kStatusErrorAuthenticationFailed; |
| 1683 break; | 1680 break; |
| 1684 case BluetoothDevice::ERROR_AUTH_TIMEOUT: | 1681 case BluetoothDevice::ERROR_AUTH_TIMEOUT: |
| 1685 error_status = kStatusErrorTimeout; | 1682 error_status = kStatusErrorTimeout; |
| 1686 break; | 1683 break; |
| 1687 case BluetoothDevice::ERROR_CONNECTION_CONGESTED: | |
| 1688 error_status = kStatusErrorConnectionCongested; | |
| 1689 break; | |
| 1690 case BluetoothDevice::ERROR_FAILED: | 1684 case BluetoothDevice::ERROR_FAILED: |
| 1691 error_status = kStatusErrorFailed; | 1685 error_status = kStatusErrorFailed; |
| 1692 break; | 1686 break; |
| 1693 case BluetoothDevice::ERROR_INPROGRESS: | 1687 case BluetoothDevice::ERROR_INPROGRESS: |
| 1694 error_status = kStatusErrorInProgress; | 1688 error_status = kStatusErrorInProgress; |
| 1695 break; | 1689 break; |
| 1696 case BluetoothDevice::ERROR_INSUFFICIENT_ENCRYPTION: | |
| 1697 error_status = kStatusErrorInsufficientEncryption; | |
| 1698 break; | |
| 1699 case BluetoothDevice::ERROR_OFFSET_INVALID: | |
| 1700 error_status = kStatusErrorOffsetInvalid; | |
| 1701 break; | |
| 1702 case BluetoothDevice::ERROR_READ_NOT_PERMITTED: | |
| 1703 error_status = kStatusErrorPermissionDenied; | |
| 1704 break; | |
| 1705 case BluetoothDevice::ERROR_REQUEST_NOT_SUPPORTED: | |
| 1706 error_status = kStatusErrorRequestNotSupported; | |
| 1707 break; | |
| 1708 case BluetoothDevice::ERROR_UNKNOWN: | 1690 case BluetoothDevice::ERROR_UNKNOWN: |
| 1709 error_status = kStatusErrorFailed; | 1691 error_status = kStatusErrorFailed; |
| 1710 break; | 1692 break; |
| 1711 case BluetoothDevice::ERROR_UNSUPPORTED_DEVICE: | 1693 case BluetoothDevice::ERROR_UNSUPPORTED_DEVICE: |
| 1712 error_status = kStatusErrorUnsupportedDevice; | 1694 error_status = kStatusErrorUnsupportedDevice; |
| 1713 break; | 1695 break; |
| 1714 case BluetoothDevice::ERROR_WRITE_NOT_PERMITTED: | |
| 1715 error_status = kStatusErrorPermissionDenied; | |
| 1716 break; | |
| 1717 case BluetoothDevice::NUM_CONNECT_ERROR_CODES: | 1696 case BluetoothDevice::NUM_CONNECT_ERROR_CODES: |
| 1718 NOTREACHED(); | 1697 NOTREACHED(); |
| 1719 error_status = kStatusErrorInvalidArguments; | 1698 error_status = kStatusErrorInvalidArguments; |
| 1720 break; | 1699 break; |
| 1721 } | 1700 } |
| 1722 | 1701 |
| 1723 error_callback.Run(error_status); | 1702 error_callback.Run(error_status); |
| 1724 } | 1703 } |
| 1725 | 1704 |
| 1726 void BluetoothLowEnergyEventRouter::OnStartNotifySession( | 1705 void BluetoothLowEnergyEventRouter::OnStartNotifySession( |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1893 requests_[extension_id] = std::move(new_request_id_map); | 1872 requests_[extension_id] = std::move(new_request_id_map); |
| 1894 } else { | 1873 } else { |
| 1895 request_id_map = iter->second.get(); | 1874 request_id_map = iter->second.get(); |
| 1896 } | 1875 } |
| 1897 | 1876 |
| 1898 (*request_id_map)[++last_callback_request_id_] = std::move(request); | 1877 (*request_id_map)[++last_callback_request_id_] = std::move(request); |
| 1899 return last_callback_request_id_; | 1878 return last_callback_request_id_; |
| 1900 } | 1879 } |
| 1901 | 1880 |
| 1902 } // namespace extensions | 1881 } // namespace extensions |
| OLD | NEW |