diff options
Diffstat (limited to 'device/bluetooth/bluetooth_gatt_connection_chromeos.h')
-rw-r--r-- | device/bluetooth/bluetooth_gatt_connection_chromeos.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/device/bluetooth/bluetooth_gatt_connection_chromeos.h b/device/bluetooth/bluetooth_gatt_connection_chromeos.h new file mode 100644 index 0000000..6e40283 --- /dev/null +++ b/device/bluetooth/bluetooth_gatt_connection_chromeos.h @@ -0,0 +1,58 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_CONNECTION_CHROMEOS_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_GATT_CONNECTION_CHROMEOS_H_ + +#include <string> + +#include "base/callback.h" +#include "base/memory/weak_ptr.h" +#include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_gatt_connection.h" +#include "device/bluetooth/dbus/bluetooth_device_client.h" + +namespace device { + +class BluetoothAdapter; + +} // namespace device + +namespace chromeos { + +// BluetoothGattConnectionChromeOS implements BluetoothGattConnection for the +// Chrome OS platform. +class BluetoothGattConnectionChromeOS + : public device::BluetoothGattConnection, + public bluez::BluetoothDeviceClient::Observer { + public: + explicit BluetoothGattConnectionChromeOS( + scoped_refptr<device::BluetoothAdapter> adapter, + const std::string& device_address, + const dbus::ObjectPath& object_path); + ~BluetoothGattConnectionChromeOS() override; + + // BluetoothGattConnection overrides. + bool IsConnected() override; + void Disconnect() override; + + private: + // bluez::Bluetooth$1Client::Observer overrides. + void DeviceRemoved(const dbus::ObjectPath& object_path) override; + void DevicePropertyChanged(const dbus::ObjectPath& object_path, + const std::string& property_name) override; + + // True, if the connection is currently active. + bool connected_; + + // D-Bus object path of the underlying device. This is used to filter observer + // events. + dbus::ObjectPath object_path_; + + DISALLOW_COPY_AND_ASSIGN(BluetoothGattConnectionChromeOS); +}; + +} // namespace chromeos + +#endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_CONNECTION_CHROMEOS_H_ |