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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_service_bluez.h

Issue 1367663002: Add Linux support for the Bluetooth API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor_dbus
Patch Set: rebase 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "dbus/object_path.h" 15 #include "dbus/object_path.h"
16 #include "device/bluetooth/bluetooth_gatt_service.h" 16 #include "device/bluetooth/bluetooth_gatt_service.h"
17 #include "device/bluetooth/bluetooth_uuid.h" 17 #include "device/bluetooth/bluetooth_uuid.h"
18 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" 18 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h"
19 #include "device/bluetooth/dbus/bluetooth_gatt_service_client.h" 19 #include "device/bluetooth/dbus/bluetooth_gatt_service_client.h"
20 20
21 namespace device { 21 namespace device {
22 22
23 class BluetoothAdapter; 23 class BluetoothAdapter;
24 class BluetoothGattCharacteristic; 24 class BluetoothGattCharacteristic;
25 25
26 } // namespace device 26 } // namespace device
27 27
28 namespace chromeos { 28 namespace bluez {
29 29
30 class BluetoothAdapterChromeOS; 30 class BluetoothAdapterBlueZ;
31 class BluetoothDeviceChromeOS; 31 class BluetoothDeviceBlueZ;
32 class BluetoothRemoteGattCharacteristicChromeOS; 32 class BluetoothRemoteGattCharacteristicBlueZ;
33 class BluetoothRemoteGattDescriptorChromeOS; 33 class BluetoothRemoteGattDescriptorBlueZ;
34 34
35 // The BluetoothRemoteGattServiceChromeOS class implements BluetootGattService 35 // The BluetoothRemoteGattServiceBlueZ class implements BluetootGattService
36 // for remote GATT services on the Chrome OS platform. 36 // for remote GATT services on the Chrome OS platform.
37 class BluetoothRemoteGattServiceChromeOS 37 class BluetoothRemoteGattServiceBlueZ
38 : public device::BluetoothGattService, 38 : public device::BluetoothGattService,
39 public bluez::BluetoothGattServiceClient::Observer, 39 public bluez::BluetoothGattServiceClient::Observer,
40 public bluez::BluetoothGattCharacteristicClient::Observer { 40 public bluez::BluetoothGattCharacteristicClient::Observer {
41 public: 41 public:
42 // device::BluetoothGattService overrides. 42 // device::BluetoothGattService overrides.
43 std::string GetIdentifier() const override; 43 std::string GetIdentifier() const override;
44 device::BluetoothUUID GetUUID() const override; 44 device::BluetoothUUID GetUUID() const override;
45 bool IsLocal() const override; 45 bool IsLocal() const override;
46 bool IsPrimary() const override; 46 bool IsPrimary() const override;
47 device::BluetoothDevice* GetDevice() const override; 47 device::BluetoothDevice* GetDevice() const override;
(...skipping 12 matching lines...) Expand all
60 const ErrorCallback& error_callback) override; 60 const ErrorCallback& error_callback) override;
61 61
62 // Object path of the underlying service. 62 // Object path of the underlying service.
63 const dbus::ObjectPath& object_path() const { return object_path_; } 63 const dbus::ObjectPath& object_path() const { return object_path_; }
64 64
65 // Parses a named D-Bus error into a service error code. 65 // Parses a named D-Bus error into a service error code.
66 static device::BluetoothGattService::GattErrorCode DBusErrorToServiceError( 66 static device::BluetoothGattService::GattErrorCode DBusErrorToServiceError(
67 const std::string error_name); 67 const std::string error_name);
68 68
69 // Returns the adapter associated with this service. 69 // Returns the adapter associated with this service.
70 BluetoothAdapterChromeOS* GetAdapter() const; 70 BluetoothAdapterBlueZ* GetAdapter() const;
71 71
72 // Notifies its observers that the GATT service has changed. This is mainly 72 // Notifies its observers that the GATT service has changed. This is mainly
73 // used by BluetoothRemoteGattCharacteristicChromeOS instances to notify 73 // used by BluetoothRemoteGattCharacteristicBlueZ instances to notify
74 // service observers when characteristic descriptors get added and removed. 74 // service observers when characteristic descriptors get added and removed.
75 void NotifyServiceChanged(); 75 void NotifyServiceChanged();
76 76
77 // Notifies its observers that a descriptor |descriptor| belonging to 77 // Notifies its observers that a descriptor |descriptor| belonging to
78 // characteristic |characteristic| has been added or removed. This is used 78 // characteristic |characteristic| has been added or removed. This is used
79 // by BluetoothRemoteGattCharacteristicChromeOS instances to notify service 79 // by BluetoothRemoteGattCharacteristicBlueZ instances to notify service
80 // observers when characteristic descriptors get added and removed. If |added| 80 // observers when characteristic descriptors get added and removed. If |added|
81 // is true, an "Added" event will be sent. Otherwise, a "Removed" event will 81 // is true, an "Added" event will be sent. Otherwise, a "Removed" event will
82 // be sent. 82 // be sent.
83 void NotifyDescriptorAddedOrRemoved( 83 void NotifyDescriptorAddedOrRemoved(
84 BluetoothRemoteGattCharacteristicChromeOS* characteristic, 84 BluetoothRemoteGattCharacteristicBlueZ* characteristic,
85 BluetoothRemoteGattDescriptorChromeOS* descriptor, 85 BluetoothRemoteGattDescriptorBlueZ* descriptor,
86 bool added); 86 bool added);
87 87
88 // Notifies its observers that the value of a descriptor has changed. Called 88 // Notifies its observers that the value of a descriptor has changed. Called
89 // by BluetoothRemoteGattCharacteristicChromeOS instances to notify service 89 // by BluetoothRemoteGattCharacteristicBlueZ instances to notify service
90 // observers. 90 // observers.
91 void NotifyDescriptorValueChanged( 91 void NotifyDescriptorValueChanged(
92 BluetoothRemoteGattCharacteristicChromeOS* characteristic, 92 BluetoothRemoteGattCharacteristicBlueZ* characteristic,
93 BluetoothRemoteGattDescriptorChromeOS* descriptor, 93 BluetoothRemoteGattDescriptorBlueZ* descriptor,
94 const std::vector<uint8>& value); 94 const std::vector<uint8>& value);
95 95
96 private: 96 private:
97 friend class BluetoothDeviceChromeOS; 97 friend class BluetoothDeviceBlueZ;
98 98
99 typedef std::map<dbus::ObjectPath, BluetoothRemoteGattCharacteristicChromeOS*> 99 typedef std::map<dbus::ObjectPath, BluetoothRemoteGattCharacteristicBlueZ*>
100 CharacteristicMap; 100 CharacteristicMap;
101 101
102 BluetoothRemoteGattServiceChromeOS(BluetoothAdapterChromeOS* adapter, 102 BluetoothRemoteGattServiceBlueZ(BluetoothAdapterBlueZ* adapter,
103 BluetoothDeviceChromeOS* device, 103 BluetoothDeviceBlueZ* device,
104 const dbus::ObjectPath& object_path); 104 const dbus::ObjectPath& object_path);
105 ~BluetoothRemoteGattServiceChromeOS() override; 105 ~BluetoothRemoteGattServiceBlueZ() override;
106 106
107 // bluez::BluetoothGattServiceClient::Observer override. 107 // bluez::BluetoothGattServiceClient::Observer override.
108 void GattServicePropertyChanged(const dbus::ObjectPath& object_path, 108 void GattServicePropertyChanged(const dbus::ObjectPath& object_path,
109 const std::string& property_name) override; 109 const std::string& property_name) override;
110 110
111 // bluez::BluetoothGattCharacteristicClient::Observer override. 111 // bluez::BluetoothGattCharacteristicClient::Observer override.
112 void GattCharacteristicAdded(const dbus::ObjectPath& object_path) override; 112 void GattCharacteristicAdded(const dbus::ObjectPath& object_path) override;
113 void GattCharacteristicRemoved(const dbus::ObjectPath& object_path) override; 113 void GattCharacteristicRemoved(const dbus::ObjectPath& object_path) override;
114 void GattCharacteristicPropertyChanged( 114 void GattCharacteristicPropertyChanged(
115 const dbus::ObjectPath& object_path, 115 const dbus::ObjectPath& object_path,
116 const std::string& property_name) override; 116 const std::string& property_name) override;
117 117
118 // Object path of the GATT service. 118 // Object path of the GATT service.
119 dbus::ObjectPath object_path_; 119 dbus::ObjectPath object_path_;
120 120
121 // The adapter associated with this service. It's ok to store a raw pointer 121 // The adapter associated with this service. It's ok to store a raw pointer
122 // here since |adapter_| indirectly owns this instance. 122 // here since |adapter_| indirectly owns this instance.
123 BluetoothAdapterChromeOS* adapter_; 123 BluetoothAdapterBlueZ* adapter_;
124 124
125 // The device this GATT service belongs to. It's ok to store a raw pointer 125 // The device this GATT service belongs to. It's ok to store a raw pointer
126 // here since |device_| owns this instance. 126 // here since |device_| owns this instance.
127 BluetoothDeviceChromeOS* device_; 127 BluetoothDeviceBlueZ* device_;
128 128
129 // Mapping from GATT characteristic object paths to characteristic objects. 129 // Mapping from GATT characteristic object paths to characteristic objects.
130 // owned by this service. Since the Chrome OS implementation uses object 130 // owned by this service. Since the Chrome OS implementation uses object
131 // paths as unique identifiers, we also use this mapping to return 131 // paths as unique identifiers, we also use this mapping to return
132 // characteristics by identifier. 132 // characteristics by identifier.
133 CharacteristicMap characteristics_; 133 CharacteristicMap characteristics_;
134 134
135 // Indicates whether or not the characteristics of this service are known to 135 // Indicates whether or not the characteristics of this service are known to
136 // have been discovered. 136 // have been discovered.
137 bool discovery_complete_; 137 bool discovery_complete_;
138 138
139 // Note: This should remain the last member so it'll be destroyed and 139 // Note: This should remain the last member so it'll be destroyed and
140 // invalidate its weak pointers before any other members are destroyed. 140 // invalidate its weak pointers before any other members are destroyed.
141 base::WeakPtrFactory<BluetoothRemoteGattServiceChromeOS> weak_ptr_factory_; 141 base::WeakPtrFactory<BluetoothRemoteGattServiceBlueZ> weak_ptr_factory_;
142 142
143 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceChromeOS); 143 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceBlueZ);
144 }; 144 };
145 145
146 } // namespace chromeos 146 } // namespace bluez
147 147
148 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ 148 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.cc ('k') | device/bluetooth/bluetooth_remote_gatt_service_bluez.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698