Roll src/third_party/WebKit 75a2fa9:2546356 (svn 202272:202273)
[chromium-blink-merge.git] / chromeos / dbus / bluetooth_le_advertising_manager_client.h
blob5160a9f52ef26073173cf0dfb52913023c8a392b
1 // Copyright 2015 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.
5 #ifndef CHROMEOS_DBUS_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h"
14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/dbus_client.h"
16 #include "dbus/object_path.h"
18 namespace chromeos {
20 // BluetoothAdvertisingManagerClient is used to communicate with the advertising
21 // manager object of the BlueZ daemon.
22 class CHROMEOS_EXPORT BluetoothLEAdvertisingManagerClient : public DBusClient {
23 public:
24 // Interface for observing changes to advertising managers.
25 class Observer {
26 public:
27 virtual ~Observer() {}
29 // Called when an advertising manager with object path |object_path| is
30 // added to the system.
31 virtual void AdvertisingManagerAdded(const dbus::ObjectPath& object_path) {}
33 // Called when an advertising manager with object path |object_path| is
34 // removed from the system.
35 virtual void AdvertisingManagerRemoved(
36 const dbus::ObjectPath& object_path) {}
39 ~BluetoothLEAdvertisingManagerClient() override;
41 // Adds and removes observers for events which change the advertising
42 // managers on the system.
43 virtual void AddObserver(Observer* observer) = 0;
44 virtual void RemoveObserver(Observer* observer) = 0;
46 // The ErrorCallback is used by advertising manager methods to indicate
47 // failure. It receives two arguments: the name of the error in |error_name|
48 // and an optional message in |error_message|.
49 using ErrorCallback = base::Callback<void(const std::string& error_name,
50 const std::string& error_message)>;
52 // Registers an advertisement with the DBus object path
53 // |advertisement_object_path| with BlueZ's advertising manager.
54 virtual void RegisterAdvertisement(
55 const dbus::ObjectPath& manager_object_path,
56 const dbus::ObjectPath& advertisement_object_path,
57 const base::Closure& callback,
58 const ErrorCallback& error_callback) = 0;
60 // Unregisters an advertisement with the DBus object path
61 // |advertisement_object_path| with BlueZ's advertising manager.
62 virtual void UnregisterAdvertisement(
63 const dbus::ObjectPath& manager_object_path,
64 const dbus::ObjectPath& advertisement_object_path,
65 const base::Closure& callback,
66 const ErrorCallback& error_callback) = 0;
68 // Creates the instance.
69 static BluetoothLEAdvertisingManagerClient* Create();
71 // Constants used to indicate exceptional error conditions.
72 static const char kNoResponseError[];
74 protected:
75 BluetoothLEAdvertisingManagerClient();
77 private:
78 DISALLOW_COPY_AND_ASSIGN(BluetoothLEAdvertisingManagerClient);
81 } // namespace chromeos
83 #endif // CHROMEOS_DBUS_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_