Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Side by Side Diff: chromeos/dbus/fake_bluetooth_gatt_manager_client.h

Issue 1347193004: Refactor DBusThreadManager to split away BT clients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_
7
8 #include <map>
9 #include <string>
10 #include <utility>
11
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"
16
17 namespace chromeos {
18
19 class FakeBluetoothGattCharacteristicServiceProvider;
20 class FakeBluetoothGattDescriptorServiceProvider;
21 class FakeBluetoothGattServiceServiceProvider;
22
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;
31
32 // DBusClient override.
33 void Init(dbus::Bus* bus) override;
34
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;
43
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);
53
54 void UnregisterServiceServiceProvider(
55 FakeBluetoothGattServiceServiceProvider* provider);
56 void UnregisterCharacteristicServiceProvider(
57 FakeBluetoothGattCharacteristicServiceProvider* provider);
58 void UnregisterDescriptorServiceProvider(
59 FakeBluetoothGattDescriptorServiceProvider* provider);
60
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;
70
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;
74
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;
85
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;
92
93 ServiceMap service_map_;
94 CharacteristicMap characteristic_map_;
95 DescriptorMap descriptor_map_;
96
97 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattManagerClient);
98 };
99
100 } // namespace chromeos
101
102 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_bluetooth_gatt_descriptor_service_provider.cc ('k') | chromeos/dbus/fake_bluetooth_gatt_manager_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698