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

Side by Side Diff: device/bluetooth/bluez/bluetooth_adapter_bluez.h

Issue 1920693002: Complete //device/bt implementation for hosting local GATT attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 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>
11 #include <memory> 11 #include <memory>
12 #include <queue> 12 #include <queue>
13 #include <string> 13 #include <string>
14 #include <tuple> 14 #include <tuple>
15 #include <utility> 15 #include <utility>
16 #include <vector> 16 #include <vector>
17 17
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "dbus/object_path.h" 20 #include "dbus/object_path.h"
21 #include "device/bluetooth/bluetooth_adapter.h" 21 #include "device/bluetooth/bluetooth_adapter.h"
22 #include "device/bluetooth/bluetooth_audio_sink.h" 22 #include "device/bluetooth/bluetooth_audio_sink.h"
23 #include "device/bluetooth/bluetooth_device.h" 23 #include "device/bluetooth/bluetooth_device.h"
24 #include "device/bluetooth/bluetooth_discovery_session.h" 24 #include "device/bluetooth/bluetooth_discovery_session.h"
25 #include "device/bluetooth/bluetooth_export.h" 25 #include "device/bluetooth/bluetooth_export.h"
26 #include "device/bluetooth/bluetooth_gatt_service.h"
26 #include "device/bluetooth/dbus/bluetooth_adapter_client.h" 27 #include "device/bluetooth/dbus/bluetooth_adapter_client.h"
27 #include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" 28 #include "device/bluetooth/dbus/bluetooth_agent_service_provider.h"
28 #include "device/bluetooth/dbus/bluetooth_device_client.h" 29 #include "device/bluetooth/dbus/bluetooth_device_client.h"
29 #include "device/bluetooth/dbus/bluetooth_input_client.h" 30 #include "device/bluetooth/dbus/bluetooth_input_client.h"
30 #include "device/bluetooth/dbus/bluetooth_profile_manager_client.h" 31 #include "device/bluetooth/dbus/bluetooth_profile_manager_client.h"
31 #include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" 32 #include "device/bluetooth/dbus/bluetooth_profile_service_provider.h"
32 33
33 namespace base { 34 namespace base {
34 class SequencedTaskRunner; 35 class SequencedTaskRunner;
35 } // namespace base 36 } // namespace base
36 37
37 namespace device { 38 namespace device {
38 class BluetoothSocketThread; 39 class BluetoothSocketThread;
39 class BluetoothTestBlueZ; 40 class BluetoothTestBlueZ;
40 } // namespace device 41 } // namespace device
41 42
42 namespace bluez { 43 namespace bluez {
43 44
44 class BluetoothBlueZTest; 45 class BluetoothBlueZTest;
45 class BluetoothAdapterProfileBlueZ; 46 class BluetoothAdapterProfileBlueZ;
46 class BluetoothDeviceBlueZ; 47 class BluetoothDeviceBlueZ;
47 class BluetoothLocalGattServiceBlueZ; 48 class BluetoothLocalGattServiceBlueZ;
49 class BluetoothGattApplicationServiceProvider;
48 class BluetoothPairingBlueZ; 50 class BluetoothPairingBlueZ;
49 51
50 // The BluetoothAdapterBlueZ class implements BluetoothAdapter for platforms 52 // The BluetoothAdapterBlueZ class implements BluetoothAdapter for platforms
51 // that use BlueZ. 53 // that use BlueZ.
52 // 54 //
53 // All methods are called from the dbus origin / UI thread and are generally 55 // All methods are called from the dbus origin / UI thread and are generally
54 // not assumed to be thread-safe. 56 // not assumed to be thread-safe.
55 // 57 //
56 // This class interacts with sockets using the BluetoothSocketThread to ensure 58 // This class interacts with sockets using the BluetoothSocketThread to ensure
57 // single-threaded calls, and posts tasks to the UI thread. 59 // single-threaded calls, and posts tasks to the UI thread.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const dbus::ObjectPath& device_path, 145 const dbus::ObjectPath& device_path,
144 const bluez::BluetoothProfileManagerClient::Options& options, 146 const bluez::BluetoothProfileManagerClient::Options& options,
145 bluez::BluetoothProfileServiceProvider::Delegate* delegate, 147 bluez::BluetoothProfileServiceProvider::Delegate* delegate,
146 const ProfileRegisteredCallback& success_callback, 148 const ProfileRegisteredCallback& success_callback,
147 const ErrorCompletionCallback& error_callback); 149 const ErrorCompletionCallback& error_callback);
148 150
149 // Release use of a profile by a device. 151 // Release use of a profile by a device.
150 void ReleaseProfile(const dbus::ObjectPath& device_path, 152 void ReleaseProfile(const dbus::ObjectPath& device_path,
151 BluetoothAdapterProfileBlueZ* profile); 153 BluetoothAdapterProfileBlueZ* profile);
152 154
155 // Add a local GATT service to the list of services owned by this adapter.
153 void AddLocalGattService( 156 void AddLocalGattService(
154 std::unique_ptr<BluetoothLocalGattServiceBlueZ> service); 157 std::unique_ptr<BluetoothLocalGattServiceBlueZ> service);
155 158
159 // Register a GATT service. The service must belong to this adapter.
160 void RegisterGattService(
161 BluetoothLocalGattServiceBlueZ* service,
162 const base::Closure& callback,
163 const device::BluetoothGattService::ErrorCallback& error_callback);
164
165 // Unregister a GATT service. The service must already be registered.
166 void UnregisterGattService(
167 BluetoothLocalGattServiceBlueZ* service,
168 const base::Closure& callback,
169 const device::BluetoothGattService::ErrorCallback& error_callback);
170
171 // Returns the object path of the adapter.
172 dbus::ObjectPath GetApplicationObjectPath() const;
173
156 protected: 174 protected:
157 // BluetoothAdapter: 175 // BluetoothAdapter:
158 void RemovePairingDelegateInternal( 176 void RemovePairingDelegateInternal(
159 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; 177 device::BluetoothDevice::PairingDelegate* pairing_delegate) override;
160 178
161 private: 179 private:
162 friend class BluetoothBlueZTest; 180 friend class BluetoothBlueZTest;
163 friend class BluetoothBlueZTest_Shutdown_Test; 181 friend class BluetoothBlueZTest_Shutdown_Test;
164 friend class BluetoothBlueZTest_Shutdown_OnStartDiscovery_Test; 182 friend class BluetoothBlueZTest_Shutdown_OnStartDiscovery_Test;
165 friend class BluetoothBlueZTest_Shutdown_OnStartDiscoveryError_Test; 183 friend class BluetoothBlueZTest_Shutdown_OnStartDiscoveryError_Test;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // Called by BluetoothAdapterProfileBlueZ when no users of a profile 359 // Called by BluetoothAdapterProfileBlueZ when no users of a profile
342 // remain. 360 // remain.
343 void RemoveProfile(const device::BluetoothUUID& uuid); 361 void RemoveProfile(const device::BluetoothUUID& uuid);
344 362
345 // Processes the queued discovery requests. For each DiscoveryParamTuple in 363 // Processes the queued discovery requests. For each DiscoveryParamTuple in
346 // the queue, this method will try to add a new discovery session. This method 364 // the queue, this method will try to add a new discovery session. This method
347 // is called whenever a pending D-Bus call to start or stop discovery has 365 // is called whenever a pending D-Bus call to start or stop discovery has
348 // ended (with either success or failure). 366 // ended (with either success or failure).
349 void ProcessQueuedDiscoveryRequests(); 367 void ProcessQueuedDiscoveryRequests();
350 368
369 // Make the call to GattManager1 to register the services currently exported
370 // by the GATT Application service provider.
371 void RegisterApplication(
372 const base::Closure& callback,
373 const device::BluetoothGattService::ErrorCallback& error_callback);
374
351 InitCallback init_callback_; 375 InitCallback init_callback_;
352 376
353 bool initialized_; 377 bool initialized_;
354 378
355 // Set in |Shutdown()|, makes IsPresent()| return false. 379 // Set in |Shutdown()|, makes IsPresent()| return false.
356 bool dbus_is_shutdown_; 380 bool dbus_is_shutdown_;
357 381
358 // Number of discovery sessions that have been added. 382 // Number of discovery sessions that have been added.
359 int num_discovery_sessions_; 383 int num_discovery_sessions_;
360 384
(...skipping 28 matching lines...) Expand all
389 // Profiles that have been released and are pending removal. 413 // Profiles that have been released and are pending removal.
390 std::map<device::BluetoothUUID, BluetoothAdapterProfileBlueZ*> 414 std::map<device::BluetoothUUID, BluetoothAdapterProfileBlueZ*>
391 released_profiles_; 415 released_profiles_;
392 416
393 // Queue of delegates waiting for a profile to register. 417 // Queue of delegates waiting for a profile to register.
394 std::map<device::BluetoothUUID, std::vector<RegisterProfileCompletionPair>*> 418 std::map<device::BluetoothUUID, std::vector<RegisterProfileCompletionPair>*>
395 profile_queues_; 419 profile_queues_;
396 420
397 std::unique_ptr<device::BluetoothDiscoveryFilter> current_filter_; 421 std::unique_ptr<device::BluetoothDiscoveryFilter> current_filter_;
398 422
423 // List of GATT services that are owned by this adapter.
399 std::vector<std::unique_ptr<BluetoothLocalGattServiceBlueZ>> 424 std::vector<std::unique_ptr<BluetoothLocalGattServiceBlueZ>>
400 owned_gatt_services_; 425 owned_gatt_services_;
401 426
427 // GATT services that are currently available on the GATT server.
428 std::map<dbus::ObjectPath, BluetoothLocalGattServiceBlueZ*>
429 registered_gatt_services_;
430
431 // DBus Object Manager that acts as a service provider for all the services
432 // that are registered with this adapter.
433 std::unique_ptr<BluetoothGattApplicationServiceProvider>
434 gatt_application_provider_;
435
402 // Note: This should remain the last member so it'll be destroyed and 436 // Note: This should remain the last member so it'll be destroyed and
403 // invalidate its weak pointers before any other members are destroyed. 437 // invalidate its weak pointers before any other members are destroyed.
404 base::WeakPtrFactory<BluetoothAdapterBlueZ> weak_ptr_factory_; 438 base::WeakPtrFactory<BluetoothAdapterBlueZ> weak_ptr_factory_;
405 439
406 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterBlueZ); 440 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterBlueZ);
407 }; 441 };
408 442
409 } // namespace bluez 443 } // namespace bluez
410 444
411 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_ADAPTER_BLUEZ_H_ 445 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_ADAPTER_BLUEZ_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_local_gatt_service.cc ('k') | device/bluetooth/bluez/bluetooth_adapter_bluez.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698