| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/containers/scoped_ptr_hash_map.h" | 17 #include "base/containers/scoped_ptr_hash_map.h" |
| 18 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
| 19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 20 #include "base/optional.h" |
| 20 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
| 21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 22 #include "device/bluetooth/bluetooth_common.h" | 23 #include "device/bluetooth/bluetooth_common.h" |
| 23 #include "device/bluetooth/bluetooth_export.h" | 24 #include "device/bluetooth/bluetooth_export.h" |
| 24 #include "device/bluetooth/bluetooth_uuid.h" | 25 #include "device/bluetooth/bluetooth_uuid.h" |
| 25 #include "net/log/net_log.h" | 26 #include "net/log/net_log.h" |
| 26 | 27 |
| 27 namespace base { | 28 namespace base { |
| 28 class BinaryValue; | 29 class BinaryValue; |
| 29 } | 30 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 // Returns the Product ID of the device, where available. | 231 // Returns the Product ID of the device, where available. |
| 231 virtual uint16_t GetProductID() const = 0; | 232 virtual uint16_t GetProductID() const = 0; |
| 232 | 233 |
| 233 // Returns the Device ID of the device, typically the release or version | 234 // Returns the Device ID of the device, typically the release or version |
| 234 // number in BCD format, where available. | 235 // number in BCD format, where available. |
| 235 virtual uint16_t GetDeviceID() const = 0; | 236 virtual uint16_t GetDeviceID() const = 0; |
| 236 | 237 |
| 237 // Returns the appearance of the device. | 238 // Returns the appearance of the device. |
| 238 virtual uint16_t GetAppearance() const = 0; | 239 virtual uint16_t GetAppearance() const = 0; |
| 239 | 240 |
| 241 // Returns the name of the device, which may be empty. |
| 242 virtual base::Optional<std::string> GetName() const = 0; |
| 243 |
| 240 // Returns the name of the device suitable for displaying, this may | 244 // Returns the name of the device suitable for displaying, this may |
| 241 // be a synthesized string containing the address and localized type name | 245 // be a synthesized string containing the address and localized type name |
| 242 // if the device has no obtained name. | 246 // if the device has no obtained name. |
| 243 virtual base::string16 GetNameForDisplay() const; | 247 virtual base::string16 GetNameForDisplay() const; |
| 244 | 248 |
| 245 // Returns the type of the device, limited to those we support or are | 249 // Returns the type of the device, limited to those we support or are |
| 246 // aware of, by decoding the bluetooth class information. The returned | 250 // aware of, by decoding the bluetooth class information. The returned |
| 247 // values are unique, and do not overlap, so DEVICE_KEYBOARD is not also | 251 // values are unique, and do not overlap, so DEVICE_KEYBOARD is not also |
| 248 // DEVICE_PERIPHERAL. | 252 // DEVICE_PERIPHERAL. |
| 249 // | 253 // |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 FRIEND_TEST_ALL_PREFIXES( | 495 FRIEND_TEST_ALL_PREFIXES( |
| 492 BluetoothTest, | 496 BluetoothTest, |
| 493 BluetoothGattConnection_DisconnectGatt_SimulateConnect); | 497 BluetoothGattConnection_DisconnectGatt_SimulateConnect); |
| 494 FRIEND_TEST_ALL_PREFIXES( | 498 FRIEND_TEST_ALL_PREFIXES( |
| 495 BluetoothTest, | 499 BluetoothTest, |
| 496 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect); | 500 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect); |
| 497 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, | 501 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, |
| 498 BluetoothGattConnection_ErrorAfterConnection); | 502 BluetoothGattConnection_ErrorAfterConnection); |
| 499 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, | 503 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, |
| 500 BluetoothGattConnection_DisconnectGatt_Cleanup); | 504 BluetoothGattConnection_DisconnectGatt_Cleanup); |
| 501 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, GetDeviceName_NullName); | 505 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, GetName_NullName); |
| 502 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, RemoveOutdatedDevices); | 506 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, RemoveOutdatedDevices); |
| 503 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, RemoveOutdatedDeviceGattConnect); | 507 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, RemoveOutdatedDeviceGattConnect); |
| 504 | 508 |
| 505 BluetoothDevice(BluetoothAdapter* adapter); | 509 BluetoothDevice(BluetoothAdapter* adapter); |
| 506 | 510 |
| 507 // Returns the internal name of the Bluetooth device, used by | |
| 508 // GetNameForDisplay(). | |
| 509 virtual std::string GetDeviceName() const = 0; | |
| 510 | |
| 511 // Implements platform specific operations to initiate a GATT connection. | 511 // Implements platform specific operations to initiate a GATT connection. |
| 512 // Subclasses must also call DidConnectGatt, DidFailToConnectGatt, or | 512 // Subclasses must also call DidConnectGatt, DidFailToConnectGatt, or |
| 513 // DidDisconnectGatt immediately or asynchronously as the connection state | 513 // DidDisconnectGatt immediately or asynchronously as the connection state |
| 514 // changes. | 514 // changes. |
| 515 virtual void CreateGattConnectionImpl() = 0; | 515 virtual void CreateGattConnectionImpl() = 0; |
| 516 | 516 |
| 517 // Disconnects GATT connection on platforms that maintain a specific GATT | 517 // Disconnects GATT connection on platforms that maintain a specific GATT |
| 518 // connection. | 518 // connection. |
| 519 virtual void DisconnectGatt() = 0; | 519 virtual void DisconnectGatt() = 0; |
| 520 | 520 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 | 575 |
| 576 private: | 576 private: |
| 577 // Returns a localized string containing the device's bluetooth address and | 577 // Returns a localized string containing the device's bluetooth address and |
| 578 // a device type for display when |name_| is empty. | 578 // a device type for display when |name_| is empty. |
| 579 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 579 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
| 580 }; | 580 }; |
| 581 | 581 |
| 582 } // namespace device | 582 } // namespace device |
| 583 | 583 |
| 584 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 584 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |