| 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 #ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ | 5 #ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ |
| 6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ | 6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 void RemoveObserver(Observer* observer) override; | 48 void RemoveObserver(Observer* observer) override; |
| 49 std::vector<dbus::ObjectPath> GetServices() override; | 49 std::vector<dbus::ObjectPath> GetServices() override; |
| 50 Properties* GetProperties(const dbus::ObjectPath& object_path) override; | 50 Properties* GetProperties(const dbus::ObjectPath& object_path) override; |
| 51 | 51 |
| 52 // Makes a service visible for device with object path |device_path|. Note | 52 // Makes a service visible for device with object path |device_path|. Note |
| 53 // that only one instance of a specific service is simulated at a time. Hence, | 53 // that only one instance of a specific service is simulated at a time. Hence, |
| 54 // this method will fail, if the service is already visible. | 54 // this method will fail, if the service is already visible. |
| 55 void ExposeHeartRateService(const dbus::ObjectPath& device_path); | 55 void ExposeHeartRateService(const dbus::ObjectPath& device_path); |
| 56 void HideHeartRateService(); | 56 void HideHeartRateService(); |
| 57 | 57 |
| 58 // Makes a service visible for device with object path |device_path| without |
| 59 // delay. Note that only one instance of a specific service is simulated at a |
| 60 // time, if the service is already visible. |
| 61 void ExposeHeartRateServiceWithoutDelay(const dbus::ObjectPath& device_path); |
| 62 |
| 58 // Returns whether or not the Heart Rate Service is visible. | 63 // Returns whether or not the Heart Rate Service is visible. |
| 59 bool IsHeartRateVisible() const; | 64 bool IsHeartRateVisible() const; |
| 60 | 65 |
| 61 // Returns the current object path of the visible Heart Rate service. If the | 66 // Returns the current object path of the visible Heart Rate service. If the |
| 62 // service is not visible, returns an invalid empty path. | 67 // service is not visible, returns an invalid empty path. |
| 63 dbus::ObjectPath GetHeartRateServicePath() const; | 68 dbus::ObjectPath GetHeartRateServicePath() const; |
| 64 | 69 |
| 65 // Final object path components and the corresponding UUIDs of the GATT | 70 // Final object path components and the corresponding UUIDs of the GATT |
| 66 // services that we emulate. Service paths are hierarchical to Bluetooth | 71 // services that we emulate. Service paths are hierarchical to Bluetooth |
| 67 // device paths, so if the path component is "service0000", and the device | 72 // device paths, so if the path component is "service0000", and the device |
| (...skipping 10 matching lines...) Expand all Loading... |
| 78 // Notifies observers. | 83 // Notifies observers. |
| 79 void NotifyServiceAdded(const dbus::ObjectPath& object_path); | 84 void NotifyServiceAdded(const dbus::ObjectPath& object_path); |
| 80 void NotifyServiceRemoved(const dbus::ObjectPath& object_path); | 85 void NotifyServiceRemoved(const dbus::ObjectPath& object_path); |
| 81 | 86 |
| 82 // Tells FakeBluetoothGattCharacteristicClient to expose GATT characteristics. | 87 // Tells FakeBluetoothGattCharacteristicClient to expose GATT characteristics. |
| 83 // This is scheduled from ExposeHeartRateService to simulate asynchronous | 88 // This is scheduled from ExposeHeartRateService to simulate asynchronous |
| 84 // retrieval of characteristics. If the Heart Rate Service is hidden at the | 89 // retrieval of characteristics. If the Heart Rate Service is hidden at the |
| 85 // time this method is called, then it does nothing. | 90 // time this method is called, then it does nothing. |
| 86 void ExposeHeartRateCharacteristics(); | 91 void ExposeHeartRateCharacteristics(); |
| 87 | 92 |
| 93 // Toggles the ServicesResolved property for the device with |object_path|. |
| 94 // This should be done after a service is fully discovered. |
| 95 void ToggleServicesResolvedProperty(const dbus::ObjectPath& object_path, |
| 96 bool resolved); |
| 97 |
| 88 // Static properties we return. As long as a service is exposed, this will be | 98 // Static properties we return. As long as a service is exposed, this will be |
| 89 // non-null. Otherwise it will be null. | 99 // non-null. Otherwise it will be null. |
| 90 std::unique_ptr<Properties> heart_rate_service_properties_; | 100 std::unique_ptr<Properties> heart_rate_service_properties_; |
| 91 std::string heart_rate_service_path_; | 101 std::string heart_rate_service_path_; |
| 92 | 102 |
| 93 // List of observers interested in event notifications from us. | 103 // List of observers interested in event notifications from us. |
| 94 base::ObserverList<Observer> observers_; | 104 base::ObserverList<Observer> observers_; |
| 95 | 105 |
| 96 // Weak pointer factory for generating 'this' pointers that might live longer | 106 // Weak pointer factory for generating 'this' pointers that might live longer |
| 97 // than we do. | 107 // than we do. |
| 98 // Note: This should remain the last member so it'll be destroyed and | 108 // Note: This should remain the last member so it'll be destroyed and |
| 99 // invalidate its weak pointers before any other members are destroyed. | 109 // invalidate its weak pointers before any other members are destroyed. |
| 100 base::WeakPtrFactory<FakeBluetoothGattServiceClient> weak_ptr_factory_; | 110 base::WeakPtrFactory<FakeBluetoothGattServiceClient> weak_ptr_factory_; |
| 101 | 111 |
| 102 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattServiceClient); | 112 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattServiceClient); |
| 103 }; | 113 }; |
| 104 | 114 |
| 105 } // namespace bluez | 115 } // namespace bluez |
| 106 | 116 |
| 107 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ | 117 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ |
| OLD | NEW |