Chromium Code Reviews| Index: chromeos/dbus/bluetooth_advertisement_service_provider.h |
| diff --git a/chromeos/dbus/bluetooth_advertisement_service_provider.h b/chromeos/dbus/bluetooth_advertisement_service_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..248765381f27a5751a24f441b53ed799ac62a0cc |
| --- /dev/null |
| +++ b/chromeos/dbus/bluetooth_advertisement_service_provider.h |
| @@ -0,0 +1,84 @@ |
| +// Copyright 2013 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 CHROMEOS_DBUS_BLUETOOTH_ADVERTISEMENT_SERVICE_PROVIDER_H_ |
| +#define CHROMEOS_DBUS_BLUETOOTH_ADVERTISEMENT_SERVICE_PROVIDER_H_ |
| + |
| +#include <stdint.h> |
| + |
| +#include <map> |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/callback.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "chromeos/chromeos_export.h" |
| +#include "dbus/bus.h" |
| +#include "dbus/file_descriptor.h" |
| +#include "dbus/object_path.h" |
| + |
| +namespace chromeos { |
| + |
| +// BluetoothAdvertisementServiceProvider is used to provide a D-Bus object that |
| +// the Bluetooth daemon can communicate with to advertise data. |
| +// |
| +// Instantiate with a chosen D-Bus object path and delegate object, and pass |
| +// the D-Bus object path as the |obj_path| argument to the |
| +// chromeos::BluetoothAdvertisementManagerClient::RegisterAdvertisement() |
| +// method. |
| +// |
| +// When an incoming profile connection occurs, or after initiating a connection |
|
Marie Janssen
2015/04/09 22:36:27
This comment section doesn't make sense, I'm guess
rkc
2015/04/13 19:47:45
Done.
|
| +// using the chromeos::BluetoothDeviceClient::ConnectAdvertisement() method, the |
| +// Bluetooth daemon will make calls to this profile object and they will be |
| +// passed on to your Delegate object for handling. Responses should be returned |
| +// using the callbacks supplied to those methods. |
| +class CHROMEOS_EXPORT BluetoothAdvertisementServiceProvider { |
| + public: |
| + using UUIDList = std::vector<std::string>; |
| + using ManufacturerData = std::map<uint16_t, std::vector<uint8_t>>; |
| + using ServiceData = std::map<std::string, std::vector<uint8_t>>; |
| + |
| + // Type of advertisement. |
| + enum AdvertisementType { BROADCAST, PERIPHERAL }; |
| + |
| + // Interface for reacting to profile requests. |
| + class Delegate { |
| + public: |
| + virtual ~Delegate() {} |
| + |
| + // This method will be called when the advertisement is unregistered from |
| + // the Bluetooth daemon, generally at shutdown or at the applications' |
| + // request. It may be used to perform cleanup tasks. This corresponds to |
| + // the org.bluez.Advertisement1.Release method and is renamed to avoid a |
|
Marie Janssen
2015/04/09 22:36:27
nit: org.bluez.LEAdvertisement1.Release
rkc
2015/04/13 19:47:45
Done.
|
| + // conflict with base::Refcounted<T>. |
| + virtual void Released() = 0; |
| + }; |
| + |
| + virtual ~BluetoothAdvertisementServiceProvider(); |
| + |
| + // Creates the instance where |bus| is the D-Bus bus connection to export |
| + // the object onto, |object_path| is the object path that it should have |
| + // and |delegate| is the object to which all method calls will be passed |
| + // and responses generated from. |
| + static BluetoothAdvertisementServiceProvider* Create( |
| + dbus::Bus* bus, |
| + const dbus::ObjectPath& object_path, |
| + Delegate* delegate, |
| + AdvertisementType type, |
| + scoped_ptr<UUIDList> service_uuids, |
| + scoped_ptr<ManufacturerData> manufacturer_data, |
| + scoped_ptr<UUIDList> solicit_uuids, |
| + scoped_ptr<ServiceData> service_data); |
| + |
| + protected: |
| + BluetoothAdvertisementServiceProvider(); |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(BluetoothAdvertisementServiceProvider); |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROMEOS_DBUS_BLUETOOTH_ADVERTISEMENT_SERVICE_PROVIDER_H_ |