OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_BLUETOOTH_CACHE_QUERY_RESULT_H_ |
| 6 #define CONTENT_BROWSER_BLUETOOTH_CACHE_QUERY_RESULT_H_ |
| 7 |
| 8 #include "content/browser/bluetooth/bluetooth_metrics.h" |
| 9 #include "content/common/bluetooth/bluetooth_messages.h" |
| 10 |
| 11 namespace device { |
| 12 class BluetoothDevice; |
| 13 class BluetoothGattService; |
| 14 class BluetoothGattCharacteristic; |
| 15 } |
| 16 |
| 17 namespace content { |
| 18 |
| 19 // Struct that holds the result of a cache query. |
| 20 // |
| 21 // WebBluetoothServiceImpl and BluetoothDispatcherHost have functions |
| 22 // that return a CacheQueryResult so we make a separate header for it. |
| 23 // TODO(ortuno): Move into WebBluetoothServiceImpl once we move all functions |
| 24 // off BluetoothDispatcherHost. |
| 25 // https://crbug.com/508771 |
| 26 struct CacheQueryResult { |
| 27 CacheQueryResult() : outcome(CacheQueryOutcome::SUCCESS) {} |
| 28 |
| 29 explicit CacheQueryResult(CacheQueryOutcome outcome) : outcome(outcome) {} |
| 30 |
| 31 ~CacheQueryResult() {} |
| 32 |
| 33 blink::WebBluetoothError GetWebError() const { |
| 34 switch (outcome) { |
| 35 case CacheQueryOutcome::SUCCESS: |
| 36 case CacheQueryOutcome::BAD_RENDERER: |
| 37 NOTREACHED(); |
| 38 return blink::WebBluetoothError::DEVICE_NO_LONGER_IN_RANGE; |
| 39 case CacheQueryOutcome::NO_DEVICE: |
| 40 return blink::WebBluetoothError::DEVICE_NO_LONGER_IN_RANGE; |
| 41 case CacheQueryOutcome::NO_SERVICE: |
| 42 return blink::WebBluetoothError::SERVICE_NO_LONGER_EXISTS; |
| 43 case CacheQueryOutcome::NO_CHARACTERISTIC: |
| 44 return blink::WebBluetoothError::CHARACTERISTIC_NO_LONGER_EXISTS; |
| 45 } |
| 46 NOTREACHED(); |
| 47 return blink::WebBluetoothError::DEVICE_NO_LONGER_IN_RANGE; |
| 48 } |
| 49 |
| 50 device::BluetoothDevice* device = nullptr; |
| 51 device::BluetoothGattService* service = nullptr; |
| 52 device::BluetoothGattCharacteristic* characteristic = nullptr; |
| 53 CacheQueryOutcome outcome; |
| 54 }; |
| 55 |
| 56 } // namespace content |
| 57 |
| 58 #endif // CONTENT_BROWSER_BLUETOOTH_CACHE_QUERY_RESULT_H_ |
OLD | NEW |