OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BLUEZ_BLUETOOTH_ADAPTER_BLUEZ_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_ADAPTER_BLUEZ_H_ |
6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_ADAPTER_BLUEZ_H_ | 6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_ADAPTER_BLUEZ_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 : public device::BluetoothAdapter, | 70 : public device::BluetoothAdapter, |
71 public bluez::BluetoothAdapterClient::Observer, | 71 public bluez::BluetoothAdapterClient::Observer, |
72 public bluez::BluetoothDeviceClient::Observer, | 72 public bluez::BluetoothDeviceClient::Observer, |
73 public bluez::BluetoothInputClient::Observer, | 73 public bluez::BluetoothInputClient::Observer, |
74 public bluez::BluetoothAgentServiceProvider::Delegate { | 74 public bluez::BluetoothAgentServiceProvider::Delegate { |
75 public: | 75 public: |
76 using ErrorCompletionCallback = | 76 using ErrorCompletionCallback = |
77 base::Callback<void(const std::string& error_message)>; | 77 base::Callback<void(const std::string& error_message)>; |
78 using ProfileRegisteredCallback = | 78 using ProfileRegisteredCallback = |
79 base::Callback<void(BluetoothAdapterProfileBlueZ* profile)>; | 79 base::Callback<void(BluetoothAdapterProfileBlueZ* profile)>; |
| 80 using ServiceRecordCallback = base::Callback<void(uint32_t)>; |
80 using ServiceRecordErrorCallback = | 81 using ServiceRecordErrorCallback = |
81 base::Callback<void(BluetoothServiceRecordBlueZ::ErrorCode)>; | 82 base::Callback<void(BluetoothServiceRecordBlueZ::ErrorCode)>; |
82 | 83 |
83 // Calls |init_callback| after a BluetoothAdapter is fully initialized. | 84 // Calls |init_callback| after a BluetoothAdapter is fully initialized. |
84 static base::WeakPtr<BluetoothAdapter> CreateAdapter( | 85 static base::WeakPtr<BluetoothAdapter> CreateAdapter( |
85 const InitCallback& init_callback); | 86 const InitCallback& init_callback); |
86 | 87 |
87 // BluetoothAdapter: | 88 // BluetoothAdapter: |
88 void Shutdown() override; | 89 void Shutdown() override; |
89 UUIDList GetUUIDs() const override; | 90 UUIDList GetUUIDs() const override; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 const std::string& identifier) const override; | 128 const std::string& identifier) const override; |
128 | 129 |
129 // These functions are specifically for use with ARC++. They have no need to | 130 // These functions are specifically for use with ARC++. They have no need to |
130 // exist for other platforms, hence we're putting them directly in the BlueZ | 131 // exist for other platforms, hence we're putting them directly in the BlueZ |
131 // specific code. | 132 // specific code. |
132 | 133 |
133 // Creates a service record with the SDP server running on this adapter. This | 134 // Creates a service record with the SDP server running on this adapter. This |
134 // only creates the record, it does not create a listening socket for the | 135 // only creates the record, it does not create a listening socket for the |
135 // service. | 136 // service. |
136 void CreateServiceRecord(const BluetoothServiceRecordBlueZ& record, | 137 void CreateServiceRecord(const BluetoothServiceRecordBlueZ& record, |
137 const base::Closure& callback, | 138 const ServiceRecordCallback& callback, |
138 const ServiceRecordErrorCallback& error_callback); | 139 const ServiceRecordErrorCallback& error_callback); |
139 | 140 |
140 // Removes a service record from the SDP server. This would result in the | 141 // Removes a service record from the SDP server. This would result in the |
141 // service not being discoverable in any further scans of the adapter. Any | 142 // service not being discoverable in any further scans of the adapter. Any |
142 // sockets listening on this service will need to be closed separately. | 143 // sockets listening on this service will need to be closed separately. |
143 void RemoveServiceRecord(const device::BluetoothUUID& uuid, | 144 void RemoveServiceRecord(uint32_t handle, |
144 const base::Closure& callback, | 145 const base::Closure& callback, |
145 const ServiceRecordErrorCallback& error_callback); | 146 const ServiceRecordErrorCallback& error_callback); |
146 | 147 |
147 // Locates the device object by object path (the devices map and | 148 // Locates the device object by object path (the devices map and |
148 // BluetoothDevice methods are by address). | 149 // BluetoothDevice methods are by address). |
149 BluetoothDeviceBlueZ* GetDeviceWithPath(const dbus::ObjectPath& object_path); | 150 BluetoothDeviceBlueZ* GetDeviceWithPath(const dbus::ObjectPath& object_path); |
150 | 151 |
151 // Announce to observers a device address change. | 152 // Announce to observers a device address change. |
152 void NotifyDeviceAddressChanged(BluetoothDeviceBlueZ* device, | 153 void NotifyDeviceAddressChanged(BluetoothDeviceBlueZ* device, |
153 const std::string& old_address); | 154 const std::string& old_address); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 const device::BluetoothGattService::ErrorCallback& error_callback); | 415 const device::BluetoothGattService::ErrorCallback& error_callback); |
415 | 416 |
416 // Register application, ignoring the given errors. Used to register a GATT | 417 // Register application, ignoring the given errors. Used to register a GATT |
417 // application even if a previous unregister application call fails. | 418 // application even if a previous unregister application call fails. |
418 void RegisterApplicationOnError( | 419 void RegisterApplicationOnError( |
419 const base::Closure& callback, | 420 const base::Closure& callback, |
420 const device::BluetoothGattService::ErrorCallback& error_callback, | 421 const device::BluetoothGattService::ErrorCallback& error_callback, |
421 const std::string& error_name, | 422 const std::string& error_name, |
422 const std::string& error_message); | 423 const std::string& error_message); |
423 | 424 |
| 425 // Called by dbus:: on an error while trying to create or remove a service |
| 426 // record. Translates the error name/message into a |
| 427 // BluetoothServiceRecordBlueZ::ErrorCode value. |
| 428 void ServiceRecordErrorConnector( |
| 429 const ServiceRecordErrorCallback& error_callback, |
| 430 const std::string& error_name, |
| 431 const std::string& error_message); |
| 432 |
424 InitCallback init_callback_; | 433 InitCallback init_callback_; |
425 | 434 |
426 bool initialized_; | 435 bool initialized_; |
427 | 436 |
428 // Set in |Shutdown()|, makes IsPresent()| return false. | 437 // Set in |Shutdown()|, makes IsPresent()| return false. |
429 bool dbus_is_shutdown_; | 438 bool dbus_is_shutdown_; |
430 | 439 |
431 // Number of discovery sessions that have been added. | 440 // Number of discovery sessions that have been added. |
432 int num_discovery_sessions_; | 441 int num_discovery_sessions_; |
433 | 442 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 // Note: This should remain the last member so it'll be destroyed and | 494 // Note: This should remain the last member so it'll be destroyed and |
486 // invalidate its weak pointers before any other members are destroyed. | 495 // invalidate its weak pointers before any other members are destroyed. |
487 base::WeakPtrFactory<BluetoothAdapterBlueZ> weak_ptr_factory_; | 496 base::WeakPtrFactory<BluetoothAdapterBlueZ> weak_ptr_factory_; |
488 | 497 |
489 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterBlueZ); | 498 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterBlueZ); |
490 }; | 499 }; |
491 | 500 |
492 } // namespace bluez | 501 } // namespace bluez |
493 | 502 |
494 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_ADAPTER_BLUEZ_H_ | 503 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_ADAPTER_BLUEZ_H_ |
OLD | NEW |