Update V8 to version 4.6.54.
[chromium-blink-merge.git] / chromeos / dbus / fake_bluetooth_gatt_manager_client.h
blob9dccaac077ce441e6aca5a5def19c6992e530500
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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_
8 #include <map>
9 #include <string>
10 #include <utility>
12 #include "base/callback.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/bluetooth_gatt_manager_client.h"
15 #include "dbus/object_path.h"
17 namespace chromeos {
19 class FakeBluetoothGattCharacteristicServiceProvider;
20 class FakeBluetoothGattDescriptorServiceProvider;
21 class FakeBluetoothGattServiceServiceProvider;
23 // FakeBluetoothGattManagerClient simulates the behavior of the Bluetooth
24 // daemon's GATT manager object and is used both in test cases in place of a
25 // mock and on the Linux desktop.
26 class CHROMEOS_EXPORT FakeBluetoothGattManagerClient
27 : public BluetoothGattManagerClient {
28 public:
29 FakeBluetoothGattManagerClient();
30 ~FakeBluetoothGattManagerClient() override;
32 // DBusClient override.
33 void Init(dbus::Bus* bus) override;
35 // BluetoothGattManagerClient overrides.
36 void RegisterService(const dbus::ObjectPath& service_path,
37 const Options& options,
38 const base::Closure& callback,
39 const ErrorCallback& error_callback) override;
40 void UnregisterService(const dbus::ObjectPath& service_path,
41 const base::Closure& callback,
42 const ErrorCallback& error_callback) override;
44 // Register, unregister, and retrieve pointers to service, characteristic, and
45 // descriptor service providers. Automatically called from the service
46 // provider constructor and destructors.
47 void RegisterServiceServiceProvider(
48 FakeBluetoothGattServiceServiceProvider* provider);
49 void RegisterCharacteristicServiceProvider(
50 FakeBluetoothGattCharacteristicServiceProvider* provider);
51 void RegisterDescriptorServiceProvider(
52 FakeBluetoothGattDescriptorServiceProvider* provider);
54 void UnregisterServiceServiceProvider(
55 FakeBluetoothGattServiceServiceProvider* provider);
56 void UnregisterCharacteristicServiceProvider(
57 FakeBluetoothGattCharacteristicServiceProvider* provider);
58 void UnregisterDescriptorServiceProvider(
59 FakeBluetoothGattDescriptorServiceProvider* provider);
61 // Return a pointer to the service provider that corresponds to the object
62 // path |object_path| if it exists.
63 FakeBluetoothGattServiceServiceProvider*
64 GetServiceServiceProvider(const dbus::ObjectPath& object_path) const;
65 FakeBluetoothGattCharacteristicServiceProvider*
66 GetCharacteristicServiceProvider(
67 const dbus::ObjectPath& object_path) const;
68 FakeBluetoothGattDescriptorServiceProvider*
69 GetDescriptorServiceProvider(const dbus::ObjectPath& object_path) const;
71 // Returns true, if a GATT service with object path |object_path| was
72 // registered with the GATT manager using RegisterService.
73 bool IsServiceRegistered(const dbus::ObjectPath& object_path) const;
75 private:
76 // Mappings for GATT service, characteristic, and descriptor service
77 // providers. The fake GATT manager stores references to all instances
78 // created so that they can be obtained by tests.
79 typedef std::map<
80 dbus::ObjectPath, FakeBluetoothGattCharacteristicServiceProvider*>
81 CharacteristicMap;
82 typedef std::map<
83 dbus::ObjectPath, FakeBluetoothGattDescriptorServiceProvider*>
84 DescriptorMap;
86 // The mapping for services is from object paths to pairs of boolean and
87 // service provider pointer, where the boolean denotes whether or not the
88 // service is already registered.
89 typedef std::pair<bool, FakeBluetoothGattServiceServiceProvider*>
90 ServiceProvider;
91 typedef std::map<dbus::ObjectPath, ServiceProvider> ServiceMap;
93 ServiceMap service_map_;
94 CharacteristicMap characteristic_map_;
95 DescriptorMap descriptor_map_;
97 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattManagerClient);
100 } // namespace chromeos
102 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_