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

Side by Side Diff: components/arc/bluetooth/arc_bluetooth_bridge.h

Issue 2101283003: arc: bluetooth: Implement Gatt server request to read/write (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gs2
Patch Set: Rebase to head Created 4 years, 5 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
« no previous file with comments | « no previous file | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 5 #ifndef COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_
6 #define COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 6 #define COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 25 matching lines...) Expand all
36 : public ArcService, 36 : public ArcService,
37 public InstanceHolder<mojom::BluetoothInstance>::Observer, 37 public InstanceHolder<mojom::BluetoothInstance>::Observer,
38 public device::BluetoothAdapter::Observer, 38 public device::BluetoothAdapter::Observer,
39 public device::BluetoothAdapterFactory::AdapterCallback, 39 public device::BluetoothAdapterFactory::AdapterCallback,
40 public device::BluetoothLocalGattService::Delegate, 40 public device::BluetoothLocalGattService::Delegate,
41 public mojom::BluetoothHost { 41 public mojom::BluetoothHost {
42 public: 42 public:
43 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); 43 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service);
44 ~ArcBluetoothBridge() override; 44 ~ArcBluetoothBridge() override;
45 45
46 // Overridden from 46 // Overridden from InstanceHolder<mojom::BluetoothInstance>::Observer:
47 // InstanceHolder<mojom::BluetoothInstance>::Observer:
48 void OnInstanceReady() override; 47 void OnInstanceReady() override;
49 48
50 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); 49 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter);
51 50
52 // Overridden from device::BluetoothAdadpter::Observer 51 // Overridden from device::BluetoothAdadpter::Observer
53 void AdapterPresentChanged(device::BluetoothAdapter* adapter, 52 void AdapterPresentChanged(device::BluetoothAdapter* adapter,
54 bool present) override; 53 bool present) override;
55 54
56 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, 55 void AdapterPoweredChanged(device::BluetoothAdapter* adapter,
57 bool powered) override; 56 bool powered) override;
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 mojom::BluetoothGattIDPtr desc_id) const; 338 mojom::BluetoothGattIDPtr desc_id) const;
340 339
341 // Propagates the list of paired device to Android. 340 // Propagates the list of paired device to Android.
342 void SendCachedPairedDevices() const; 341 void SendCachedPairedDevices() const;
343 342
344 bool IsGattServerAttributeHandleAvailable(int need); 343 bool IsGattServerAttributeHandleAvailable(int need);
345 int32_t GetNextGattServerAttributeHandle(); 344 int32_t GetNextGattServerAttributeHandle();
346 template <class LocalGattAttribute> 345 template <class LocalGattAttribute>
347 int32_t CreateGattAttributeHandle(LocalGattAttribute* attribute); 346 int32_t CreateGattAttributeHandle(LocalGattAttribute* attribute);
348 347
348 // Common code for OnCharacteristicReadRequest and OnDescriptorReadRequest
349 template <class LocalGattAttribute>
350 void OnGattAttributeReadRequest(const device::BluetoothDevice* device,
351 const LocalGattAttribute* attribute,
352 int offset,
353 const ValueCallback& success_callback,
354 const ErrorCallback& error_callback);
355
356 // Common code for OnCharacteristicWriteRequest and OnDescriptorWriteRequest
357 template <class LocalGattAttribute>
358 void OnGattAttributeWriteRequest(const device::BluetoothDevice* device,
359 const LocalGattAttribute* attribute,
360 const std::vector<uint8_t>& value,
361 int offset,
362 const base::Closure& success_callback,
363 const ErrorCallback& error_callback);
364
349 bool CalledOnValidThread(); 365 bool CalledOnValidThread();
350 366
351 mojo::Binding<mojom::BluetoothHost> binding_; 367 mojo::Binding<mojom::BluetoothHost> binding_;
352 368
353 scoped_refptr<bluez::BluetoothAdapterBlueZ> bluetooth_adapter_; 369 scoped_refptr<bluez::BluetoothAdapterBlueZ> bluetooth_adapter_;
354 scoped_refptr<device::BluetoothAdvertisement> advertisment_; 370 scoped_refptr<device::BluetoothAdvertisement> advertisment_;
355 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; 371 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_;
356 std::unordered_map<std::string, 372 std::unordered_map<std::string,
357 std::unique_ptr<device::BluetoothGattNotifySession>> 373 std::unique_ptr<device::BluetoothGattNotifySession>>
358 notification_session_; 374 notification_session_;
359 // Map from Android int handle to Chrome (BlueZ) string identifier. 375 // Map from Android int handle to Chrome (BlueZ) string identifier.
360 std::unordered_map<int32_t, std::string> gatt_identifier_; 376 std::unordered_map<int32_t, std::string> gatt_identifier_;
377 // Map from Chrome (BlueZ) string identifier to android int handle.
378 std::unordered_map<std::string, int32_t> gatt_handle_;
361 // Store last GattCharacteristic added to each GattService for GattServer. 379 // Store last GattCharacteristic added to each GattService for GattServer.
362 std::unordered_map<int32_t, int32_t> last_characteristic_; 380 std::unordered_map<int32_t, int32_t> last_characteristic_;
363 // Monotonically increasing value to use as handle to give to Android side. 381 // Monotonically increasing value to use as handle to give to Android side.
364 int32_t gatt_server_attribute_next_handle_ = 0; 382 int32_t gatt_server_attribute_next_handle_ = 0;
365 383
366 base::ThreadChecker thread_checker_; 384 base::ThreadChecker thread_checker_;
367 385
368 // WeakPtrFactory to use for callbacks. 386 // WeakPtrFactory to use for callbacks.
369 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; 387 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_;
370 388
371 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); 389 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge);
372 }; 390 };
373 391
374 } // namespace arc 392 } // namespace arc
375 393
376 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 394 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_
OLDNEW
« no previous file with comments | « no previous file | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698