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

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

Issue 228643004: device/bluetooth: Add chromeos::BluetoothRemoteGattCharacteristicChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed potentially flaky expectation from unit test. Created 6 years, 8 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 | Annotate | Revision Log
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_CHROMEOS_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_
7 7
8 #include <map>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h"
13 #include "chromeos/dbus/bluetooth_gatt_service_client.h" 15 #include "chromeos/dbus/bluetooth_gatt_service_client.h"
14 #include "dbus/object_path.h" 16 #include "dbus/object_path.h"
15 #include "device/bluetooth/bluetooth_gatt_service.h" 17 #include "device/bluetooth/bluetooth_gatt_service.h"
16 #include "device/bluetooth/bluetooth_uuid.h" 18 #include "device/bluetooth/bluetooth_uuid.h"
17 19
18 namespace device { 20 namespace device {
19 21
20 class BluetoothGattCharacteristic; 22 class BluetoothGattCharacteristic;
21 23
22 } // namespace device 24 } // namespace device
23 25
24 namespace chromeos { 26 namespace chromeos {
25 27
26 class BluetoothDeviceChromeOS; 28 class BluetoothDeviceChromeOS;
29 class BluetoothRemoteGattCharacteristicChromeOS;
27 30
28 // The BluetoothRemoteGattServiceChromeOS class implements BluetootGattService 31 // The BluetoothRemoteGattServiceChromeOS class implements BluetootGattService
29 // for remote GATT services on the the Chrome OS platform. 32 // for remote GATT services on the the Chrome OS platform.
30 class BluetoothRemoteGattServiceChromeOS 33 class BluetoothRemoteGattServiceChromeOS
31 : public device::BluetoothGattService, 34 : public device::BluetoothGattService,
32 public BluetoothGattServiceClient::Observer { 35 public BluetoothGattServiceClient::Observer,
36 public BluetoothGattCharacteristicClient::Observer {
33 public: 37 public:
34 // device::BluetoothGattService overrides. 38 // device::BluetoothGattService overrides.
39 virtual void AddObserver(
40 device::BluetoothGattService::Observer* observer) OVERRIDE;
41 virtual void RemoveObserver(
42 device::BluetoothGattService::Observer* observer) OVERRIDE;
35 virtual std::string GetIdentifier() const OVERRIDE; 43 virtual std::string GetIdentifier() const OVERRIDE;
36 virtual device::BluetoothUUID GetUUID() const OVERRIDE; 44 virtual device::BluetoothUUID GetUUID() const OVERRIDE;
37 virtual bool IsLocal() const OVERRIDE; 45 virtual bool IsLocal() const OVERRIDE;
38 virtual bool IsPrimary() const OVERRIDE; 46 virtual bool IsPrimary() const OVERRIDE;
39 virtual const std::vector<device::BluetoothGattCharacteristic*>& 47 virtual std::vector<device::BluetoothGattCharacteristic*>
40 GetCharacteristics() const OVERRIDE; 48 GetCharacteristics() const OVERRIDE;
41 virtual const std::vector<device::BluetoothGattService*>& 49 virtual std::vector<device::BluetoothGattService*>
42 GetIncludedServices() const OVERRIDE; 50 GetIncludedServices() const OVERRIDE;
43 virtual void AddObserver( 51 virtual device::BluetoothGattCharacteristic* GetCharacteristic(
44 device::BluetoothGattService::Observer* observer) OVERRIDE; 52 const std::string& identifier) OVERRIDE;
45 virtual void RemoveObserver(
46 device::BluetoothGattService::Observer* observer) OVERRIDE;
47 virtual bool AddCharacteristic( 53 virtual bool AddCharacteristic(
48 device::BluetoothGattCharacteristic* characteristic) OVERRIDE; 54 device::BluetoothGattCharacteristic* characteristic) OVERRIDE;
49 virtual bool AddIncludedService( 55 virtual bool AddIncludedService(
50 device::BluetoothGattService* service) OVERRIDE; 56 device::BluetoothGattService* service) OVERRIDE;
51 virtual void Register(const base::Closure& callback, 57 virtual void Register(const base::Closure& callback,
52 const ErrorCallback& error_callback) OVERRIDE; 58 const ErrorCallback& error_callback) OVERRIDE;
53 virtual void Unregister(const base::Closure& callback, 59 virtual void Unregister(const base::Closure& callback,
54 const ErrorCallback& error_callback) OVERRIDE; 60 const ErrorCallback& error_callback) OVERRIDE;
55 61
56 // Object path of the underlying service. 62 // Object path of the underlying service.
57 const dbus::ObjectPath& object_path() const { return object_path_; } 63 const dbus::ObjectPath& object_path() const { return object_path_; }
58 64
59 private: 65 private:
60 friend class BluetoothDeviceChromeOS; 66 friend class BluetoothDeviceChromeOS;
61 67
62 BluetoothRemoteGattServiceChromeOS(BluetoothDeviceChromeOS* device, 68 BluetoothRemoteGattServiceChromeOS(BluetoothDeviceChromeOS* device,
63 const dbus::ObjectPath& object_path); 69 const dbus::ObjectPath& object_path);
64 virtual ~BluetoothRemoteGattServiceChromeOS(); 70 virtual ~BluetoothRemoteGattServiceChromeOS();
65 71
66 // BluetoothGattServiceClient::Observer override. 72 // BluetoothGattServiceClient::Observer override.
67 virtual void GattServicePropertyChanged( 73 virtual void GattServicePropertyChanged(
68 const dbus::ObjectPath& object_path, 74 const dbus::ObjectPath& object_path,
69 const std::string& property_name) OVERRIDE; 75 const std::string& property_name) OVERRIDE;
70 76
77 // BluetoothGattCharacteristicClient::Observer override.
78 virtual void GattCharacteristicAdded(
79 const dbus::ObjectPath& object_path) OVERRIDE;
80 virtual void GattCharacteristicRemoved(
81 const dbus::ObjectPath& object_path) OVERRIDE;
82 virtual void GattCharacteristicPropertyChanged(
83 const dbus::ObjectPath& object_path,
84 const std::string& property_name) OVERRIDE;
85
71 // Object path of the GATT service. 86 // Object path of the GATT service.
72 dbus::ObjectPath object_path_; 87 dbus::ObjectPath object_path_;
73 88
74 // List of observers interested in event notifications from us. 89 // List of observers interested in event notifications from us.
75 ObserverList<device::BluetoothGattService::Observer> observers_; 90 ObserverList<device::BluetoothGattService::Observer> observers_;
76 91
77 // The device this GATT service belongs to. 92 // The device this GATT service belongs to.
78 BluetoothDeviceChromeOS* device_; 93 BluetoothDeviceChromeOS* device_;
79 94
80 // The list of characteristics that belong to this service. 95 // Mapping from GATT characteristic object paths to characteristic objects.
81 std::vector<device::BluetoothGattCharacteristic*> characteristics_; 96 // owned by this service. Since the Chrome OS implementation uses object
82 97 // paths as unique identifiers, we also use this mapping to return
83 // The list of GATT services included by this service. 98 // characteristics by identifier.
84 std::vector<device::BluetoothGattService*> includes_; 99 typedef std::map<dbus::ObjectPath, BluetoothRemoteGattCharacteristicChromeOS*>
100 CharacteristicMap;
101 CharacteristicMap characteristics_;
85 102
86 // Note: This should remain the last member so it'll be destroyed and 103 // Note: This should remain the last member so it'll be destroyed and
87 // invalidate its weak pointers before any other members are destroyed. 104 // invalidate its weak pointers before any other members are destroyed.
88 base::WeakPtrFactory<BluetoothRemoteGattServiceChromeOS> weak_ptr_factory_; 105 base::WeakPtrFactory<BluetoothRemoteGattServiceChromeOS> weak_ptr_factory_;
89 106
90 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceChromeOS); 107 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceChromeOS);
91 }; 108 };
92 109
93 } // namespace chromeos 110 } // namespace chromeos
94 111
95 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ 112 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698